|
1 | | -import React, { useMemo, useState } from 'react'; |
| 1 | +import React, { useState } from 'react'; |
2 | 2 | import { useTranslation } from 'react-i18next'; |
3 | 3 | import { format } from 'date-fns'; |
4 | 4 |
|
5 | 5 | import { Button, ListEmptyMessage, NavigateLink, StatusIndicator } from 'components'; |
6 | | -import { SelectCSDProps } from 'components'; |
7 | 6 |
|
8 | 7 | import { DATE_TIME_FORMAT } from 'consts'; |
9 | 8 | import { useNotifications } from 'hooks'; |
10 | 9 | import { useLocalStorageState } from 'hooks/useLocalStorageState'; |
| 10 | +import { useProjectFilter } from 'hooks/useProjectFilter'; |
11 | 11 | import { getServerError } from 'libs'; |
12 | 12 | import { getStatusIconType } from 'libs/volumes'; |
13 | 13 | import { ROUTES } from 'routes'; |
14 | | -import { useGetProjectsQuery } from 'services/project'; |
15 | 14 | import { useDeleteVolumesMutation } from 'services/volume'; |
16 | 15 |
|
17 | 16 | export const useVolumesTableEmptyMessages = ({ |
@@ -102,17 +101,9 @@ export const useColumnsDefinitions = () => { |
102 | 101 | return { columns } as const; |
103 | 102 | }; |
104 | 103 |
|
105 | | -export const useFilters = (storagePrefix?: string) => { |
106 | | - const [onlyActive, setOnlyActive] = useLocalStorageState<boolean>(`${storagePrefix}volume-list-is-active`, true); |
107 | | - const [selectedProject, setSelectedProject] = useState<SelectCSDProps.Option | null>(null); |
108 | | - |
109 | | - const { data: projectsData } = useGetProjectsQuery(); |
110 | | - |
111 | | - const projectOptions = useMemo<SelectCSDProps.Options>(() => { |
112 | | - if (!projectsData?.length) return []; |
113 | | - |
114 | | - return projectsData.map((project) => ({ label: project.project_name, value: project.project_name })); |
115 | | - }, [projectsData]); |
| 104 | +export const useFilters = (localStorePrefix = 'volume-list-page') => { |
| 105 | + const [onlyActive, setOnlyActive] = useLocalStorageState<boolean>(`${localStorePrefix}-is-active`, true); |
| 106 | + const { selectedProject, setSelectedProject, projectOptions } = useProjectFilter({ localStorePrefix }); |
116 | 107 |
|
117 | 108 | const clearFilters = () => { |
118 | 109 | setOnlyActive(false); |
|
0 commit comments