import { createLazyFileRoute } from "@tanstack/react-router"; import { TbArrowNarrowRight } from "react-icons/tb"; import { IoIosArrowUp } from "react-icons/io"; import { HiOutlineGlobeAlt } from "react-icons/hi"; import { useForm, Control, FieldError } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { Button } from "@/shadcn/components/ui/button.tsx"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/shadcn/components/ui/form.tsx"; import { Input } from "@/shadcn/components/ui/input.tsx"; import client from "@/honoClient"; import { useState } from "react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "@/shadcn/components/ui/dropdown-menu"; // Define validation schema using zod const formSchema = z.object({ email: z.string().email(), }); type FormSchema = z.infer; // Interface for props of CustomFormField interface CustomFormFieldProps { name: keyof FormSchema; label: string; control: Control; type?: string; placeholder?: string; error?: FieldError; // Add error prop } // Component for form fields with bold labels const CustomFormField: React.FC = ({ name, label, control, type = "text", placeholder, error, }) => ( ( {label} )} /> ); interface DropdownProps { onSelect: (selectedOption: string) => void; defaultOption?: string; listOption?: string[]; } const CustomDropdownMenu: React.FC = ({ onSelect, defaultOption = "", listOption = [], }) => { const [selectedOption, setSelectedOption] = useState(defaultOption); const handleSelect = (option: string) => { setSelectedOption(option); onSelect(option); }; return ( {listOption.map((option, index) => ( {option} ))} ); }; // Define a route for the registration form export const Route = createLazyFileRoute("/forgot-password/")({ component: () => (
), }); // Main components of the registration form export function ForgotPasswordForm() { // Set up form with react-hook-form and zod const form = useForm({ // Integrate schema with form resolver: zodResolver(formSchema), defaultValues: { email: "", }, }); // Function to handle form submission const onSubmit = async (values: FormSchema) => { try { const response = await client["forgot-password"].$post({ json: values, }); if (response.ok) { // Handle successful registration here alert("Reset instructions sent successfully"); const data = await response.json(); return data; } else { throw response; } } catch (error) { // Handle registration error here console.error("Submission error:", error); alert("Failed to send reset instructions"); } }; const handleSelect = (selectedOption: string) => { console.log('Selected option:', selectedOption); // Do something with selected option }; return (
{/* Top */}
Amati
{/* Center */}

Forgot Password

No worries, we'll send you reset instructions

Back to login
{/* Bottom */}
); }