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