"use client"; import { Dialog, DialogTrigger } from "@radix-ui/react-dialog"; import { Button } from "@/components/ui/button"; import { DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import * as z from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; import { Icons } from "@/components/icons"; import { useState } from "react"; export default function ChangePassword() { return (

Password

You can change your password here.

); } function ChangePasswordDialog() { return ( Change password Your password must be at least a minimum of 8 characters. ); } const changePasswordSchema = z.object({ current: z.string({ required_error: "your current password is required" }).min(1), password: z.string({ required_error: "New password is required" }).min(8), confirm_password: z.string({ required_error: "Password confirmation is required" }).min(8), }).refine(data => data.password === data.confirm_password, { message: "Your new password and confirmation does not match.", path: ["confirm_password"], }); type ChangePasswordFormValues = z.infer function ChangePasswordForm() { const [isLoading, setIsLoading] = useState(false); const form = useForm({ resolver: zodResolver(changePasswordSchema), defaultValues: { current: "", password: "", confirm_password: "", }, }); function onSubmit(data: ChangePasswordFormValues) { setIsLoading(true); console.log(data); } return (
( Current password )} /> ( New password )} /> ( Repeat new password )} />
); }