Files
mtdb_movie/common/resources/client/auth/requests/use-resend-verification-email.ts
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

31 lines
929 B
TypeScript
Executable File

import {useMutation} from '@tanstack/react-query';
import {BackendResponse} from '../../http/backend-response/backend-response';
import {toast} from '../../ui/toast/toast';
import {message} from '../../i18n/message';
import {apiClient} from '../../http/query-client';
import {showHttpErrorToast} from '../../utils/http/show-http-error-toast';
interface Response extends BackendResponse {
message: string;
}
export interface ResendConfirmEmailPayload {
email: string;
}
export function useResendVerificationEmail() {
return useMutation({
mutationFn: (payload: ResendConfirmEmailPayload) => resendEmail(payload),
onSuccess: () => {
toast(message('Email sent'));
},
onError: err => showHttpErrorToast(err),
});
}
function resendEmail(payload: ResendConfirmEmailPayload): Promise<Response> {
return apiClient
.post('resend-email-verification', payload)
.then(response => response.data);
}