diff --git a/package-lock.json b/package-lock.json index 5ba1904..dd44a1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,11 +11,14 @@ "@fortawesome/fontawesome-svg-core": "^6.5.1", "@fortawesome/free-solid-svg-icons": "^6.5.1", "@fortawesome/react-fontawesome": "^0.2.0", + "@reduxjs/toolkit": "^2.0.1", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "axios": "^1.6.5", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-redux": "^9.1.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "react-slick": "^0.29.0", @@ -3405,6 +3408,38 @@ } } }, + "node_modules/@reduxjs/toolkit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.0.1.tgz", + "integrity": "sha512-fxIjrR9934cmS8YXIGd9e7s1XRsEU++aFc9DVNMFMRTM5Vtsg2DCRMj21eslGtDt43IUf9bJL3h5bwUlZleibA==", + "dependencies": { + "immer": "^10.0.3", + "redux": "^5.0.0", + "redux-thunk": "^3.1.0", + "reselect": "^5.0.1" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, + "node_modules/@reduxjs/toolkit/node_modules/immer": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.0.3.tgz", + "integrity": "sha512-pwupu3eWfouuaowscykeckFmVTpqbzW+rXFCX8rQLkZzM9ftBmU/++Ra+o+L27mz03zJTlyV4UUr+fdKNffo4A==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, "node_modules/@remix-run/router": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.1.tgz", @@ -3731,104 +3766,6 @@ "url": "https://github.com/sponsors/gregberge" } }, - "node_modules/@testing-library/dom": { - "version": "9.3.4", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.4.tgz", - "integrity": "sha512-FlS4ZWlp97iiNWig0Muq8p+3rVDjRiYE+YKGbAqXOu9nwJFFOdL00kFpz42M+4huzYi86vAK1sOOfyOG45muIQ==", - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.1.3", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@testing-library/dom/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "peer": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", - "peer": true, - "dependencies": { - "deep-equal": "^2.0.5" - } - }, - "node_modules/@testing-library/dom/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "peer": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/@testing-library/dom/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "peer": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/@testing-library/dom/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "peer": true - }, - "node_modules/@testing-library/dom/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/@testing-library/dom/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "peer": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/@testing-library/jest-dom": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz", @@ -4608,6 +4545,11 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "node_modules/@types/ws": { "version": "8.5.10", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", @@ -5474,6 +5416,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", + "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "dependencies": { + "follow-redirects": "^1.15.4", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -12057,12 +12022,6 @@ "jiti": "bin/jiti.js" } }, - "node_modules/jquery": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", - "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", - "peer": true - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -14697,6 +14656,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -14985,6 +14949,32 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" }, + "node_modules/react-redux": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.0.tgz", + "integrity": "sha512-6qoDzIO+gbrza8h3hjMA9aq4nwVFCKFtY2iLxCtVT38Swyy2C/dJCGBXHeHLtx6qlg/8qzc2MrhOeduf5K32wQ==", + "dependencies": { + "@types/use-sync-external-store": "^0.0.3", + "use-sync-external-store": "^1.0.0" + }, + "peerDependencies": { + "@types/react": "^18.2.25", + "react": "^18.0", + "react-native": ">=0.69", + "redux": "^5.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react-native": { + "optional": true + }, + "redux": { + "optional": true + } + } + }, "node_modules/react-refresh": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", @@ -15166,6 +15156,19 @@ "node": ">=8" } }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, + "node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "peerDependencies": { + "redux": "^5.0.0" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz", @@ -15311,6 +15314,11 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, + "node_modules/reselect": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.0.tgz", + "integrity": "sha512-aw7jcGLDpSgNDyWBQLv2cedml85qd95/iszJjN988zX1t7AVRJi19d9kto5+W7oCfQ94gyo40dVbT6g2k4/kXg==" + }, "node_modules/resize-observer-polyfill": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", @@ -17116,19 +17124,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -17276,6 +17271,14 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", + "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 1ea9b78..ea3a594 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,14 @@ "@fortawesome/fontawesome-svg-core": "^6.5.1", "@fortawesome/free-solid-svg-icons": "^6.5.1", "@fortawesome/react-fontawesome": "^0.2.0", + "@reduxjs/toolkit": "^2.0.1", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "axios": "^1.6.5", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-redux": "^9.1.0", "react-router-dom": "^6.21.1", "react-scripts": "5.0.1", "react-slick": "^0.29.0", diff --git a/src/App.js b/src/App.js index c87993e..3557ef5 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { Routes, Route } from 'react-router-dom'; import './App.css'; import Header from './component/header/Header'; @@ -10,14 +10,20 @@ import Login from './pages/login/Login'; import Signup from './pages/signup/Signup'; import Cards from './pages/cards/Cards'; import Offer from './pages/offer/Offer'; - import Chat from './pages/chat/Chat'; - import Payment from './pages/payment/Payment'; import Profile from './pages/profile/Profile'; - +import { useDispatch } from 'react-redux'; +import { checkLogIn } from './slices/authSlice'; +import Confirm from './pages/signup/confirm/Confirm'; function App() { + const dispatch = useDispatch(); + + useEffect(() => { + dispatch(checkLogIn()); + }, [dispatch]); + return (
@@ -27,14 +33,13 @@ function App() { } /> } /> } /> + } /> } /> } /> } /> } /> } /> - -
); diff --git a/src/api.js b/src/api.js deleted file mode 100644 index c16c544..0000000 --- a/src/api.js +++ /dev/null @@ -1 +0,0 @@ -const MAIN = 'http://cyberswap.uz/'; diff --git a/src/api/axios.js b/src/api/axios.js new file mode 100644 index 0000000..59fc406 --- /dev/null +++ b/src/api/axios.js @@ -0,0 +1,9 @@ +import axios from 'axios'; + +const instance = axios.create({ + baseURL: 'https://api.cyberswap.uz/api', + withCredentials: true, + // Additional configurations like headers can go here +}); + +export default instance; diff --git a/src/component/header/Header.js b/src/component/header/Header.js index 0390ab9..05364c8 100644 --- a/src/component/header/Header.js +++ b/src/component/header/Header.js @@ -1,12 +1,15 @@ import React, { useState } from 'react'; import { NavLink, Link } from 'react-router-dom'; - +import halmet from '../../img/halmet.png'; import './header.css'; - import logo from './logo1_1.png'; +import { useSelector } from 'react-redux'; +import { selectCurrentUser } from '../../slices/authSlice'; const Header = () => { const [navbar, setNavbar] = useState(false); + const user = useSelector(selectCurrentUser); + const navBtn = () => setNavbar(!navbar); return (
@@ -21,25 +24,34 @@ const Header = () => {
- - Kirish - - - + {user ? ( + + + + ) : ( + + Kirish + + + )} diff --git a/src/component/header/header.css b/src/component/header/header.css index e5f2ef8..7653334 100644 --- a/src/component/header/header.css +++ b/src/component/header/header.css @@ -1,166 +1,183 @@ .header { - width: 100%; - height: 60px; - display: flex; - align-items: center; - justify-content: space-between; - position: fixed; - top: 0; - left: 0; - background: var(--bg-color); - z-index: 1000; - box-shadow: 0 0 10px rgb(88, 5, 44); + width: 100%; + height: 60px; + display: flex; + align-items: center; + justify-content: space-between; + position: fixed; + top: 0; + left: 0; + background: var(--bg-color); + z-index: 1000; + box-shadow: 0 0 10px rgb(88, 5, 44); } .header > a { - display: flex; - align-items: center; - gap: 8px; + display: flex; + align-items: center; + gap: 8px; } -.header .logo{ - display: flex; - align-items: center; - justify-content: center; - width: 40px; - height: 40px; +.header .logo { + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 40px; } .header > a span { - font-family: var(--roboto); - font-size: var(--small-fs); - font-weight: var(--fw-800); - letter-spacing: 1.2px; + font-family: var(--roboto); + font-size: var(--small-fs); + font-weight: var(--fw-800); + letter-spacing: 1.2px; } .header nav ul { - display: flex; - gap: 1.4rem; + display: flex; + gap: 1.4rem; } .header nav ul li a { - display: flex; - align-items: center; - gap: 10px; - font-family: var(--lato); - font-size: var(--smallest-fs); - font-weight: var(--fw-400); - letter-spacing: 0.72px; - text-transform: uppercase; - transition: all .3s ease; - position: relative; + display: flex; + align-items: center; + gap: 10px; + font-family: var(--lato); + font-size: var(--smallest-fs); + font-weight: var(--fw-400); + letter-spacing: 0.72px; + text-transform: uppercase; + transition: all 0.3s ease; + position: relative; } .header nav ul li a i { - font-size: var(--smaller-fs); - display: none; + font-size: var(--smaller-fs); + display: none; } .header nav ul li a::after { - content: ''; - width: 0%; - height: 2px; - background: var(--btn-bg-color); - position: absolute; - bottom: -8px; - left: 0; - transition: all .5s ease; + content: ''; + width: 0%; + height: 2px; + background: var(--btn-bg-color); + position: absolute; + bottom: -8px; + left: 0; + transition: all 0.5s ease; } .header nav ul li a:hover::after, .header nav ul li a.active::after { - width: 100%; + width: 100%; } .header-btns { - display: flex; - align-items: center; - gap: 1rem; + display: flex; + align-items: center; + gap: 1rem; } .header .sign-in { - display: flex; - align-items: center; - gap: 5px; + display: flex; + align-items: center; + gap: 5px; } .header .sign-in > span { - font-family: var(--lato); - font-size: var(--smallest-fs); - font-weight: var(--fw-400); - letter-spacing: 0.72px; - text-transform: uppercase; - transform: translateX(-10%); - transition: all .3s ease; + font-family: var(--lato); + font-size: var(--smallest-fs); + font-weight: var(--fw-400); + letter-spacing: 0.72px; + text-transform: uppercase; + transform: translateX(-10%); + transition: all 0.3s ease; } .header .sign-in:hover > span { - transform: translateX(0); + transform: translateX(0); } .header .sign-in i, .header .nav-btn i { - font-size: var(--big-fs); + font-size: var(--big-fs); } .header .nav-btn { - width: 40px; - height: 40px; - display: flex; - align-items: center; - justify-content: center; - display: none; + width: 40px; + height: 40px; + display: flex; + align-items: center; + justify-content: center; + display: none; +} + +.halmet { + width: 15%; + height: 15%; + margin-left: auto; } @media screen and (max-width: 992px) { - .header nav ul { - gap: 1rem; - } + .header nav ul { + gap: 1rem; + } + .halmet { + width: 18%; + height: 18%; + margin-left: auto; + } } -@media screen and (max-width: 768px){ - .header .nav-btn { - display: flex; - } - - .header nav { - width: 70%; - height: 100vh; - position: absolute; - top: 100%; - right: 0; - transform: translateX(105%); - transition: all 0.5s ease; - } - .header nav.mobile { - transform: translateX(0); - } - - .header nav ul { - padding: 40px; - width: 100%; - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - gap: 20px; - border-left: 2px solid rgb(142, 19, 19); - background: var(--bg-color); - } - .header nav ul li { - width: 100%; - padding: 10px; - display: flex; - justify-content: center; - border: 2px solid black; - background: white; - } - .header nav ul li a { - display: flex; - justify-content: center; - width: 100%; - color: #000; - } - .header nav ul li a i { - display: block; - color: #000; - } - .header nav ul li:hover { - background: rgb(88, 5, 44); - } - .header nav ul li:hover a { - color: #fff; - } - .header nav ul li a::after { - display: none; - } -} \ No newline at end of file +@media screen and (max-width: 768px) { + .halmet { + width: 30%; + height: 30%; + margin-left: auto; + } + + .header .nav-btn { + display: flex; + } + + .header nav { + width: 70%; + height: 100vh; + position: absolute; + top: 100%; + right: 0; + transform: translateX(105%); + transition: all 0.5s ease; + } + .header nav.mobile { + transform: translateX(0); + } + + .header nav ul { + padding: 40px; + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; + border-left: 2px solid rgb(142, 19, 19); + background: var(--bg-color); + } + .header nav ul li { + width: 100%; + padding: 10px; + display: flex; + justify-content: center; + border: 2px solid black; + background: white; + } + .header nav ul li a { + display: flex; + justify-content: center; + width: 100%; + color: #000; + } + .header nav ul li a i { + display: block; + color: #000; + } + .header nav ul li:hover { + background: rgb(88, 5, 44); + } + .header nav ul li:hover a { + color: #fff; + } + .header nav ul li a::after { + display: none; + } +} diff --git a/src/img/halmet.png b/src/img/halmet.png new file mode 100644 index 0000000..c31634d Binary files /dev/null and b/src/img/halmet.png differ diff --git a/src/index.js b/src/index.js index 4eabdff..cc71ad7 100644 --- a/src/index.js +++ b/src/index.js @@ -1,14 +1,18 @@ -import React from "react"; -import { BrowserRouter } from "react-router-dom"; -import ReactDOM from "react-dom/client"; -import "./index.css"; -import App from "./App"; +import React from 'react'; +import { BrowserRouter } from 'react-router-dom'; +import ReactDOM from 'react-dom/client'; +import './index.css'; +import App from './App'; +import { Provider } from 'react-redux'; +import { store } from './store'; -const root = ReactDOM.createRoot(document.getElementById("root")); +const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + + + ); diff --git a/src/pages/login/Login.js b/src/pages/login/Login.js index fe7ae37..4da8f57 100644 --- a/src/pages/login/Login.js +++ b/src/pages/login/Login.js @@ -1,61 +1,96 @@ -import React from "react"; -import "./login.css"; -import logo1 from "../../component/header/logo1_1.png"; -import { NavLink, Link } from "react-router-dom"; +import './login.css'; +import logo1 from '../../component/header/logo1_1.png'; +import { NavLink, Link } from 'react-router-dom'; +import React, { useState, useEffect } from 'react'; +import { useDispatch } from 'react-redux'; +import { logIn } from '../../slices/authSlice'; +import axios from 'axios'; const Login = () => { + const [credentials, setCredentials] = useState({ + login: '', + password: '', + }); + + const handleInputChange = (event) => { + const { id, value } = event.target; + setCredentials({ + ...credentials, + [id]: value, + }); + }; + + const dispatch = useDispatch(); + + const handleSubmit = (event) => { + event.preventDefault(); + dispatch(logIn(credentials)); + }; + return ( -
-
-
-
-
+
+
+
+
+


-
+
- logo + logo

Hush kelibsiz

-
-
- - + +
+ +
-
- - +
+ +
-
+
- -
-
+
-
- -
- -
+

- + ASOSIYGA QAYTISH
-
+
-
-
+
+
diff --git a/src/pages/profile/Profile.js b/src/pages/profile/Profile.js index b7bf77f..3cdce22 100644 --- a/src/pages/profile/Profile.js +++ b/src/pages/profile/Profile.js @@ -1,64 +1,76 @@ -import React from "react"; -import "./profile.css"; -import profileImg from "./img/profile-img.png"; - -import ProfileOfferData from "./ProfileOfferData"; +import React from 'react'; +import './profile.css'; +import profileImg from './img/profile-img.png'; +import ProfileOfferData from './ProfileOfferData'; +import { logOutUser } from '../../slices/authSlice'; +import { useDispatch } from 'react-redux'; +import { NavLink } from 'react-router-dom'; const Profile = () => { + const dispatch = useDispatch(); + + const handleLogout = () => { + dispatch(logOutUser()); + }; + return ( -
-
-
+
+
+
+ + + Chiqish + Profilingiz -
- user user +
+ user user
-
-

Oddiy inson

-

+

+

Oddiy inson

+

Lorem ipsum dolor sit amet consectetur adipisicing elit. Eos, velit sit! Eos nemo incidunt sequi velit earum nostrum aliquam iure voluptate. Quod amet repudiandae impedit!

-

Ma'lumotlarni o'zgartirish:

-
- - - - +

Ma'lumotlarni o'zgartirish:

+
+ + + +
-
-
- - +
+
+ +
-
+
{ProfileOfferData.map((offerData) => { return ( -
-
-
+
+
+
{offerData.name}
-
-

+

+

Lvl: {offerData.level}

-

+

Price: {offerData.price} so'm

-
- - +
); diff --git a/src/pages/profile/ProfileOfferData.js b/src/pages/profile/ProfileOfferData.js index 61626cb..7d465d1 100644 --- a/src/pages/profile/ProfileOfferData.js +++ b/src/pages/profile/ProfileOfferData.js @@ -1,49 +1,48 @@ -import profileImg from "./img/profile-img.png"; +import profileImg from './img/profile-img.png'; const ProfileOfferData = [ - { - id: 1, - image: profileImg, - price: 25000, - level: 65, - name: "user" - }, - { - id: 2, - image: profileImg, - price: 30000, - level: 40, - name: "user" - }, - { - id: 1, - image: profileImg, - price: 25000, - level: 65, - name: "user" - }, - { - id: 2, - image: profileImg, - price: 30000, - level: 40, - name: "user" - }, - { - id: 1, - image: profileImg, - price: 25000, - level: 65, - name: "user" - }, - { - id: 2, - image: profileImg, - price: 30000, - level: 40, - name: "user" - } + { + id: 1, + image: profileImg, + price: 25000, + level: 65, + name: 'user', + }, + { + id: 2, + image: profileImg, + price: 30000, + level: 40, + name: 'user', + }, + { + id: 3, + image: profileImg, + price: 25000, + level: 65, + name: 'user', + }, + { + id: 4, + image: profileImg, + price: 30000, + level: 40, + name: 'user', + }, + { + id: 5, + image: profileImg, + price: 25000, + level: 65, + name: 'user', + }, + { + id: 6, + image: profileImg, + price: 30000, + level: 40, + name: 'user', + }, +]; -] - -export default ProfileOfferData; \ No newline at end of file +export default ProfileOfferData; diff --git a/src/pages/profile/profile.css b/src/pages/profile/profile.css index a958115..4b65b7f 100644 --- a/src/pages/profile/profile.css +++ b/src/pages/profile/profile.css @@ -1,265 +1,279 @@ .profile { - padding-top: 90px; - padding-bottom: 6vw; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - background: url('./img/bg3.jpg') no-repeat; - background-size: cover; - background-position: center; - background-attachment: fixed; + padding-top: 90px; + padding-bottom: 6vw; + width: 100%; + display: flex; + align-items: center; + justify-content: center; + background: url('./img/bg3.jpg') no-repeat; + background-size: cover; + background-position: center; + background-attachment: fixed; } .profile-wrapper { - width: 576px; - height: 100%; - display: flex; - flex-direction: column; - justify-content: flex-start; - box-shadow: 0 0 8px #fff; - border-radius: 10px; - background: rgba(0, 0, 0, 0.6); - overflow: hidden; - background: #fff; + width: 576px; + height: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; + box-shadow: 0 0 8px #fff; + border-radius: 10px; + background: rgba(0, 0, 0, 0.6); + overflow: hidden; + background: #fff; } .profile-header { - padding: 1rem 1rem 0.2rem; - width: 100%; - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: flex-start; - background: url("./img/header-bg2.jpg") no-repeat; - background-size: cover; - background-position: center; + padding: 1rem 1rem 0.2rem; + width: 100%; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-start; + background: url('./img/header-bg2.jpg') no-repeat; + background-size: cover; + background-position: center; } .profile-header > span { - display: inline-block; - width: fit-content; - text-align: left; - letter-spacing: 1px; - font-size: 1.2rem; - font-weight: bold; - font-style: italic; - border-bottom: 2px solid white; + display: inline-block; + width: fit-content; + text-align: left; + letter-spacing: 1px; + font-size: 1.2rem; + font-weight: bold; + font-style: italic; + border-bottom: 2px solid white; } .profile-header .img { - margin-top: 0.6rem; - width: 100px; - height: 100px; - border-radius: 50%; - background: white; - align-self: center; + margin-top: 0.6rem; + width: 100px; + height: 100px; + border-radius: 50%; + background: white; + align-self: center; } .profile-info { - padding: 0.5rem; - width: 100%; - display: flex; - flex-direction: column; - align-items: center; - gap: 1rem; - background: linear-gradient(to bottom right, #37356c, #252251); + padding: 0.5rem; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + gap: 1rem; + background: linear-gradient(to bottom right, #37356c, #252251); } .profile-info .profile-name { - font-size: 1rem; - text-align: center; - letter-spacing: 1px; + font-size: 1rem; + text-align: center; + letter-spacing: 1px; } .profile-info .profile-detail { - font-size: 0.8rem; - text-indent: 1rem; - text-align: left; - line-height: 120%; - letter-spacing: 1px; + font-size: 0.8rem; + text-indent: 1rem; + text-align: left; + line-height: 120%; + letter-spacing: 1px; } .profile-info .profile-edit { - font-size: 0.8rem; - text-align: center; - line-height: 120%; - letter-spacing: 1px; - padding-bottom: 0.5rem; - border-bottom: 3px solid red; + font-size: 0.8rem; + text-align: center; + line-height: 120%; + letter-spacing: 1px; + padding-bottom: 0.5rem; + border-bottom: 3px solid red; } .profile-info .edit-btns { - width: 100%; - display: grid; - grid-template-columns: auto auto auto auto; - gap: 1rem; + width: 100%; + display: grid; + grid-template-columns: auto auto auto auto; + gap: 1rem; } .profile-info .edit-btns > button { - background: none; - border: none; - outline: none; - padding: 5px 0; - background: linear-gradient(to bottom right, #37356c, #252251); - font-size: 1rem; - border-radius: 20px; - box-shadow: 0px 0px 10px #000; - cursor: pointer; - transition: all .5s ease; + background: none; + border: none; + outline: none; + padding: 5px 0; + background: linear-gradient(to bottom right, #37356c, #252251); + font-size: 1rem; + border-radius: 20px; + box-shadow: 0px 0px 10px #000; + cursor: pointer; + transition: all 0.5s ease; } .profile-info .edit-btns > button:hover { - background: linear-gradient(to bottom right, #92438d, #7f2570); + background: linear-gradient(to bottom right, #92438d, #7f2570); } .profile-container { - width: 100%; - padding: 0.5rem; - display: flex; - flex-direction: column; - background: #fff; + width: 100%; + padding: 0.5rem; + display: flex; + flex-direction: column; + background: #fff; } .profile-container .profile-filter { - width: 100%; - display: flex; - justify-content: flex-end; - align-items: center; - gap: 1rem; - padding-bottom: 0.5rem; - border-bottom: 2px solid #000; + width: 100%; + display: flex; + justify-content: flex-end; + align-items: center; + gap: 1rem; + padding-bottom: 0.5rem; + border-bottom: 2px solid #000; } .profile-container .profile-filter > button { - border: none; - outline: none; - background: none; - color: #000; - padding: 10px 15px; - font-size: 1rem; - border-radius: 20px; - box-shadow: inset 0px 0px 8px #000; - cursor: pointer; - transition: all .3s ease; + border: none; + outline: none; + background: none; + color: #000; + padding: 10px 15px; + font-size: 1rem; + border-radius: 20px; + box-shadow: inset 0px 0px 8px #000; + cursor: pointer; + transition: all 0.3s ease; } .profile-container .profile-filter > button.active, .profile-container .profile-filter > button:active { - box-shadow: 0px 0px 8px #000; - background: #7f2570; - color: #fff; -} + box-shadow: 0px 0px 8px #000; + background: #7f2570; + color: #fff; +} .profile-container .data-container { - width: 100%; - height: 100%; - padding: 1rem 0; - display: flex; - flex-direction: column; - gap: 1rem; - overflow-y: scroll; + width: 100%; + height: 100%; + padding: 1rem 0; + display: flex; + flex-direction: column; + gap: 1rem; + overflow-y: scroll; } .profile-container .data-container .data-content { - width: 100%; - display: flex; - align-items: center; - justify-content: space-between; - padding: 0.5rem; - border: 2px solid #192e7e; - border-left-color: transparent; - border-radius: 20px; + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0.5rem; + border: 2px solid #192e7e; + border-left-color: transparent; + border-radius: 20px; } .profile-container .data-container .data-content .content-box { - display: flex; - align-items: center; - gap: 1rem; + display: flex; + align-items: center; + gap: 1rem; } .profile-container .data-container .data-content .content-img { - width: 50px; - height: 50px; - border-radius: 50%; - overflow: hidden; - border: 1px solid #192e7e; - box-shadow: 0 0 4px #000; - background: #fff; + width: 50px; + height: 50px; + border-radius: 50%; + overflow: hidden; + border: 1px solid #192e7e; + box-shadow: 0 0 4px #000; + background: #fff; } .profile-container .data-container .data-content .content-info { - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: center; - gap: 0.5rem; + display: flex; + flex-direction: column; + align-items: flex-start; + justify-content: center; + gap: 0.5rem; } .profile-container .data-container .data-content .content-level, -.profile-container .data-container .data-content .content-price - { - color: #000; - font-size: 1rem; - font-weight: 600; +.profile-container .data-container .data-content .content-price { + color: #000; + font-size: 1rem; + font-weight: 600; } .profile-container .data-container .data-content .content-level > span, -.profile-container .data-container .data-content .content-price > span - { - color: #7f2570; - font-size: 1.2rem; - font-weight: 600; +.profile-container .data-container .data-content .content-price > span { + color: #7f2570; + font-size: 1.2rem; + font-weight: 600; } .profile-container .data-container .data-content .content-info__edit { - /* margin-left: auto; */ - display: flex; - gap: 10px; + /* margin-left: auto; */ + display: flex; + gap: 10px; } .profile-container .data-container .data-content .content-info__edit > button { - border: none; - background: none; - outline: none; - color: #000; - cursor: pointer; + border: none; + background: none; + outline: none; + color: #000; + cursor: pointer; } .profile-container .data-container .data-content .delete-info__btn > ion-icon { - color: #ff0000; - font-size: 1.4rem; + color: #ff0000; + font-size: 1.4rem; } -.profile-container .data-container .data-content .delete-info__btn:hover > ion-icon { - transform: scale(1.1); +.profile-container + .data-container + .data-content + .delete-info__btn:hover + > ion-icon { + transform: scale(1.1); } .profile-container .data-container .data-content .update-info__btn { - color: #000; - font-size: 1rem; - font-weight: 600; - padding: 5px 10px; - background: rgb(26, 215, 26) !important; - border-radius: 10px; + color: #000; + font-size: 1rem; + font-weight: 600; + padding: 5px 10px; + background: rgb(26, 215, 26) !important; + border-radius: 10px; } .profile-container .data-container .data-content .update-info__btn:hover { - background: rgb(49, 238, 49) !important; + background: rgb(49, 238, 49) !important; } .profile-container .data-container .data-content .update-info__btn:active { - background: rgb(26, 215, 26) !important; + background: rgb(26, 215, 26) !important; } +.chiqish { + display: flex; + border: 1.5px solid #6547f7; + border-radius: 5px; + padding: 0.2rem; + box-shadow: 0 0 10px rgb(58, 41, 86); + margin-left: auto; +} -@media screen and (max-width: 576px){ - .profile { - padding-left: 3vw; - padding-right: 3vw; - padding-bottom: 3vw; - align-items: flex-start; - } - .profile-wrapper { - width: 100%; - } - .profile-info .edit-btns { - grid-template-columns: auto auto; - gap: 1rem; - } +.chiqish ion-icon { + font-size: 1.1rem; +} + +@media screen and (max-width: 576px) { + .profile { + padding-left: 3vw; + padding-right: 3vw; + padding-bottom: 3vw; + align-items: flex-start; + } + .profile-wrapper { + width: 100%; + } + .profile-info .edit-btns { + grid-template-columns: auto auto; + gap: 1rem; + } - .profile-container .data-container .data-content { - width: 100%; - display: flex; - flex-direction: column; - align-items: flex-start; - gap: 1rem; - justify-content: space-between; - } - .profile-container .data-container .data-content .content-box { - width: 100%; - display: flex; - align-items: center; - gap: 1rem; - } - .profile-container .data-container .data-content .content-info__edit { - width: 100%; - justify-content: flex-end; - } -} \ No newline at end of file + .profile-container .data-container .data-content { + width: 100%; + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 1rem; + justify-content: space-between; + } + .profile-container .data-container .data-content .content-box { + width: 100%; + display: flex; + align-items: center; + gap: 1rem; + } + .profile-container .data-container .data-content .content-info__edit { + width: 100%; + justify-content: flex-end; + } +} diff --git a/src/pages/signup/Signup.js b/src/pages/signup/Signup.js index ac73fe6..16885c7 100644 --- a/src/pages/signup/Signup.js +++ b/src/pages/signup/Signup.js @@ -1,9 +1,32 @@ -import React from 'react'; +import React, { useState } from 'react'; import './signup.css'; import logo1 from '../../component/header/logo1_1.png'; -import { NavLink, Link } from 'react-router-dom'; +import { NavLink, useNavigate } from 'react-router-dom'; +import { useDispatch } from 'react-redux'; +import { signUp } from '../../slices/authSlice'; const Signup = () => { + const [phoneNumber, setPhoneNumber] = useState(''); + const [password, setPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [passwordError, setPasswordError] = useState(''); + const navigate = useNavigate(); + const dispatch = useDispatch(); + + const handleSubmit = (event) => { + event.preventDefault(); + if (password !== confirmPassword) { + setPasswordError('Parol togri kemadi'); + console.log(passwordError); + return; + } + + setPasswordError(''); + dispatch(signUp({ number: phoneNumber, password })); + + navigate('/confirm'); + }; + return (
@@ -16,42 +39,61 @@ const Signup = () => {
logo

Ro'yxatdan o'ting

-
+
- - + + setPhoneNumber(e.target.value)} // Update state on change + />
- - + + setPassword(e.target.value)} + />
- - + + setConfirmPassword(e.target.value)} + /> + {passwordError && ( +
{passwordError}
+ )}
- - + + + +


- diff --git a/src/pages/signup/confirm/Confirm.js b/src/pages/signup/confirm/Confirm.js new file mode 100644 index 0000000..1e0e036 --- /dev/null +++ b/src/pages/signup/confirm/Confirm.js @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; +import { useDispatch } from 'react-redux'; +import { verifyNumber } from '../../../slices/authSlice'; +import './confirm.css'; +import logo1 from '../../../component/header/logo1_1.png'; +import { NavLink, Link } from 'react-router-dom'; + +const Confirm = () => { + const [otp, setOtp] = useState(''); + const dispatch = useDispatch(); + const handleSubmit = (event) => { + event.preventDefault(); + dispatch(verifyNumber(otp)); + // handle response or navigate to another page as needed + console.log('Boldii'); + }; + + return ( +
+
+
+
+
+
+
+
+
+ logo +

Nomeringizni tasdiqlang

+ +
+ + setOtp(e.target.value)} + /> +
+
+ +
+ + +
+
+
+
+
+ + + +
+
+ + +
+
+
+
+
+ ); +}; + +export default Confirm; diff --git a/src/pages/signup/confirm/confirm.css b/src/pages/signup/confirm/confirm.css new file mode 100644 index 0000000..3484dde --- /dev/null +++ b/src/pages/signup/confirm/confirm.css @@ -0,0 +1,291 @@ +.login-section { + padding-top: 90px; + padding-bottom: 3vw; + width: 100%; + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + + background: url('../../../img/bg2.jpg') no-repeat center; + background-size: cover; +} +.login-container-signup { + width: 400px; + padding: 10px; + font-family: Arial, Helvetica, sans-serif; + background-image: linear-gradient( + to right top, + #1a1643, + #2b1d47, + #39254b, + #452d4f, + #503653 + ); + border-radius: 25px; + box-shadow: 5px 5px 10px #000000, -5px -5px 10px #2b2b2b; /* Adjusted to create a subtle depth */ + color: white; + overflow: hidden; +} + +.login-section .login-border { + width: 100%; + display: flex; + flex-direction: column; + border: 2px solid #7069b1; + border-top: none; + border-radius: 25px; + position: relative; +} + +.login-section .line { + display: flex; + gap: 1rem; +} + +.login-section .line hr { + margin: auto; + border: 0; + height: 2px; + border-radius: 5px; + width: 12%; + background-image: linear-gradient(to right, #612a39, #d4abb6); + box-shadow: 0px -1px 5px rgba(0, 0, 0, 0.5); + margin-bottom: -1rem; +} + +.login-section .corner-item { + position: absolute; + background-image: linear-gradient( + to bottom, + + #e9e9e9, + #f13f9f, + #f13f9f, + #df41bc, + #c04dda, + #8e5df5 + ); + width: 1.4rem; + height: 1.4rem; + border-radius: 50%; /* This will make it perfectly round */ + box-shadow: -4px 8px 10px rgba(0, 0, 0, 0.856); + border: 1px solid black; +} + +.login-section .top-left { + top: 0.9rem; /* Half of the height to ensure it's centered on the corner */ + left: 0.8rem; /* Half of the width to ensure it's centered on the corner */ +} + +.login-section .top-right { + top: 0.9rem; + right: 0.8rem; +} + +.login-section .bottom-left { + bottom: 0.9rem; + left: 0.8rem; + background-image: linear-gradient(to bottom, #df41bc, #c04dda, #8e5df5); + box-shadow: none; +} + +.login-section .bottom-right { + bottom: 0.7rem; + right: 0.8rem; + background-image: linear-gradient(to bottom, #df41bc, #c04dda, #8e5df5); + box-shadow: none; +} + +.login-section .logo-in { + width: 3rem; + height: 3rem; + margin: 0 auto; +} + +.login-section h2 { + font-family: Arial, Helvetica, sans-serif; + text-align: center; + font-size: 1.8rem; + margin-top: 1rem; + margin-bottom: 1rem; + letter-spacing: 1px; +} + +.login-section .login-form { + padding: 1rem; + width: 100%; + display: flex; + flex-direction: column; +} + +.login-section .input-container { + width: 100%; + display: flex; + flex-direction: column; + margin-bottom: 1rem; +} + +.login-section .input-container label { + text-transform: uppercase; + display: block; + font-size: 0.8rem; + color: white; + margin-bottom: 0.5rem; +} + +.login-section .input-container input { + width: 100%; + padding: 10px; + border-radius: 25px; + background: #442b4e; + box-shadow: inset 2px 2px 5px #1b1b1b, inset -2px -2px 5px #3b3b3b; /* Neumorphism effect */ + color: white; + border: 2px solid white; +} + +.sms { + margin: 0 auto; + width: 60%; + padding: 10px; + border-radius: 25px; + background: #442b4e; + box-shadow: inset 2px 2px 5px #1b1b1b, inset -2px -2px 5px #3b3b3b; /* Neumorphism effect */ + color: white; + border: 2px solid white; +} + +.login-section .vertical-hr { + margin-top: 0.5rem; + margin-right: 0.5rem; + border-radius: 10px; + height: 5rem; + border-left: 1px solid #15009b; + transform-origin: left; +} + +.login-section .horizontal-hr { + border-radius: 5px; + width: 7rem; + margin: auto; + border: 0; + height: 2px; + border-radius: 5px; + background-image: linear-gradient(to right, #443e5b, #4c426c, #d4abb6); +} + +.login-section .login-footer { + width: 100%; + display: flex; + align-items: flex-end; + gap: 1rem; + margin-bottom: 2rem; +} + +.login-section .login-footer > div { + width: 50%; + height: 100%; + display: flex; + flex-direction: column; +} + +.login-container-signup .login-footer button { + border: none; + padding: 10px 10px; + width: 100%; + margin-top: 1.8rem; + border-radius: 20px; + color: white; + background-image: linear-gradient( + to left bottom, + #88347b, + #6f2b75, + #54236e, + #371c65, + #10165c + ); + box-shadow: 4px 4px 6px #1b1b1b, -4px -4px 6px #3b3b3b; /* Neumorphism effect */ + cursor: pointer; + border-top: 2px solid #d6b1d6; /* Light blue top border */ + border-right: 2px solid #d969c6; /* Regular blue for the right border */ + border-bottom: 2px solid #775fcf; /* Regular blue for the bottom border */ + border-left: 2px solid #775fcf; /* Regular blue for the left border */ +} + +.login-section .back-home a { + display: block; + text-align: center; + color: #aaa; + text-decoration: none; +} +.login-section .back-home a:hover { + color: #fff; +} + +.login-section .login-main-signup { + width: 100%; + font-size: 1.2rem; + font-weight: 800; + letter-spacing: 2px; + padding: 5px; + border-radius: 25px; + margin-top: 2rem; + margin-bottom: 3rem; + border-top: 2px solid #d6b1d6; /* Light blue top border */ + border-right: 2px solid #d969c6; /* Regular blue for the right border */ + border-bottom: 2px solid #775fcf; /* Regular blue for the bottom border */ + border-left: 2px solid #775fcf; /* Regular blue for the left border */ + background-image: linear-gradient( + to left bottom, + #88347b, + #6f2b75, + #54236e, + #371c65, + #10165c + ); +} + +.login-section .back-home { + display: flex; +} + +.login-section .back-home hr { + margin: auto; + border: 0; + height: 2px; + border-radius: 5px; + width: 20%; + background-image: linear-gradient( + to right, + #35327a, + rgb(136, 126, 176), + rgb(231, 231, 231) + ); + box-shadow: 0px -1px 5px rgba(0, 0, 0, 0.5); +} + +.login-section .bottom-line { + margin: auto; + border: 0; + height: 2px; + border-radius: 5px; + width: 60%; + background-image: linear-gradient( + to right, + #35327a, + rgb(136, 126, 176), + rgb(231, 231, 231) + ); + box-shadow: 0px -1px 5px rgba(0, 0, 0, 0.5); + margin-top: 1rem; +} + +@media screen and (max-width: 400px) { + .login-section { + padding-left: 15px; + padding-right: 15px; + } + .login-section .login-container-signup { + width: 100%; + } +} diff --git a/src/pages/signup/signup.css b/src/pages/signup/signup.css index fecc5d3..5a34c50 100644 --- a/src/pages/signup/signup.css +++ b/src/pages/signup/signup.css @@ -7,7 +7,7 @@ align-items: center; justify-content: center; - background: url("../../img/bg2.jpg") no-repeat center ; + background: url('../../img/bg2.jpg') no-repeat center; background-size: cover; } .login-container-signup { @@ -109,7 +109,7 @@ font-size: 1.8rem; margin-top: 1rem; margin-bottom: 1rem; - letter-spacing: 1px;; + letter-spacing: 1px; } .login-section .login-form { @@ -212,7 +212,6 @@ border-left: 2px solid #775fcf; /* Regular blue for the left border */ } - .login-section .back-home a { display: block; text-align: center; @@ -289,4 +288,4 @@ .login-section .login-container-signup { width: 100%; } -} \ No newline at end of file +} diff --git a/src/slices/authSlice.js b/src/slices/authSlice.js new file mode 100644 index 0000000..b14d29a --- /dev/null +++ b/src/slices/authSlice.js @@ -0,0 +1,108 @@ +// src/features/auth/authSlice.js +import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'; +import axios from '../api/axios'; + +const initialState = { + user: null, + status: 'idle', // 'idle' | 'loading' | 'succeeded' | 'failed' + error: null, +}; + +export const logIn = createAsyncThunk( + 'auth/logIn', + async (credentials, thunkAPI) => { + try { + const response = await axios.post('/login', credentials); + return response.data; + } catch (error) { + return thunkAPI.rejectWithValue(error.response.data); + } + } +); + +export const checkLogIn = createAsyncThunk( + 'auth/checkLogIn', + async (thunkAPI) => { + try { + const userResponse = await axios.get('/me'); + return userResponse.data; + } catch (error) { + return thunkAPI.rejectWithValue(error.response.data); + } + } +); + +export const logOutUser = createAsyncThunk( + 'auth/logOutUser', + async (_, thunkAPI) => { + try { + await axios.post('/logout'); + thunkAPI.dispatch(logOut()); + } catch (error) { + return thunkAPI.rejectWithValue(error.response.data); + } + } +); + +export const signUp = createAsyncThunk( + 'auth/signUp', + async ({ number, password }, thunkAPI) => { + try { + const response = await axios.post('/registration', { + number, + password, + }); + return response.data; + } catch (error) { + return thunkAPI.rejectWithValue(error.response.data); + } + } +); + +export const verifyNumber = createAsyncThunk( + 'auth/verifyNumber', + async (otp, thunkAPI) => { + try { + const response = await axios.post('/registration/verify', { + ot_password: otp, + }); + console.log(response.data); + return response.data; + } catch (error) { + return thunkAPI.rejectWithValue(error.response.data); + } + } +); + +const authSlice = createSlice({ + name: 'auth', + initialState, + reducers: { + logOut: (state) => { + state.user = null; + state.status = 'idle'; + state.error = null; + }, + }, + extraReducers: (builder) => { + builder + .addCase(verifyNumber.fulfilled, (state, action) => { + state.status = 'succeeded'; + state.user = action.payload; + }) + .addCase(logIn.fulfilled, (state, action) => { + state.status = 'succeeded'; + state.user = action.payload; + }) + // Handle the fulfilled state of checkLogIn + .addCase(checkLogIn.fulfilled, (state, action) => { + state.status = 'succeeded'; + state.user = action.payload; + }); + // Add other cases for pending and rejected states if needed + }, +}); + +export const selectCurrentUser = (state) => state.auth.user; +export const { logOut } = authSlice.actions; +export default authSlice.reducer; diff --git a/src/store.js b/src/store.js new file mode 100644 index 0000000..e02ae0e --- /dev/null +++ b/src/store.js @@ -0,0 +1,9 @@ +// src/app/store.js +import { configureStore } from '@reduxjs/toolkit'; +import authReducer from './slices/authSlice'; + +export const store = configureStore({ + reducer: { + auth: authReducer, + }, +});