use-post-update-email.tsx 655 B

12345678910111213141516171819202122232425
  1. import { useMutation } from '@tanstack/react-query';
  2. import { userQueryKeys } from '../user-query-keys';
  3. import { userApi } from '../user-api';
  4. import { ResponseType } from '@api/response-type';
  5. import type { BaseAxiosError } from '../../../../types';
  6. export const usePostUpdateEmailMutation = () => {
  7. return useMutation<
  8. ResponseType,
  9. BaseAxiosError,
  10. {
  11. token: string;
  12. email: string;
  13. },
  14. ResponseType
  15. >({
  16. mutationKey: userQueryKeys.updateEmail(),
  17. mutationFn: async (variables) => {
  18. const response = await userApi.updateEmail(variables.token, variables.email);
  19. return response.data;
  20. }
  21. });
  22. };