"use client" import type { IUserSchema } from "@/src/entities/models/users/users.model" import { useSendMagicLinkMutation, useSendPasswordRecoveryMutation } from "@/app/(pages)/(auth)/_queries/mutations" import { toast } from "sonner" export const useSendPasswordRecoveryHandler = (user: IUserSchema, onOpenChange: (open: boolean) => void) => { const { mutateAsync: sendPasswordRecovery, isPending } = useSendPasswordRecoveryMutation() const handleSendPasswordRecovery = async () => { if (user.email) { await sendPasswordRecovery(user.email, { onSuccess: () => { toast.success(`Password recovery email sent to ${user.email}`) onOpenChange(false) }, onError: (error) => { toast.error(error.message) onOpenChange(false) }, }) } } return { handleSendPasswordRecovery, isPending, } }