Make api name editable and add expiry (#6473)

Fixes #6302

---------

Co-authored-by: martmull <martmull@hotmail.fr>
This commit is contained in:
Prateek Jain
2024-08-02 17:01:06 +05:30
committed by GitHub
parent 68120d529c
commit 281bf689fa
13 changed files with 155 additions and 78 deletions

View File

@ -0,0 +1,26 @@
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
import { SettingsPath } from '@/types/SettingsPath';
import { apiKeyTokenState } from '@/settings/developers/states/generatedApiKeyTokenState';
import { useRecoilValue, useResetRecoilState } from 'recoil';
import { AppPath } from '@/types/AppPath';
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,
};
};