/* eslint-disable @typescript-eslint/no-explicit-any */ import React from "react"; import Swal from "sweetalert2"; import { Formik, Form, Field, ErrorMessage } from "formik"; import * as Yup from "yup"; import { forgotPassword } from "../../Api/CustomerApi"; interface ForgotModalProps { isSubmitting: boolean; setModalType: (type: string) => void; } const ForgotModal: React.FC = ({ setModalType }) => { const initialValues = { email: "" }; const validationSchema = Yup.object().shape({ email: Yup.string() .email("Invalid email format") .required("Email is required"), }); const handleForgotPassword = async ( values: { email: string }, { setSubmitting }: any ) => { try { const response = await forgotPassword({ email: values.email }); if (response.status) { Swal.fire({ icon: "success", title: "Success", text: "Reset instructions sent to your email", customClass: { confirmButton: "delybell-primary px-4", cancelButton: 'delybell-dark' }, // text: response.message || 'Your profile has been successfully updated.', }); } else { Swal.fire({ icon: "error", title: "Error!", text: response.message || "Something went wrong. Please try again.", customClass: { confirmButton: "delybell-primary px-4", cancelButton: 'delybell-dark' }, }); } // Swal.fire("Success", "Reset instructions sent to your email", "success"); setSubmitting(false); } catch (error: any) { console.error("Forgot password error:", error); Swal.fire( "Error", error?.response?.data?.message || "Something went wrong", "error" ); setSubmitting(false); } }; return ( {({ isSubmitting }) => (

Reset Your Account

Forgot Password

Enter your email addresse below and we ll send you the reset instructions.

(required)
{/* Submit Button */}
)}
); }; export default ForgotModal;