Clean up and typing
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
textClasses,
|
||||
textInputClasses,
|
||||
} from 'styles';
|
||||
import type { Application } from 'types';
|
||||
import AppSettingsItem from './AppSettingsItem';
|
||||
import DebouncedApplication from './DebouncedApplication';
|
||||
|
||||
@@ -32,27 +33,26 @@ const ApplicationSettings = () => {
|
||||
const { data: apps, isFetching: isAppsFetching } = useQueryAPI({
|
||||
endpoint: endpoint,
|
||||
});
|
||||
const [applicationData, setApplicationData] = useState<any>([]);
|
||||
const { theme, isMobile } = useCommonHooks();
|
||||
const [newApplication, setNewApplication] = useState<any>({
|
||||
const [applicationData, setApplicationData] = useState<Application[]>([]);
|
||||
const { theme, isMobile, modalStyle } = useCommonHooks();
|
||||
const [newApplication, setNewApplication] = useState<Application>({
|
||||
id: undefined,
|
||||
name: '',
|
||||
url: '',
|
||||
icon: '',
|
||||
baseUrl: '',
|
||||
filterName: '',
|
||||
index: 0,
|
||||
});
|
||||
const { mutateAsync } = useMutationAPI();
|
||||
const [searchValue, setSearchValue] = useState('');
|
||||
const [debouncedSearch] = useDebouncedValue(searchValue, 500);
|
||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||
const handleDelete = (application: any) => {
|
||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: application });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (apps && !isAppsFetching) {
|
||||
setApplicationData(
|
||||
apps.filter((a: any) =>
|
||||
apps.filter((a: Application) =>
|
||||
a.name.toLowerCase().includes(debouncedSearch.toLowerCase()),
|
||||
),
|
||||
);
|
||||
@@ -70,14 +70,7 @@ const ApplicationSettings = () => {
|
||||
onClose={() => {
|
||||
closeModal();
|
||||
}}
|
||||
style={{
|
||||
'--color-text-pri': theme.primaryColor,
|
||||
'--color-text-acc': theme.accentColor,
|
||||
'--color-background': theme.backgroundColor,
|
||||
'--color-border': theme.borderColor,
|
||||
'--color-search-background': theme.searchColor,
|
||||
'--image-background': `url(${theme.backgroundImage})`,
|
||||
}}
|
||||
style={modalStyle}
|
||||
closeOnEscape
|
||||
closeOnClickOutside
|
||||
>
|
||||
@@ -269,7 +262,7 @@ const ApplicationSettings = () => {
|
||||
</Group>
|
||||
<Stack w={'100%'} align='center'>
|
||||
<Grid columns={18} w={'75%'}>
|
||||
{applicationData?.map((application: any) => (
|
||||
{applicationData?.map((application: Application) => (
|
||||
<GridCol span={6} key={application.id}>
|
||||
<Popover withArrow withOverlay withinPortal={false}>
|
||||
<Popover.Target>
|
||||
@@ -286,10 +279,7 @@ const ApplicationSettings = () => {
|
||||
</Box>
|
||||
</Popover.Target>
|
||||
<Popover.Dropdown>
|
||||
<DebouncedApplication
|
||||
application={application}
|
||||
handleDelete={handleDelete}
|
||||
/>
|
||||
<DebouncedApplication application={application} />
|
||||
</Popover.Dropdown>
|
||||
</Popover>
|
||||
</GridCol>
|
||||
|
||||
Reference in New Issue
Block a user