Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d13889c
init: create app
Deolys Aug 10, 2024
44d09c0
refactor: add eslint
Deolys Aug 10, 2024
2156045
refactor: add prettier
Deolys Aug 10, 2024
e68cb0e
refactor: add husky
Deolys Aug 10, 2024
ef7c273
refactor: add format:fix command
Deolys Aug 10, 2024
361115a
refactor: change eslint config
Deolys Aug 11, 2024
e753dd6
refactor: change lint staged
Deolys Aug 11, 2024
ef643ee
feat: add routing
Deolys Aug 12, 2024
9c143a8
feat: add route for controlled form
Deolys Aug 12, 2024
c208ec9
feat: add uncontrolled form with validation
Deolys Aug 12, 2024
f93bba1
feat: show errors and password strength
Deolys Aug 13, 2024
b4c66f6
fix: remove unnesessary useRef
Deolys Aug 13, 2024
e77bf05
fix: change validation errors
Deolys Aug 14, 2024
7e5ea8b
fix: return old errors validation
Deolys Aug 14, 2024
7cd48dd
feat: add convert image to base64 feature
Deolys Aug 14, 2024
138d88d
feat: add forms slice and routes constants
Deolys Aug 14, 2024
7f8c946
feat: show list of forms at main page
Deolys Aug 14, 2024
4ae8e77
refactor: remove unnecessary code
Deolys Aug 14, 2024
3dd474c
feat: add react hook form and update yup validation
Deolys Aug 15, 2024
1894f82
feat: add custom hooks for forms
Deolys Aug 15, 2024
33fd7b8
refactor: improve the layout
Deolys Aug 15, 2024
00daa00
fix: block invalid chars at number input
Deolys Aug 15, 2024
d5dd71f
refactor: add main page background
Deolys Aug 15, 2024
c7c8dd2
refactor: remove button disabling
Deolys Aug 15, 2024
f7ded95
feat: add some countries
Deolys Aug 16, 2024
897fb05
docks: update README.md
Deolys Sep 19, 2024
9597e94
chore: update dependencies
Deolys Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"arrowParens": "always",
"semi": true,
"bracketSpacing": true
}
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# React forms
## React forms

This project demonstrates a React application with two forms for user data collection, featuring comprehensive validation, data management using Redux, and image handling.

Features:

Multiple Routes:
* Main route displays collected data.
* Two separate routes for form submissions.

Data Collection and Management:
* Redux is used to store and manage form data from both forms.
* After form submission, the user is redirected to the main route.

Form Validation:
* Yup library is used for validation in both forms.
* Error messages are displayed to guide users.
* Submit button is disabled until all required fields are filled and validation criteria are met.

Form Fields:
* Both forms include fields for:
* Name
* Age
* Email
* Gender selection
* Terms and conditions acceptance checkbox
* Input for image upload.

Image Handling:
* Image is saved as base64 encoded data.
* The uploaded image is displayed on the main route after redirection.

Password Handling:
* Both forms include password fields with password strength indication.

Autocomplete Feature:
* Autocomplete functionality is implemented in both forms to enhance user experience.

Technical Details:

1. Framework: React
2. State Management: Redux
3. Validation Library: Yup
4. Image Handling: Base64 encoding

This project showcases a robust approach to form validation in a React application.


## Getting Started
1. Clone the repository
```bash
https://github.com/Deolys/react-forms.git
```
2. Install dependencies:

```bash
npm install
```

3. Run the development server:

```bash
npm run dev
```
56 changes: 56 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import react from 'eslint-plugin-react';
import reactCompiler from 'eslint-plugin-react-compiler';
import eslintPluginPrettier from 'eslint-plugin-prettier';
import eslintConfigPrettier from 'eslint-config-prettier';

export default tseslint.config({
extends: [js.configs.recommended, ...tseslint.configs.recommended, eslintConfigPrettier],
files: ['**/*.{ts,tsx}'],
ignores: ['dist'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
react,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'react-compiler': reactCompiler,
...eslintConfigPrettier.plugins,
prettier: eslintPluginPrettier,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
'react-compiler/react-compiler': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }],
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off',
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
},
],
...eslintConfigPrettier.rules,
},
settings: {
react: {
version: 'detect',
},
},
});
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React forms</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading