Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
41 changes: 21 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

# 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?
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
# Form Validation Task
# React + TypeScript + Vite

Dear students,
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Please use your ReactJS skills to Build a web application that allows users to submit data through a form. Utilize Formik and Yup for form management and validation, Material UI for the UI components.
Currently, two official plugins are available:

## Task Instructions
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

Please follow the steps below to complete the task:
## Expanding the ESLint configuration

Create a form with the following fields:
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Name (text input)
- Email (text input with email validation)
- Message (textarea)
- Phone number
- Configure the top-level `parserOptions` property like this:

Use Formik to manage the form state and handle form submissions. Implement Yup schema validation to ensure that:
```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

- Name is required and should be at least 3 characters long.
- Email is required and should be a valid email address.
- Message is required and should have 40 min characters and 255 max characters.
- Phone number should be a number that is valid in Iraq.

Use Material UI to style and layout your form components. Ensure the form is visually appealing, user-friendly, and responsive.

Extra Tasks (Optional) - Formik and Yup Challenges:

1. Create a custom Formik field component: Implement a custom Formik field component for a specific input type, such as a date picker or a file uploader. Integrate it into your form and handle the form state accordingly.

2. Conditional form sections: add a checkbox and an input field using mui and then make the input field show or hide based on the checkbox value (use formik to control the checkbox value ).

Feel free to choose one or more of these Formik and Yup challenges to enhance your form-building skills. Please reach out if you have any questions or need further assistance.
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
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" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading