import { useAdminResendNotification } from "medusa-react" import React from "react" import { useForm } from "react-hook-form" import Button from "../../../../components/fundamentals/button" import Input from "../../../../components/molecules/input" import Modal from "../../../../components/molecules/modal" import useNotification from "../../../../hooks/use-notification" import { getErrorMessage } from "../../../../utils/error-messages" type ResendModalProps = { notificationId: string email: string handleCancel: () => void } const ResendModal: React.FC = ({ notificationId, email, handleCancel, }) => { const { mutate, isLoading } = useAdminResendNotification(notificationId) const { register, handleSubmit } = useForm({ defaultValues: { to: email }, }) const notification = useNotification() const handleResend = (data) => { mutate( { to: data.to.trim(), }, { onSuccess: () => { notification( "Success", `Notification re-send to ${data.to}`, "success" ) handleCancel() }, onError: (err) => notification("Error", getErrorMessage(err), "error"), } ) } return (
Resend notification
) } export default ResendModal