Update README and LoginForm

This commit is contained in:
2023-12-04 09:00:00 +07:00
parent 15190e8330
commit 5d8453e05c
4 changed files with 48 additions and 34 deletions
+32 -28
View File
@@ -5,29 +5,30 @@
## Overview ## Overview
- Introduce: Build a hotel management web application using HTML5, CSS3, Typescript, json-server, React and compile by Vite. - Introduce: Build a hotel management web application using HTML5, CSS3, Typescript, json-server, React and compile by Vite.
- Plan: [Link](https://docs.google.com/document/d/1t2kx17iGCceEe3EbaKO6-3g70ejOJ1PAu9u3KXSKWi4/edit?usp=sharing) - Plan: [Link](https://docs.google.com/document/d/1fE_dv1M9Sbcc1KGCmMAC86-T1rYPW6rvhluNhi8nAWU/edit)
- Deploy: [Link](https://hotel-management.loiphan.com/) - Deploy: [Link](https://hotel-management.loiphan.com/)
## Requirements ## Requirements
- Use develop tools below: - Adding more features for practice 2:
- [Pnpm](https://pnpm.io/) - Converting json-server to Supabase
- [Commitlint](https://github.com/conventional-changelog/commitlint) - Add pagination method
- [Eslint](https://eslint.org/) - Add booking pages
- [Prettier](https://prettier.io/) - Create booking function
- [Husky](https://github.com/typicode/husky) - Add login, logout method
- [Why-did-you-render](https://github.com/welldone-software/why-did-you-render) - Update information user login
- Use latest react app version - Apply useReducer for state management
- Apply [Styled component](https://styled-components.com/). - Apply [TanStack Query](https://tanstack.com/query/latest/) for fetching data
- Compile by [Vite](https://vitejs.dev/) - Write unit tests for the project.
- Deploy to Vercel is mandatory as a final result - Apply [React Hook Form](https://react-hook-form.com/).
## Target ## Target
- Known how to build a web application with React - Known how to state management with useReducer and useContext.
- Understanding and how to use React hooks. - Understand and know how to use [TanStack Query](https://tanstack.com/query/latest/)
- Understanding in depth about useCallback and useMemo. - Unit test coverage greater than 80%
- [PageSpeed](https://pagespeed.web.dev/) scores at minimum 98 points - Know how to use [React Hook Form](https://react-hook-form.com/).
- [PageSpeed](https://pagespeed.web.dev/) scores at minimum of 98 points
## Technical ## Technical
@@ -36,22 +37,23 @@
- [Typescript](https://www.typescriptlang.org/): TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. - [Typescript](https://www.typescriptlang.org/): TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
- [React](https://react.dev/): React is a framework that employs Webpack to automatically compile React, JSX, and ES6 code while handling CSS file prefixes. React is a JavaScript-based UI development library. Although React is a library rather than a language, it is widely used in web development. - [React](https://react.dev/): React is a framework that employs Webpack to automatically compile React, JSX, and ES6 code while handling CSS file prefixes. React is a JavaScript-based UI development library. Although React is a library rather than a language, it is widely used in web development.
- [Vite](https://vitejs.dev/): Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects. - [Vite](https://vitejs.dev/): Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects.
- [json-server](https://github.com/typicode/json-server): Get a full fake REST API with zero coding. - [TanStack Query](https://tanstack.com/query/latest/): Powerful asynchronous state management for TS/JS, React, Solid, Vue and Svelte
- [Supabase](https://supabase.com/): Supabase is an incredible tool for building secure and high-performance Postgres backends with minimal configuration. It provides developers with a wide array of functionalities similar to Firebase, such as authentication, real-time database, and storage.
## Information ## Information
- Timeline: - Timeline:
- Estimate: 11 days - Estimate: 7 days
- Actual: 13 days. - Actual: 10 days.
- Calendar: - Calendar:
- Start: 2023/10/16 - Start: 2023/11/17
- End: 2023/10/30 - End: 2023/11/30
## Development Environment ## Development Environment
- Node: v18.17.1 - Node: v18.18.2
- Npm: v10.1.0 - Npm: v9.8.1
- Pnpm: 8.8.0 - Pnpm: 8.9.2
## Getting started ## Getting started
@@ -60,15 +62,17 @@
- `$ git clone https://github.com/Nez27/react-training.git`. - `$ git clone https://github.com/Nez27/react-training.git`.
- Step 2: Move to folder which just cloned in your computer. - Step 2: Move to folder which just cloned in your computer.
- `cd ./react-training`. - `cd ./react-training`.
- Step 3: Move it to branch react-practice. - Step 3: Move it to branch react-practice-02.
- `$ git checkout react-practice`. - `$ git checkout react-practice-02`.
- Step 4: Move to folder hotel-management. - Step 4: Move to folder hotel-management.
- `$ cd ./hotel-management`. - `$ cd ./hotel-management`.
- Step 5: - Step 5:
- Open terminal > `pnpm i`. - Download this [_file_](https://nezumi27-my.sharepoint.com/:u:/g/personal/admin_nezumi_site/EWmB4skriS9JjPQlemYuFfsB3JZ2-47OuAVDbrzSntUEFg?e=KAFbbh) and put into folder hotel-management (Password: _nezumi_)
- Step 6: - Step 6:
- Run `pnpm run dev`. - Open terminal > `pnpm i`.
- Step 7: - Step 7:
- Run `pnpm run dev`.
- Step 8:
- Open http://localhost:5173/ in browser. - Open http://localhost:5173/ in browser.
## Author ## Author
+2 -1
View File
@@ -56,7 +56,8 @@ const REGEX = {
PHONE: /(0[3|5|7|8|9])+([0-9]{8})\b/g, PHONE: /(0[3|5|7|8|9])+([0-9]{8})\b/g,
NAME: /^[a-zA-Z]{2,}(?: [a-zA-Z]+){0,2}$/gm, NAME: /^[a-zA-Z]{2,}(?: [a-zA-Z]+){0,2}$/gm,
NUMBER: /^[0-9]*$/, NUMBER: /^[0-9]*$/,
PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,16}$/ PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,16}$/,
EMAIL: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,
}; };
export { export {
@@ -7,6 +7,7 @@ const PASSWORD_CONDITION =
const INVALID_PASSWORD = 'Invalid password'; const INVALID_PASSWORD = 'Invalid password';
const PASSWORD_NOT_MATCH = 'Password not match!'; const PASSWORD_NOT_MATCH = 'Password not match!';
const PASSWORD_NOT_MATCH_REQUIREMENT = 'Password not match the requirement!'; const PASSWORD_NOT_MATCH_REQUIREMENT = 'Password not match the requirement!';
const INVALID_EMAIL = 'Invalid email address';
export { export {
REQUIRED_FIELD_ERROR, REQUIRED_FIELD_ERROR,
@@ -17,4 +18,5 @@ export {
INVALID_PASSWORD, INVALID_PASSWORD,
PASSWORD_NOT_MATCH, PASSWORD_NOT_MATCH,
PASSWORD_NOT_MATCH_REQUIREMENT, PASSWORD_NOT_MATCH_REQUIREMENT,
INVALID_EMAIL,
}; };
+12 -5
View File
@@ -8,7 +8,10 @@ import { FieldInput, StyledLoginForm } from './styled';
import Button from '@commonStyle/Button'; import Button from '@commonStyle/Button';
// Constants // Constants
import { REQUIRED_FIELD_ERROR } from '@constant/formValidateMessage'; import {
INVALID_EMAIL,
REQUIRED_FIELD_ERROR,
} from '@constant/formValidateMessage';
// Types // Types
import { ILogin } from '@type/common'; import { ILogin } from '@type/common';
@@ -16,6 +19,12 @@ import { ILogin } from '@type/common';
// Hooks // Hooks
import { useLogin } from '@hook/authentication/useLogin'; import { useLogin } from '@hook/authentication/useLogin';
// Helpers
import { isValidRegex } from '@helper/validators';
// Constants
import { REGEX } from '@constant/commons';
const LoginForm = () => { const LoginForm = () => {
const { const {
register, register,
@@ -41,10 +50,8 @@ const LoginForm = () => {
id="email" id="email"
{...register('email', { {...register('email', {
required: REQUIRED_FIELD_ERROR, required: REQUIRED_FIELD_ERROR,
pattern: { validate: (value) =>
value: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, isValidRegex(REGEX.EMAIL, value) || INVALID_EMAIL,
message: 'Invalid email address',
},
})} })}
/> />
</Form.Row> </Form.Row>