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