mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: switch to FeatureSchema
This commit is contained in:
		
							parent
							
								
									d661096fb7
								
							
						
					
					
						commit
						b521fafd6b
					
				@ -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,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user