mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
2e367b3a04
* 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
30 lines
836 B
TypeScript
30 lines
836 B
TypeScript
import { basePath } from 'utils/formatPath';
|
|
import { createPersistentGlobalStateHook } from './usePersistentGlobalState';
|
|
import React from 'react';
|
|
|
|
export interface ILocationSettings {
|
|
locale: string;
|
|
}
|
|
|
|
interface IUseLocationSettingsOutput {
|
|
locationSettings: ILocationSettings;
|
|
setLocationSettings: React.Dispatch<
|
|
React.SetStateAction<ILocationSettings>
|
|
>;
|
|
}
|
|
|
|
export const useLocationSettings = (): IUseLocationSettingsOutput => {
|
|
const [locationSettings, setLocationSettings] = useGlobalState();
|
|
|
|
return { locationSettings, setLocationSettings };
|
|
};
|
|
|
|
const createInitialValue = (): ILocationSettings => {
|
|
return { locale: navigator.language };
|
|
};
|
|
|
|
const useGlobalState = createPersistentGlobalStateHook<ILocationSettings>(
|
|
`${basePath}:useLocationSettings:v1`,
|
|
createInitialValue()
|
|
);
|