More typing and fixes
This commit is contained in:
@@ -5,7 +5,7 @@ import { textClasses } from 'styles';
|
||||
import type { Application } from 'types';
|
||||
import AppItem from './AppItem';
|
||||
|
||||
function Applications({ contentType }: { contentType: [string] }) {
|
||||
function Applications({ contentType }: { contentType: string[] }) {
|
||||
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
||||
endpoint: 'api/apps',
|
||||
});
|
||||
@@ -17,16 +17,24 @@ function Applications({ contentType }: { contentType: [string] }) {
|
||||
setApplicationData(
|
||||
apps
|
||||
.filter((a: Application) => a.enabled === 1)
|
||||
.sort((a: any, b: any) => {
|
||||
.sort((a: Application, b: Application) => {
|
||||
switch (appSort) {
|
||||
case 'A>Z':
|
||||
return a.name > b.name ? 1 : -1;
|
||||
case 'Z>A':
|
||||
return a.name < b.name ? 1 : -1;
|
||||
case 'Newest':
|
||||
return a.id < b.id ? 1 : -1;
|
||||
if (a.id && b.id) {
|
||||
return a.id < b.id ? 1 : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
case 'Oldest':
|
||||
return a.id > b.id ? 1 : -1;
|
||||
if (a.id && b.id) {
|
||||
return a.id > b.id ? 1 : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
case 'Custom':
|
||||
return a.index > b.index ? 1 : -1;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { textClasses } from 'styles';
|
||||
import type { Bookmark, BookmarkGroup } from 'types';
|
||||
import LinkGroups from './LinkGroups';
|
||||
|
||||
function Links({ contentType }: { contentType: [string] }) {
|
||||
function Links({ contentType }: { contentType: string[] }) {
|
||||
const { data: linkData, isFetched: linksIsFetched } = useQueryAPI({
|
||||
endpoint: 'api/links',
|
||||
});
|
||||
@@ -28,18 +28,26 @@ function Links({ contentType }: { contentType: [string] }) {
|
||||
return category;
|
||||
});
|
||||
setGroups(
|
||||
groupList.sort((a: any, b: any) => {
|
||||
groupList.sort((a: BookmarkGroup, b: BookmarkGroup) => {
|
||||
switch (bookmarkSort) {
|
||||
case 'A>Z':
|
||||
return a.categoryName > b.categoryName ? 1 : -1;
|
||||
case 'Z>A':
|
||||
return a.categoryName < b.categoryName ? 1 : -1;
|
||||
case 'Newest':
|
||||
return a.id < b.id ? 1 : -1;
|
||||
if (a.id && b.id) {
|
||||
return a.id < b.id ? 1 : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
case 'Oldest':
|
||||
return a.id > b.id ? 1 : -1;
|
||||
if (a.id && b.id) {
|
||||
return a.id > b.id ? 1 : -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
case 'Custom':
|
||||
return a.index > b.index ? 1 : -1;
|
||||
return a.categoryIndex > b.categoryIndex ? 1 : -1;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Group, Stack, Text } from '@mantine/core';
|
||||
import { useCommonHooks } from 'hooks';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { textClasses } from 'styles';
|
||||
import type { CurrentWeather as CW } from 'types';
|
||||
import type { CurrentWeather } from 'types';
|
||||
|
||||
function Header({
|
||||
greet,
|
||||
@@ -15,8 +15,8 @@ function Header({
|
||||
}: {
|
||||
greet: string;
|
||||
date: string;
|
||||
current: CW;
|
||||
setCurrent: (current: CW) => void;
|
||||
current: CurrentWeather;
|
||||
setCurrent: (current: CurrentWeather) => void;
|
||||
weather: any;
|
||||
basicWeather: any;
|
||||
openWeatherModal: () => void;
|
||||
|
||||
@@ -67,11 +67,11 @@ export default function Search({
|
||||
const [placeholderValue, setPlaceholderValue] = useState('');
|
||||
const [value, setValue] = useState(0);
|
||||
|
||||
const handleSearchHistoryItem = (item: any) => {
|
||||
const handleSearchHistoryItem = ({ option }: { option: SearchHistoryItem }) => {
|
||||
const url =
|
||||
providers.find((provider: Provider) => provider.prefix === item.option.prefix)
|
||||
?.url ?? 'https://www.google.com/search?q=';
|
||||
open(`${url}${item.option.searchTerm}`, '_self');
|
||||
providers.find((provider: Provider) => provider.prefix === option.prefix)?.url ??
|
||||
'https://www.google.com/search?q=';
|
||||
open(`${url}${option.searchTerm}`, '_self');
|
||||
};
|
||||
|
||||
const handleAppSearchItem = (item: any) => {
|
||||
@@ -425,7 +425,7 @@ export default function Search({
|
||||
useEffect(() => {
|
||||
const splittedSearch = searchValue.toLowerCase().trim().split(' ');
|
||||
const filtered = searchHistory
|
||||
.filter((item: any) => {
|
||||
.filter((item: SearchHistoryItem) => {
|
||||
const option = `${item.prefix} ${item.searchTerm}`;
|
||||
const words = option.toLowerCase().trim().split(' ');
|
||||
return splittedSearch.every((searchWord) =>
|
||||
@@ -450,7 +450,7 @@ export default function Search({
|
||||
<Select
|
||||
classNames={selectClasses}
|
||||
className={selectClasses.search}
|
||||
data={searchHistory.map((item: any) => ({
|
||||
data={searchHistory.map((item: SearchHistoryItem) => ({
|
||||
label: `${item.provider}`,
|
||||
value: `${item.prefix} ${item.searchTerm} ${item.dateTimeStamp}`,
|
||||
...item,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
ActionIcon,
|
||||
Button,
|
||||
type ComboboxItem,
|
||||
Group,
|
||||
Menu,
|
||||
MultiSelect,
|
||||
@@ -169,7 +170,9 @@ function SettingsButton() {
|
||||
macAddress: wolClient.macAddress,
|
||||
};
|
||||
})
|
||||
.toSorted((a: any, b: any) => a.label.localeCompare(b.label)) || []
|
||||
.toSorted((a: ComboboxItem, b: ComboboxItem) =>
|
||||
a.label.localeCompare(b.label),
|
||||
) ?? []
|
||||
}
|
||||
w='92%'
|
||||
classNames={{
|
||||
@@ -179,8 +182,6 @@ function SettingsButton() {
|
||||
option: selectClasses.menuSelectOption,
|
||||
}}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
onChange={(_value, option: any) => setSelectedClient(option)}
|
||||
onLoad={(option: any) => setSelectedClient(option)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack
|
||||
@@ -252,7 +253,9 @@ function SettingsButton() {
|
||||
label: playlist.name,
|
||||
};
|
||||
})
|
||||
.toSorted((a: any, b: any) => a.label.localeCompare(b.label)) ?? []
|
||||
.toSorted((a: ComboboxItem, b: ComboboxItem) =>
|
||||
a.label.localeCompare(b.label),
|
||||
) ?? []
|
||||
}
|
||||
w='92%'
|
||||
classNames={{
|
||||
@@ -262,7 +265,7 @@ function SettingsButton() {
|
||||
option: selectClasses.menuSelectOption,
|
||||
}}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
onChange={(_value, option: any) => {
|
||||
onChange={(_value, option: ComboboxItem) => {
|
||||
setCurrentThemePlaylist(option.value);
|
||||
if (option.value !== 'Time of Day') {
|
||||
setThemeName('random');
|
||||
@@ -281,7 +284,6 @@ function SettingsButton() {
|
||||
);
|
||||
}
|
||||
}}
|
||||
onLoad={(option: any) => setCurrentThemePlaylist(option)}
|
||||
/>
|
||||
</Stack>
|
||||
</Stack>
|
||||
@@ -329,7 +331,7 @@ function SettingsButton() {
|
||||
<MultiSelect
|
||||
label='Filter'
|
||||
data={
|
||||
categories.toSorted((a: any, b: any) =>
|
||||
categories.toSorted((a: ComboboxItem, b: ComboboxItem) =>
|
||||
a.label.localeCompare(b.label),
|
||||
) ?? []
|
||||
}
|
||||
@@ -341,7 +343,7 @@ function SettingsButton() {
|
||||
: 'No apps selected'
|
||||
}
|
||||
defaultValue={appFilter}
|
||||
onChange={(data: any) => {
|
||||
onChange={(data: string[]) => {
|
||||
setAppFilter(data);
|
||||
}}
|
||||
classNames={multiSelectClasses}
|
||||
@@ -359,7 +361,7 @@ function SettingsButton() {
|
||||
option: selectClasses.menuSelectOption,
|
||||
}}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
onChange={(_value, option: any) => {
|
||||
onChange={(_value, option: ComboboxItem) => {
|
||||
setAppSort(option.value);
|
||||
}}
|
||||
/>
|
||||
@@ -408,7 +410,7 @@ function SettingsButton() {
|
||||
<MultiSelect
|
||||
label='Filter'
|
||||
data={
|
||||
categories.toSorted((a: any, b: any) =>
|
||||
categories.toSorted((a: ComboboxItem, b: ComboboxItem) =>
|
||||
a.label.localeCompare(b.label),
|
||||
) ?? []
|
||||
}
|
||||
@@ -420,7 +422,7 @@ function SettingsButton() {
|
||||
: 'No bookmarks selected'
|
||||
}
|
||||
defaultValue={bookmarkFilter}
|
||||
onChange={(data: any) => {
|
||||
onChange={(data: string[]) => {
|
||||
setBookmarkFilter(data);
|
||||
}}
|
||||
classNames={multiSelectClasses}
|
||||
@@ -438,7 +440,7 @@ function SettingsButton() {
|
||||
option: selectClasses.menuSelectOption,
|
||||
}}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
onChange={(_value, option: any) => {
|
||||
onChange={(_value, option: ComboboxItem) => {
|
||||
setBookmarkSort(option.value);
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user