refactor(web): remove typescript

This commit is contained in:
Ali BARIN
2024-02-27 15:23:23 +00:00
parent 636870a075
commit b3ae2d2748
337 changed files with 2067 additions and 4997 deletions

View File

@@ -6,7 +6,6 @@ import Typography from '@mui/material/Typography';
import LoadingButton from '@mui/lab/LoadingButton';
import * as yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import useAuthentication from 'hooks/useAuthentication';
import * as URLS from 'config/urls';
import { REGISTER_USER } from 'graphql/mutations/register-user.ee';
@@ -14,7 +13,6 @@ import Form from 'components/Form';
import TextField from 'components/TextField';
import { LOGIN } from 'graphql/mutations/login';
import useFormatMessage from 'hooks/useFormatMessage';
const validationSchema = yup.object().shape({
fullName: yup.string().trim().required('signupForm.mandatoryInput'),
email: yup
@@ -28,46 +26,39 @@ const validationSchema = yup.object().shape({
.required('signupForm.mandatoryInput')
.oneOf([yup.ref('password')], 'signupForm.passwordsMustMatch'),
});
const initialValues = {
fullName: '',
email: '',
password: '',
confirmPassword: '',
};
function SignUpForm() {
const navigate = useNavigate();
const authentication = useAuthentication();
const formatMessage = useFormatMessage();
const [registerUser, { loading: registerUserLoading }] = useMutation(REGISTER_USER);
const [registerUser, { loading: registerUserLoading }] =
useMutation(REGISTER_USER);
const [login, { loading: loginLoading }] = useMutation(LOGIN);
React.useEffect(() => {
if (authentication.isAuthenticated) {
navigate(URLS.DASHBOARD);
}
}, [authentication.isAuthenticated]);
const handleSubmit = async (values: any) => {
const handleSubmit = async (values) => {
const { fullName, email, password } = values;
await registerUser({
variables: {
input: { fullName, email, password },
},
});
const { data } = await login({
variables: {
input: { email, password },
},
});
const { token } = data.login;
authentication.updateToken(token);
};
return (
<Paper sx={{ px: 2, py: 4 }}>
<Typography
@@ -101,7 +92,7 @@ function SignUpForm() {
error={touchedFields.fullName && !!errors?.fullName}
helperText={
touchedFields.fullName && errors?.fullName?.message
? formatMessage(errors?.fullName?.message as string, {
? formatMessage(errors?.fullName?.message, {
inputName: formatMessage('signupForm.fullNameFieldLabel'),
})
: ''
@@ -118,7 +109,7 @@ function SignUpForm() {
error={touchedFields.email && !!errors?.email}
helperText={
touchedFields.email && errors?.email?.message
? formatMessage(errors?.email?.message as string, {
? formatMessage(errors?.email?.message, {
inputName: formatMessage('signupForm.emailFieldLabel'),
})
: ''
@@ -134,7 +125,7 @@ function SignUpForm() {
error={touchedFields.password && !!errors?.password}
helperText={
touchedFields.password && errors?.password?.message
? formatMessage(errors?.password?.message as string, {
? formatMessage(errors?.password?.message, {
inputName: formatMessage('signupForm.passwordFieldLabel'),
})
: ''
@@ -151,9 +142,9 @@ function SignUpForm() {
helperText={
touchedFields.confirmPassword &&
errors?.confirmPassword?.message
? formatMessage(errors?.confirmPassword?.message as string, {
? formatMessage(errors?.confirmPassword?.message, {
inputName: formatMessage(
'signupForm.confirmPasswordFieldLabel'
'signupForm.confirmPasswordFieldLabel',
),
})
: ''
@@ -177,5 +168,4 @@ function SignUpForm() {
</Paper>
);
}
export default SignUpForm;