mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 14:25:47 +00:00
feat(FE): Add constants transformation utilities and API service
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user