import { Stack } from "@mui/material"; import { ConfigBox } from "@/Components/design-elements"; import { TextField, Button } from "@/Components/inputs"; import { useTranslation } from "react-i18next"; import { useTheme } from "@mui/material"; import { useForm, Controller } from "react-hook-form"; import { usePasswordForm } from "@/Hooks/usePasswordForm"; import { usePatch } from "@/Hooks/UseApi"; import type { PasswordFormData } from "@/Validation/password"; export const TabPassword = () => { const { t } = useTranslation(); const theme = useTheme(); const { resolver, defaults } = usePasswordForm(); const { patch, loading } = usePatch(); const { control, handleSubmit, reset } = useForm({ resolver, defaultValues: defaults, }); const onSubmit = async (data: PasswordFormData) => { const fd = new FormData(); fd.append("password", data.currentPassword); fd.append("newPassword", data.newPassword); const result = await patch("/auth/user", fd); if (result?.success) { reset(); } }; return ( ( )} /> } /> ( )} /> ( )} /> } /> ); };