mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 12:26:40 +07:00
16 lines
475 B
TypeScript
16 lines
475 B
TypeScript
import useSWR from 'swr';
|
|
|
|
import { apiCheckRestoreCode } from '~/api/auth';
|
|
import { API } from '~/constants/api';
|
|
import { getErrorMessage } from '~/utils/errors/getErrorMessage';
|
|
|
|
export const useRestoreCode = (code: string) => {
|
|
const { data, isValidating, error } = useSWR(
|
|
API.USER.REQUEST_CODE(code),
|
|
() => apiCheckRestoreCode({ code }),
|
|
);
|
|
|
|
const codeUser = data?.user;
|
|
|
|
return { codeUser, isLoading: isValidating, error: getErrorMessage(error) };
|
|
};
|