From 4b24661e720e75efe34761e7bc4475214394665c Mon Sep 17 00:00:00 2001 From: Jigme Lodey Date: Tue, 23 Jan 2024 12:57:03 +0600 Subject: [PATCH 01/13] project set up ` --- package.json | 7 - src/app/(auth)/component/auth-container.tsx | 21 - src/app/(auth)/component/form.component.tsx | 145 -- src/app/(auth)/component/style/auth-style.ts | 23 - src/app/(auth)/constant/auth.constant.ts | 76 - src/app/(auth)/login/page.tsx | 47 - src/app/(auth)/model/auth.model.ts | 17 - src/app/(auth)/register/page.tsx | 45 - src/app/(auth)/register/verification.tsx | 50 - .../(auth)/services/schema/schema.service.ts | 30 - src/app/(authenticated)/profile/page.tsx | 5 - src/app/layout.tsx | 5 +- src/app/page.tsx | 91 +- src/middleware.ts | 10 +- src/providers/providers.tsx | 18 - styles/theme.ts | 85 - yarn.lock | 1853 +---------------- 17 files changed, 21 insertions(+), 2507 deletions(-) delete mode 100644 src/app/(auth)/component/auth-container.tsx delete mode 100644 src/app/(auth)/component/form.component.tsx delete mode 100644 src/app/(auth)/component/style/auth-style.ts delete mode 100644 src/app/(auth)/constant/auth.constant.ts delete mode 100644 src/app/(auth)/login/page.tsx delete mode 100644 src/app/(auth)/model/auth.model.ts delete mode 100644 src/app/(auth)/register/page.tsx delete mode 100644 src/app/(auth)/register/verification.tsx delete mode 100644 src/app/(auth)/services/schema/schema.service.ts delete mode 100644 src/app/(authenticated)/profile/page.tsx delete mode 100644 src/providers/providers.tsx delete mode 100644 styles/theme.ts diff --git a/package.json b/package.json index 0f55ae5..36e8c8b 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,6 @@ "prepare": "husky install" }, "dependencies": { - "@emotion/react": "^11.11.1", - "@emotion/styled": "^11.11.0", - "@mui/icons-material": "^5.14.0", - "@mui/material": "^5.14.0", - "@mui/styled-engine-sc": "^5.12.0", - "@mui/x-date-pickers": "^6.10.0", "@reduxjs/toolkit": "^1.9.5", "@types/node": "20.4.2", "@types/react": "18.2.15", @@ -28,7 +22,6 @@ "react-dom": "18.2.0", "react-redux": "^8.1.1", "react-verification-input": "^3.3.1", - "styled-components": "^6.0.4", "typescript": "5.1.6", "yup": "^1.2.0" }, diff --git a/src/app/(auth)/component/auth-container.tsx b/src/app/(auth)/component/auth-container.tsx deleted file mode 100644 index 09b192d..0000000 --- a/src/app/(auth)/component/auth-container.tsx +++ /dev/null @@ -1,21 +0,0 @@ -'use client'; -import { Grid } from '@mui/material'; -import { ReactNode } from 'react'; -import { FormContainer, Background } from '@/app/(auth)/component/style/auth-style'; -import { theme } from '../../../../styles/theme'; - -export default function AuthContainer (props: ReactNode) { - return( - - - - - {props.children} - - - ); -} diff --git a/src/app/(auth)/component/form.component.tsx b/src/app/(auth)/component/form.component.tsx deleted file mode 100644 index 7e3ec87..0000000 --- a/src/app/(auth)/component/form.component.tsx +++ /dev/null @@ -1,145 +0,0 @@ -'use client'; -import { Formik, FormikValues } from 'formik'; -import { Box, Grid, InputAdornment } from '@mui/material'; -import Input from '@/shared/component/input/input.component'; -import Button from '@/shared/component/button/button.component'; -import Typography from '@/shared/component/typography/typography'; -import Checkbox from '@/shared/component/checkbox/checkbox.component'; -import { LOGIN_SCHEMA, REGISTRATION_SCHEMA } from '@/app/(auth)/services/schema/schema.service'; -import { useEffect, useState } from 'react'; -import Icon from '@/shared/component/icon/icon'; -import { - GENDER, - LOGIN_FORM, - LOGIN_INITIAL_VALUE, - REGISTER_FORM, - REGISTRATION_INITIAL_VALUE -} from '@/app/(auth)/constant/auth.constant'; -import Dropdown from '@/shared/component/dropdown/dropdown'; -import { useRouter } from 'next/navigation'; -import { setCookie } from 'cookies-next'; -import { useLoginUserMutation, useRegistrationMutation } from '@/app/services/api/auth.api'; - -function AuthForm (props: { type?: string, setEmail?: any }) { - const router = useRouter(); - const [email, setEmail] = useState(''); - const [ passwordView, setPasswordView ] = useState<{ password: boolean, confirmPassword: boolean }>( { - password: true, - confirmPassword: true - } ); - const [ login, { data:loginData, error } ] = useLoginUserMutation(); - const [ register, { data: registration } ] = useRegistrationMutation(); - - useEffect(() => { - if ( loginData ) { - setCookie('authenticated', loginData); - loginData && router.push('/'); - } - - if ( registration ) { - props?.setEmail(email); - } - if (error?.data?.error === 'You have to confirm your email address before continuing.' ) - { - props.setEmail(email); - } - }, [loginData, registration, error]); - - const showPassword = (name: string) => { - name === 'password' ? setPasswordView( { - password: !passwordView.password, - confirmPassword: passwordView.confirmPassword - }) : setPasswordView( { - password: passwordView.password, - confirmPassword: !passwordView.confirmPassword - }); - }; - const submitData = (value: FormikValues) => { - const data = { user: { - email: value.email, - password: value.password, - username: value.userName, - name: value.name, - gender: value?.gender?.toLowerCase, - password_confirmation: value.confirmPassword - } - }; - setEmail(value.email); - props?.type === 'login' ? login(data) : register(data); - }; - return ( - { - submitData(values); - } } - initialValues={ props?.type === 'login' ? LOGIN_INITIAL_VALUE : REGISTRATION_INITIAL_VALUE } - validationSchema={ props?.type === 'login'? LOGIN_SCHEMA : REGISTRATION_SCHEMA } - > - {({ handleChange, handleBlur, values, touched, errors, handleSubmit }) => ( - - { - ( props?.type === 'login' ? LOGIN_FORM : REGISTER_FORM ).map( ( - { label, name, type } ) => ( - - { - type !== 'dropdown' ? - - showPassword(name)} - > - { - name === 'password' ? - : - - } - - ), - } } - />: - } - - ) ) - } - - - - - - - - - - - - - - -