2022-02-08 13:36:32 +01:00
|
|
|
import { getBasePath } from '../utils/format-path';
|
2022-02-23 15:08:44 +01:00
|
|
|
import { createPersistentGlobalStateHook } from './usePersistentGlobalState';
|
2022-02-08 13:36:32 +01:00
|
|
|
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 };
|
|
|
|
};
|
|
|
|
|
2022-02-23 15:08:44 +01:00
|
|
|
const useGlobalState = createPersistentGlobalStateHook<IEventSettings>(
|
2022-02-08 13:36:32 +01:00
|
|
|
`${getBasePath()}:useEventSettings:v1`,
|
|
|
|
createInitialValue()
|
|
|
|
);
|