2023-02-27 01:54:28 +01:00
|
|
|
import { createContext } from 'react';
|
2022-04-27 23:19:20 -07:00
|
|
|
import { ClientConfig } from '../interfaces/client-config.model';
|
2022-05-27 15:08:59 -07:00
|
|
|
|
2022-10-02 10:21:38 -07:00
|
|
|
const ENDPOINT = `/api/config`;
|
2022-04-25 23:10:07 -07:00
|
|
|
|
2023-02-27 01:54:28 +01:00
|
|
|
export interface ClientConfigStaticService {
|
|
|
|
getConfig(): Promise<ClientConfig>;
|
|
|
|
}
|
|
|
|
|
2022-04-25 23:10:07 -07:00
|
|
|
class ClientConfigService {
|
|
|
|
public static async getConfig(): Promise<ClientConfig> {
|
2022-05-27 18:44:26 -07:00
|
|
|
const response = await fetch(ENDPOINT);
|
2022-04-25 23:10:07 -07:00
|
|
|
const status = await response.json();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-27 01:54:28 +01:00
|
|
|
export const ClientConfigServiceContext =
|
|
|
|
createContext<ClientConfigStaticService>(ClientConfigService);
|