Update validation, dll Hospital-Portal
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as Yup from 'yup';
|
||||
import { useState } from 'react';
|
||||
import React, { useContext, useRef, useState, useEffect } from 'react';
|
||||
import { Link as RouterLink, useNavigate } from 'react-router-dom';
|
||||
// form
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -15,6 +15,7 @@ import useIsMountedRef from '@/hooks/useIsMountedRef';
|
||||
// components
|
||||
import Iconify from '@/components/Iconify';
|
||||
import { FormProvider, RHFTextField, RHFCheckbox } from '@/components/hook-form';
|
||||
import { LanguageContext } from '@/contexts/LanguageContext';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -26,6 +27,7 @@ type FormValuesProps = {
|
||||
};
|
||||
|
||||
export default function LoginForm() {
|
||||
const { localeData } = useContext(LanguageContext);
|
||||
const { login } = useAuth();
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -34,8 +36,8 @@ export default function LoginForm() {
|
||||
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'),
|
||||
email: Yup.string().email('Format email tidak valid').required('Email harus diisi'),
|
||||
password: Yup.string().required('Password harus diisi'),
|
||||
});
|
||||
|
||||
const defaultValues = {
|
||||
@@ -75,10 +77,10 @@ export default function LoginForm() {
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
<Alert severity="info">Email : admin@linksehat.dev & Password : password</Alert>
|
||||
{!!errors.afterSubmit && <Alert severity="error">{errors.afterSubmit.message}</Alert>}
|
||||
<Alert severity="info">{localeData.infoLogin}</Alert>
|
||||
{!!errors.afterSubmit && <Alert severity="error">{errors.afterSubmit.data.meta.message}</Alert>}
|
||||
|
||||
<RHFTextField name="email" label="Email address" />
|
||||
<RHFTextField name="email" label="Email" required/>
|
||||
|
||||
<RHFTextField
|
||||
name="password"
|
||||
@@ -93,14 +95,15 @@ export default function LoginForm() {
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
required
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between" sx={{ my: 2 }}>
|
||||
<RHFCheckbox name="remember" label="Remember me" />
|
||||
{/*<RHFCheckbox name="remember" label="Remember me" />
|
||||
<Link component={RouterLink} variant="subtitle2" to={PATH_AUTH.resetPassword}>
|
||||
Forgot password?
|
||||
</Link>
|
||||
</Link>*/}
|
||||
</Stack>
|
||||
|
||||
<LoadingButton
|
||||
@@ -109,6 +112,7 @@ export default function LoginForm() {
|
||||
type="submit"
|
||||
variant="contained"
|
||||
loading={isSubmitting}
|
||||
sx={{ marginTop: 2 }}
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
|
||||
Reference in New Issue
Block a user