File size: 662 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { BackupCodesDto, TwoFactorDto } from "@reactive-resume/dto";
import { useMutation } from "@tanstack/react-query";
import type { AxiosResponse } from "axios";

import { axios } from "@/client/libs/axios";

export const enable2FA = async (data: TwoFactorDto) => {
  const response = await axios.post<BackupCodesDto, AxiosResponse<BackupCodesDto>, TwoFactorDto>(
    "/auth/2fa/enable",
    data,
  );

  return response.data;
};

export const useEnable2FA = () => {
  const {
    error,
    isPending: loading,
    mutateAsync: enable2FAFn,
  } = useMutation({
    mutationFn: enable2FA,
  });

  return { enable2FA: enable2FAFn, loading, error };
};