Files
image-platform/apps/cabinet/src/business/auth/hooks/use-logout.hook.ts

21 lines
483 B
TypeScript
Raw Normal View History

import { useSWRConfig } from 'swr'
import { clearAdminToken, getAdminSessionKey } from 'infra/backend-api'
import type { LogoutAction } from '../types/auth-api.type'
/**
* Сценарий выхода администратора.
*/
export const useLogout = (): LogoutAction => {
const { mutate } = useSWRConfig()
const logout = async () => {
clearAdminToken()
await mutate(getAdminSessionKey(), undefined, { revalidate: false })
}
return {
logout,
}
}