feat(FE): Add constants transformation utilities and API service

This commit is contained in:
rstubryan
2026-03-02 09:57:21 +07:00
parent 04b5a7bd4d
commit aa1ef7a559
3 changed files with 237 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import { httpClient } from '@/services/http/client';
import {
ConstantsApiResponse,
TransformedConstants,
} from '@/types/api/constants/constants';
import { transformConstants } from '@/lib/helper';
class ConstantsApiService {
async fetchConstants(): Promise<ConstantsApiResponse | undefined> {
try {
const response = await httpClient<ConstantsApiResponse>('/constants');
return response;
} catch {
return undefined;
}
}
async fetchTransformedConstants(): Promise<TransformedConstants | undefined> {
const data = await this.fetchConstants();
if (!data) return undefined;
return transformConstants(data);
}
}
export const ConstantsApi = new ConstantsApiService();