1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/src/hooks/useEventSettings.ts
olav 2e367b3a04 feat: add trial expiration warning banner (#985)
* refactor: simplify useApiGetter cache keys

* refactor: simplify basePath helpers

* refactor: add UNLEASH_BASE_PATH frontend env var

* refactor: make sure AnnouncerElement does not affect the layout

* refactor: draw texture image above footer

* refactor: extract domain check helpers

* refactor: fix a few ts-expect-errors

* feat: add trial expiration warning banner

* refactor: fix IInstanceStatus interface prefix

* refactor: use ConditionallyRender in InstanceStatus

* refactor: simplify env helper functions

* refactor: use FC in InstanceStatus

* refactor: warn about expired trials

* refactor: fix eslint warnings

* refactor: disable banner outside of localhost

* refactor: use new instance state field name
2022-05-19 14:06:18 +02:00

28 lines
769 B
TypeScript

import { basePath } from 'utils/formatPath';
import { createPersistentGlobalStateHook } from './usePersistentGlobalState';
import React from 'react';
export interface IEventSettings {
showData: boolean;
}
interface IUseEventSettingsOutput {
eventSettings: IEventSettings;
setEventSettings: React.Dispatch<React.SetStateAction<IEventSettings>>;
}
export const useEventSettings = (): IUseEventSettingsOutput => {
const [eventSettings, setEventSettings] = useGlobalState();
return { eventSettings, setEventSettings };
};
const createInitialValue = (): IEventSettings => {
return { showData: false };
};
const useGlobalState = createPersistentGlobalStateHook<IEventSettings>(
`${basePath}:useEventSettings:v1`,
createInitialValue()
);