diff --git a/package.json b/package.json index c2f7320..f474ee4 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,11 @@ "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.15.0" + "react-router-dom": "^6.15.0", + "validator": "^13.11.0" }, "devDependencies": { + "@tailwindcss/forms": "^0.5.4", "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", "@vitejs/plugin-react": "^4.0.3", diff --git a/src/App.css b/src/App.css deleted file mode 100644 index b9d355d..0000000 --- a/src/App.css +++ /dev/null @@ -1,42 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/src/App.jsx b/src/App.jsx index e82825e..5106fe4 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,4 @@ import { RouterProvider, createBrowserRouter } from 'react-router-dom'; -import './App.css' -import { Login } from './pages'; import routes from './routes'; const router = createBrowserRouter(routes) diff --git a/src/index.css b/src/index.css index 9266e10..750edf7 100644 --- a/src/index.css +++ b/src/index.css @@ -1,73 +1,3 @@ @tailwind base; @tailwind component; -@tailwind utilities; - -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} +@tailwind utilities; \ No newline at end of file diff --git a/src/pages/Login/index.jsx b/src/pages/Login/index.jsx new file mode 100644 index 0000000..fd25441 --- /dev/null +++ b/src/pages/Login/index.jsx @@ -0,0 +1,111 @@ +import { useState } from "react"; +import user from "../../data/users.json"; + +const Login = () => { + const [authForm, setAuthForm] = useState({ + email: '', + password: '' + }); + + const [err, setErr] = useState({ + err: false, + message: '' + }); + + const handleAuthForm = (e) => { + if(err.err) { + setErr({ ...err, err: false}) + } + const name = e.target.name; + const val = name === "email" ? e.target.value.toLowerCase() : e.target.value; + setAuthForm({ ...authForm, [name]: val }); + } + + const handleSubmit = (e) => { + e.preventDefault() + const current_user = user.find(x => x.email == authForm.email); + + if (!current_user) { + setErr({ err: true, message: "User not found with this Email / Password"}) + return; + } + + const isPassword = authForm.password === current_user.password + + if(!isPassword) { + setErr({ err: true, message: "User not found with this Email / Password"}) + return; + } + + console.log(current_user); + } + + return ( + <> +
+
+

+ Sign in +

+
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + { err.err && + + } +
+
+
+
+ + ) +} + +export default Login; \ No newline at end of file diff --git a/src/pages/404/index.jsx b/src/pages/Notfound404/index.jsx similarity index 100% rename from src/pages/404/index.jsx rename to src/pages/Notfound404/index.jsx diff --git a/src/pages/index.js b/src/pages/index.js index 0a41cf9..326cc83 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,5 +1,5 @@ -import Login from './login'; -import Notfound404 from './404'; +import Login from './Login'; +import Notfound404 from './Notfound404'; export { Login, diff --git a/src/pages/login/index.jsx b/src/pages/login/index.jsx deleted file mode 100644 index b7e41ac..0000000 --- a/src/pages/login/index.jsx +++ /dev/null @@ -1,35 +0,0 @@ -import { useState } from 'react'; -import reactLogo from '../../assets/react.svg'; -import viteLogo from '/vite.svg' - -const Login = () => { - const [count, setCount] = useState(0) - - return ( - <> -
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.jsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

-

Hello world!

- - ) -} - -export default Login; \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js index 6f01875..9815354 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -7,6 +7,8 @@ export default { theme: { extend: {}, }, - plugins: [], + plugins: [ + require('@tailwindcss/forms'), + ], } diff --git a/yarn.lock b/yarn.lock index 4d839e7..3e5de13 100644 --- a/yarn.lock +++ b/yarn.lock @@ -437,6 +437,13 @@ resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.8.0.tgz#e848d2f669f601544df15ce2a313955e4bf0bafc" integrity sha512-mrfKqIHnSZRyIzBcanNJmVQELTnX+qagEDlcKO90RgRBVOZGSGvZKeDihTRfWcqoDn5N/NkUcwWTccnpN18Tfg== +"@tailwindcss/forms@^0.5.4": + version "0.5.4" + resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.4.tgz#5316a782fd95369eb5b6fd01d46323b3dce656a2" + integrity sha512-YAm12D3R7/9Mh4jFbYSMnsd6jG++8KxogWgqs7hbdo/86aWjjlIEvL7+QYdVELmAI0InXTpZqFIg5e7aDVWI2Q== + dependencies: + mini-svg-data-uri "^1.2.3" + "@types/prop-types@*": version "15.7.5" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" @@ -1573,6 +1580,11 @@ micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.2" picomatch "^2.3.1" +mini-svg-data-uri@^1.2.3: + version "1.4.4" + resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939" + integrity sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg== + minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -2240,6 +2252,11 @@ util-deprecate@^1.0.2: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +validator@^13.11.0: + version "13.11.0" + resolved "https://registry.yarnpkg.com/validator/-/validator-13.11.0.tgz#23ab3fd59290c61248364eabf4067f04955fbb1b" + integrity sha512-Ii+sehpSfZy+At5nPdnyMhx78fEoPDkR2XW/zimHEL3MyGJQOCQ7WeP20jPYRz7ZCpcKLB21NxuXHF3bxjStBQ== + vite@^4.4.5: version "4.4.9" resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d"