Profile Admin
This commit is contained in:
@@ -48,7 +48,7 @@ export default function LoginForm() {
|
||||
resolver: yupResolver(LoginSchema),
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
|
||||
const {
|
||||
reset,
|
||||
setError,
|
||||
@@ -58,8 +58,8 @@ export default function LoginForm() {
|
||||
|
||||
const onSubmit = async (data: FormValuesProps) => {
|
||||
try {
|
||||
const loginResult = await login(data.email, data.password );
|
||||
|
||||
const loginResult = await login(data.email, data.password);
|
||||
|
||||
navigate('/dashboard');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -75,7 +75,7 @@ export default function LoginForm() {
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
<Alert severity='info'>Email : admin@linksehat.dev & Password : password</Alert>
|
||||
<Alert severity="info">Email : admin@linksehat.dev & Password : password</Alert>
|
||||
{!!errors.afterSubmit && <Alert severity="error">{errors.afterSubmit.message}</Alert>}
|
||||
|
||||
<RHFTextField name="email" label="Email address" />
|
||||
|
||||
@@ -3,17 +3,19 @@ import * as Yup from 'yup';
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
import { useForm } from 'react-hook-form';
|
||||
// @mui
|
||||
import { Stack } from '@mui/material';
|
||||
import { Alert, Stack } from '@mui/material';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
// hooks
|
||||
import useIsMountedRef from '../../../hooks/useIsMountedRef';
|
||||
// components
|
||||
import { FormProvider, RHFTextField } from '../../../components/hook-form';
|
||||
import axios from '../../../utils/axios';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type FormValuesProps = {
|
||||
email: string;
|
||||
afterSubmit?: string;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -35,24 +37,33 @@ export default function ResetPasswordForm({ onSent, onGetEmail }: Props) {
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
setError,
|
||||
formState: { errors, isSubmitting },
|
||||
} = methods;
|
||||
|
||||
const onSubmit = async (data: FormValuesProps) => {
|
||||
try {
|
||||
await axios.post('/verify-email', data);
|
||||
console.log(data);
|
||||
|
||||
// await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
if (isMountedRef.current) {
|
||||
onSent();
|
||||
onGetEmail(data.email);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
console.log(error.response.data);
|
||||
if (isMountedRef.current) {
|
||||
setError('afterSubmit', { ...error, message: error.response.data.message });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
{!!errors.afterSubmit && <Alert severity="error">{errors.afterSubmit.message}</Alert>}
|
||||
<RHFTextField name="email" label="Email address" />
|
||||
|
||||
<LoadingButton
|
||||
|
||||
Reference in New Issue
Block a user