This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-6871](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6871). --- ### Description Migrate: - Info display component - Status display component - SeparatorLineText display component ### Demo ###### SeparatorLineText In Storybook  Info Component on Storybook  Status Component on Storybook  ###### Fixes twentyhq/private-issues#95 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
28 lines
878 B
TypeScript
28 lines
878 B
TypeScript
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
|
|
import { AppPath } from '@/types/AppPath';
|
|
import { SettingsPath } from '@/types/SettingsPath';
|
|
import { useRecoilValue, useResetRecoilState } from 'recoil';
|
|
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
|
|
|
import { isDefined } from '~/utils/isDefined';
|
|
|
|
export const useCleanRecoilState = () => {
|
|
const isMatchingLocation = useIsMatchingLocation();
|
|
const resetApiKeyToken = useResetRecoilState(apiKeyTokenState);
|
|
const apiKeyToken = useRecoilValue(apiKeyTokenState);
|
|
const cleanRecoilState = () => {
|
|
if (
|
|
!isMatchingLocation(
|
|
`${AppPath.Settings}/${AppPath.Developers}/${SettingsPath.DevelopersApiKeyDetail}`,
|
|
) &&
|
|
isDefined(apiKeyToken)
|
|
) {
|
|
resetApiKeyToken();
|
|
}
|
|
};
|
|
|
|
return {
|
|
cleanRecoilState,
|
|
};
|
|
};
|