mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
23 lines
707 B
TypeScript
23 lines
707 B
TypeScript
|
import { useEffect, useState } from 'react';
|
||
|
import { getLocalStorageItem, setLocalStorageItem } from '../utils/storage';
|
||
|
import { basePath } from 'utils/formatPath';
|
||
|
|
||
|
export type IFeedbackCategory = 'search';
|
||
|
|
||
|
export const useUserSubmittedFeedback = (category: IFeedbackCategory) => {
|
||
|
const key = `${basePath}:unleash-userSubmittedFeedback:${category}`;
|
||
|
|
||
|
const [hasSubmittedFeedback, setHasSubmittedFeedback] = useState(() => {
|
||
|
return getLocalStorageItem<boolean>(key) || false;
|
||
|
});
|
||
|
|
||
|
useEffect(() => {
|
||
|
setLocalStorageItem(key, hasSubmittedFeedback);
|
||
|
}, [hasSubmittedFeedback, key]);
|
||
|
|
||
|
return {
|
||
|
hasSubmittedFeedback,
|
||
|
setHasSubmittedFeedback,
|
||
|
};
|
||
|
};
|