1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00

chore: switch to FeatureSchema

This commit is contained in:
Thomas Heartman 2024-11-20 14:49:37 +01:00
parent d661096fb7
commit b521fafd6b
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78

View File

@ -1,12 +1,11 @@
import useSWR, { type SWRConfiguration } from 'swr'; import useSWR, { type SWRConfiguration } from 'swr';
import { useCallback } from 'react'; import { useCallback } from 'react';
import { emptyFeature } from './emptyFeature';
import handleErrorResponses from '../httpErrorResponseHandler'; import handleErrorResponses from '../httpErrorResponseHandler';
import { formatApiPath } from 'utils/formatPath'; import { formatApiPath } from 'utils/formatPath';
import type { IFeatureToggle } from 'interfaces/featureToggle'; import type { FeatureSchema } from 'openapi';
export interface IUseFeatureOutput { export interface IUseFeatureOutput {
feature: IFeatureToggle; feature: FeatureSchema;
refetchFeature: () => void; refetchFeature: () => void;
loading: boolean; loading: boolean;
status?: number; status?: number;
@ -15,7 +14,7 @@ export interface IUseFeatureOutput {
export interface IFeatureResponse { export interface IFeatureResponse {
status: number; status: number;
body?: IFeatureToggle; body?: FeatureSchema;
} }
export const useFeature = ( export const useFeature = (
@ -36,7 +35,7 @@ export const useFeature = (
}, [mutate]); }, [mutate]);
return { return {
feature: data?.body || emptyFeature, feature: data?.body || { name: '' },
refetchFeature, refetchFeature,
loading: !error && !data, loading: !error && !data,
status: data?.status, status: data?.status,