frontend_nyla/src/api/storeApi.ts
2026-02-23 17:13:31 +01:00

47 lines
1.3 KiB
TypeScript

/**
* Store API
*
* API layer for the Feature Store.
* Manages feature activation/deactivation in the root mandate's shared instances.
*/
import api from '../api';
export interface StoreFeature {
featureCode: string;
label: Record<string, string>;
icon: string;
description: Record<string, string>;
isActive: boolean;
canActivate: boolean;
instanceId: string | null;
}
export interface StoreActivateResponse {
featureCode: string;
instanceId: string;
featureAccessId: string;
roleId: string | null;
activated: boolean;
}
export interface StoreDeactivateResponse {
featureCode: string;
instanceId: string;
deactivated: boolean;
}
export async function fetchStoreFeatures(): Promise<StoreFeature[]> {
const response = await api.get<StoreFeature[]>('/api/store/features');
return response.data;
}
export async function activateStoreFeature(featureCode: string): Promise<StoreActivateResponse> {
const response = await api.post<StoreActivateResponse>('/api/store/activate', { featureCode });
return response.data;
}
export async function deactivateStoreFeature(featureCode: string): Promise<StoreDeactivateResponse> {
const response = await api.post<StoreDeactivateResponse>('/api/store/deactivate', { featureCode });
return response.data;
}