diff --git a/frontend/src/component/application/ApplicationUpdate/ApplicationUpdate.tsx b/frontend/src/component/application/ApplicationUpdate/ApplicationUpdate.tsx index a295c84212..ac8dc84115 100644 --- a/frontend/src/component/application/ApplicationUpdate/ApplicationUpdate.tsx +++ b/frontend/src/component/application/ApplicationUpdate/ApplicationUpdate.tsx @@ -5,19 +5,9 @@ import icons from '../icon-names'; import GeneralSelect from '../../common/GeneralSelect/GeneralSelect'; import useApplicationsApi from '../../../hooks/api/actions/useApplicationsApi/useApplicationsApi'; import useToast from '../../../hooks/useToast'; +import { IApplication } from '../../../interfaces/application'; + -interface IApplication { - appName: string; - color: string; - createdAt: string; - description: string; - icon: string; - instances: []; - links: object; - seenToggles: []; - strategies: []; - url: string; -} interface IApplicationUpdateProps { application: IApplication; } diff --git a/frontend/src/hooks/api/getters/useApplication/useApplication.ts b/frontend/src/hooks/api/getters/useApplication/useApplication.ts index 7cc8344ca0..7453b35a0d 100644 --- a/frontend/src/hooks/api/getters/useApplication/useApplication.ts +++ b/frontend/src/hooks/api/getters/useApplication/useApplication.ts @@ -2,8 +2,20 @@ import useSWR, { mutate, SWRConfiguration } from 'swr'; import { useState, useEffect } from 'react'; import { formatApiPath } from '../../../../utils/format-path'; import handleErrorResponses from '../httpErrorResponseHandler'; +import { IApplication } from '../../../../interfaces/application'; -const useApplication = (name: string, options: SWRConfiguration = {}) => { +interface IUseApplicationOutput { + application: IApplication; + refetchApplication: () => void; + loading: boolean; + error?: Error; + APPLICATION_CACHE_KEY: string; +} + +const useApplication = ( + name: string, + options: SWRConfiguration = {} +): IUseApplicationOutput => { const path = formatApiPath(`api/admin/metrics/applications/${name}`); const fetcher = async () => { diff --git a/frontend/src/hooks/api/getters/useApplications/useApplications.ts b/frontend/src/hooks/api/getters/useApplications/useApplications.ts index c2c4ea1464..c6d15753d7 100644 --- a/frontend/src/hooks/api/getters/useApplications/useApplications.ts +++ b/frontend/src/hooks/api/getters/useApplications/useApplications.ts @@ -2,10 +2,21 @@ import useSWR, { mutate, SWRConfiguration } from 'swr'; import { useState, useEffect } from 'react'; import { formatApiPath } from '../../../../utils/format-path'; import handleErrorResponses from '../httpErrorResponseHandler'; +import { IApplication } from '../../../../interfaces/application'; const path = formatApiPath('api/admin/metrics/applications'); -const useApplications = (options: SWRConfiguration = {}) => { +interface IUseApplicationsOutput { + applications: IApplication[]; + refetchApplications: () => void; + loading: boolean; + error?: Error; + APPLICATIONS_CACHE_KEY: string; +} + +const useApplications = ( + options: SWRConfiguration = {} +): IUseApplicationsOutput => { const fetcher = async () => { return fetch(path, { method: 'GET', diff --git a/frontend/src/interfaces/application.ts b/frontend/src/interfaces/application.ts new file mode 100644 index 0000000000..17b79deb9d --- /dev/null +++ b/frontend/src/interfaces/application.ts @@ -0,0 +1,12 @@ +export interface IApplication { + appName: string; + color: string; + createdAt: string; + description: string; + icon: string; + instances: []; + links: object; + seenToggles: []; + strategies: []; + url: string; +}