client portal dashboard & claim-reports
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
import * as Yup from 'yup';
|
||||
import { useState } from 'react';
|
||||
import { Link as RouterLink, useNavigate } from 'react-router-dom';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
// form
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { yupResolver } from '@hookform/resolvers/yup';
|
||||
// @mui
|
||||
import { Link, Stack, Alert, IconButton, InputAdornment } from '@mui/material';
|
||||
import { Stack, Alert } from '@mui/material';
|
||||
import { LoadingButton } from '@mui/lab';
|
||||
// routes
|
||||
import { PATH_AUTH } from '../../../routes/paths';
|
||||
// hooks
|
||||
import useAuth from '../../../hooks/useAuth';
|
||||
import useIsMountedRef from '../../../hooks/useIsMountedRef';
|
||||
// components
|
||||
import Iconify from '../../../components/Iconify';
|
||||
import { FormProvider, RHFTextField, RHFCheckbox } from '../../../components/hook-form';
|
||||
import { FormProvider, RHFTextField } from '../../../components/hook-form';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
type FormValuesProps = {
|
||||
email: string;
|
||||
password: string;
|
||||
remember: boolean;
|
||||
afterSubmit?: string;
|
||||
};
|
||||
|
||||
export default function LoginForm() {
|
||||
@@ -31,24 +24,15 @@ export default function LoginForm() {
|
||||
|
||||
const isMountedRef = useIsMountedRef();
|
||||
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
|
||||
const LoginSchema = Yup.object().shape({
|
||||
email: Yup.string().email('Email must be a valid email address').required('Email is required'),
|
||||
password: Yup.string().required('Password is required'),
|
||||
});
|
||||
|
||||
const defaultValues = {
|
||||
email: 'admin@linksehat.dev',
|
||||
password: 'password',
|
||||
remember: true,
|
||||
};
|
||||
|
||||
const methods = useForm<FormValuesProps>({
|
||||
resolver: yupResolver(LoginSchema),
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
|
||||
const {
|
||||
reset,
|
||||
setError,
|
||||
@@ -58,8 +42,8 @@ export default function LoginForm() {
|
||||
|
||||
const onSubmit = async (data: FormValuesProps) => {
|
||||
try {
|
||||
const loginResult = await login(data.email, data.password );
|
||||
|
||||
await login(data.email);
|
||||
|
||||
navigate('/dashboard');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -75,32 +59,10 @@ export default function LoginForm() {
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
<Alert severity='primary'>Email : admin@linksehat.dev & Password : password</Alert>
|
||||
<Alert severity="info">Masukkan akun yang telah terdaftar</Alert>
|
||||
{!!errors.afterSubmit && <Alert severity="error">{errors.afterSubmit.message}</Alert>}
|
||||
|
||||
<RHFTextField name="email" label="Email address" />
|
||||
|
||||
<RHFTextField
|
||||
name="password"
|
||||
label="Password"
|
||||
type={showPassword ? 'text' : 'password'}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">
|
||||
<IconButton onClick={() => setShowPassword(!showPassword)} edge="end">
|
||||
<Iconify icon={showPassword ? 'eva:eye-fill' : 'eva:eye-off-fill'} />
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ my: 2 }}>
|
||||
<RHFCheckbox name="remember" label="Remember me" />
|
||||
<Link component={RouterLink} variant="subtitle2" to={PATH_AUTH.resetPassword}>
|
||||
Forgot password?
|
||||
</Link>
|
||||
</Stack>
|
||||
|
||||
<LoadingButton
|
||||
|
||||
Reference in New Issue
Block a user