Changeset 16237c4
- Timestamp:
- 09/08/22 12:38:24 (2 years ago)
- Branches:
- master
- Children:
- ee05663
- Parents:
- 717ceae
- Files:
-
- 12 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/models/userModel.js
r717ceae r16237c4 4 4 { 5 5 name: { type: String, required: true }, 6 contact: { type: String, required: true }, 6 7 email: { type: String, required: true, unique: true }, 7 8 password: { type: String, required: true }, -
backend/package-lock.json
r717ceae r16237c4 13 13 "dotenv": "^16.0.1", 14 14 "express": "^4.18.1", 15 "express-async-handler": "^1.2.0", 16 "jsonwebtoken": "^8.5.1", 15 17 "mongoose": "^6.5.3" 16 18 }, … … 192 194 } 193 195 }, 196 "node_modules/buffer-equal-constant-time": { 197 "version": "1.0.1", 198 "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", 199 "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 200 }, 194 201 "node_modules/bytes": { 195 202 "version": "3.1.2", … … 316 323 "engines": { 317 324 "node": ">=12" 325 } 326 }, 327 "node_modules/ecdsa-sig-formatter": { 328 "version": "1.0.11", 329 "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 330 "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", 331 "dependencies": { 332 "safe-buffer": "^5.0.1" 318 333 } 319 334 }, … … 385 400 } 386 401 }, 402 "node_modules/express-async-handler": { 403 "version": "1.2.0", 404 "resolved": "https://registry.npmjs.org/express-async-handler/-/express-async-handler-1.2.0.tgz", 405 "integrity": "sha512-rCSVtPXRmQSW8rmik/AIb2P0op6l7r1fMW538yyvTMltCO4xQEWMmobfrIxN2V1/mVrgxB8Az3reYF6yUZw37w==" 406 }, 387 407 "node_modules/fill-range": { 388 408 "version": "7.0.1", … … 616 636 } 617 637 }, 638 "node_modules/jsonwebtoken": { 639 "version": "8.5.1", 640 "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", 641 "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", 642 "dependencies": { 643 "jws": "^3.2.2", 644 "lodash.includes": "^4.3.0", 645 "lodash.isboolean": "^3.0.3", 646 "lodash.isinteger": "^4.0.4", 647 "lodash.isnumber": "^3.0.3", 648 "lodash.isplainobject": "^4.0.6", 649 "lodash.isstring": "^4.0.1", 650 "lodash.once": "^4.0.0", 651 "ms": "^2.1.1", 652 "semver": "^5.6.0" 653 }, 654 "engines": { 655 "node": ">=4", 656 "npm": ">=1.4.28" 657 } 658 }, 659 "node_modules/jsonwebtoken/node_modules/ms": { 660 "version": "2.1.3", 661 "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 662 "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 663 }, 664 "node_modules/jwa": { 665 "version": "1.4.1", 666 "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 667 "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", 668 "dependencies": { 669 "buffer-equal-constant-time": "1.0.1", 670 "ecdsa-sig-formatter": "1.0.11", 671 "safe-buffer": "^5.0.1" 672 } 673 }, 674 "node_modules/jws": { 675 "version": "3.2.2", 676 "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", 677 "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", 678 "dependencies": { 679 "jwa": "^1.4.1", 680 "safe-buffer": "^5.0.1" 681 } 682 }, 618 683 "node_modules/kareem": { 619 684 "version": "2.4.1", 620 685 "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.4.1.tgz", 621 686 "integrity": "sha512-aJ9opVoXroQUPfovYP5kaj2lM7Jn02Gw13bL0lg9v0V7SaUc0qavPs0Eue7d2DcC3NjqI6QAUElXNsuZSeM+EA==" 687 }, 688 "node_modules/lodash.includes": { 689 "version": "4.3.0", 690 "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", 691 "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" 692 }, 693 "node_modules/lodash.isboolean": { 694 "version": "3.0.3", 695 "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", 696 "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" 697 }, 698 "node_modules/lodash.isinteger": { 699 "version": "4.0.4", 700 "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", 701 "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" 702 }, 703 "node_modules/lodash.isnumber": { 704 "version": "3.0.3", 705 "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", 706 "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" 707 }, 708 "node_modules/lodash.isplainobject": { 709 "version": "4.0.6", 710 "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", 711 "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" 712 }, 713 "node_modules/lodash.isstring": { 714 "version": "4.0.1", 715 "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", 716 "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" 717 }, 718 "node_modules/lodash.once": { 719 "version": "4.1.1", 720 "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", 721 "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" 622 722 }, 623 723 "node_modules/media-typer": { … … 1021 1121 "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 1022 1122 "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 1023 "dev": true,1024 1123 "bin": { 1025 1124 "semver": "bin/semver" … … 1396 1495 } 1397 1496 }, 1497 "buffer-equal-constant-time": { 1498 "version": "1.0.1", 1499 "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", 1500 "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 1501 }, 1398 1502 "bytes": { 1399 1503 "version": "3.1.2", … … 1482 1586 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz", 1483 1587 "integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==" 1588 }, 1589 "ecdsa-sig-formatter": { 1590 "version": "1.0.11", 1591 "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 1592 "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", 1593 "requires": { 1594 "safe-buffer": "^5.0.1" 1595 } 1484 1596 }, 1485 1597 "ee-first": { … … 1541 1653 } 1542 1654 }, 1655 "express-async-handler": { 1656 "version": "1.2.0", 1657 "resolved": "https://registry.npmjs.org/express-async-handler/-/express-async-handler-1.2.0.tgz", 1658 "integrity": "sha512-rCSVtPXRmQSW8rmik/AIb2P0op6l7r1fMW538yyvTMltCO4xQEWMmobfrIxN2V1/mVrgxB8Az3reYF6yUZw37w==" 1659 }, 1543 1660 "fill-range": { 1544 1661 "version": "7.0.1", … … 1700 1817 "dev": true 1701 1818 }, 1819 "jsonwebtoken": { 1820 "version": "8.5.1", 1821 "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", 1822 "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", 1823 "requires": { 1824 "jws": "^3.2.2", 1825 "lodash.includes": "^4.3.0", 1826 "lodash.isboolean": "^3.0.3", 1827 "lodash.isinteger": "^4.0.4", 1828 "lodash.isnumber": "^3.0.3", 1829 "lodash.isplainobject": "^4.0.6", 1830 "lodash.isstring": "^4.0.1", 1831 "lodash.once": "^4.0.0", 1832 "ms": "^2.1.1", 1833 "semver": "^5.6.0" 1834 }, 1835 "dependencies": { 1836 "ms": { 1837 "version": "2.1.3", 1838 "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1839 "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 1840 } 1841 } 1842 }, 1843 "jwa": { 1844 "version": "1.4.1", 1845 "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 1846 "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", 1847 "requires": { 1848 "buffer-equal-constant-time": "1.0.1", 1849 "ecdsa-sig-formatter": "1.0.11", 1850 "safe-buffer": "^5.0.1" 1851 } 1852 }, 1853 "jws": { 1854 "version": "3.2.2", 1855 "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", 1856 "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", 1857 "requires": { 1858 "jwa": "^1.4.1", 1859 "safe-buffer": "^5.0.1" 1860 } 1861 }, 1702 1862 "kareem": { 1703 1863 "version": "2.4.1", 1704 1864 "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.4.1.tgz", 1705 1865 "integrity": "sha512-aJ9opVoXroQUPfovYP5kaj2lM7Jn02Gw13bL0lg9v0V7SaUc0qavPs0Eue7d2DcC3NjqI6QAUElXNsuZSeM+EA==" 1866 }, 1867 "lodash.includes": { 1868 "version": "4.3.0", 1869 "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", 1870 "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" 1871 }, 1872 "lodash.isboolean": { 1873 "version": "3.0.3", 1874 "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", 1875 "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" 1876 }, 1877 "lodash.isinteger": { 1878 "version": "4.0.4", 1879 "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", 1880 "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" 1881 }, 1882 "lodash.isnumber": { 1883 "version": "3.0.3", 1884 "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", 1885 "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" 1886 }, 1887 "lodash.isplainobject": { 1888 "version": "4.0.6", 1889 "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", 1890 "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" 1891 }, 1892 "lodash.isstring": { 1893 "version": "4.0.1", 1894 "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", 1895 "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" 1896 }, 1897 "lodash.once": { 1898 "version": "4.1.1", 1899 "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", 1900 "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" 1706 1901 }, 1707 1902 "media-typer": { … … 1987 2182 "version": "5.7.1", 1988 2183 "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 1989 "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 1990 "dev": true 2184 "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" 1991 2185 }, 1992 2186 "send": { -
backend/package.json
r717ceae r16237c4 15 15 "dotenv": "^16.0.1", 16 16 "express": "^4.18.1", 17 "express-async-handler": "^1.2.0", 18 "jsonwebtoken": "^8.5.1", 17 19 "mongoose": "^6.5.3" 18 20 }, -
backend/server.js
r717ceae r16237c4 5 5 import seedRouter from "./routes/seedRoutes.js"; 6 6 import productRouter from "./routes/productRoutes.js"; 7 import userRouter from "./routes/userRoutes.js"; 8 import orderRouter from "./routes/orderRoutes.js"; 7 9 8 10 dotenv.config(); … … 18 20 19 21 const app = express(); 22 23 app.use(express.json()); 24 app.use(express.urlencoded({ extended: true })); 25 20 26 app.use("/api/seed", seedRouter); 21 27 app.use("/api/products", productRouter); 28 app.use("/api/users", userRouter); 29 app.use("/api/orders", orderRouter); 30 31 app.use((err, req, res, next) => { 32 res.status(500).send({ message: err.message }); 33 }); 22 34 23 35 const port = process.env.PORT || 5000; -
frontend/package-lock.json
r717ceae r16237c4 28 28 "react-router-dom": "^6.3.0", 29 29 "react-scripts": "5.0.1", 30 "react-toastify": "^9.0.8", 30 31 "web-vitals": "^2.1.4" 31 32 } … … 14659 14660 } 14660 14661 }, 14662 "node_modules/react-toastify": { 14663 "version": "9.0.8", 14664 "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.0.8.tgz", 14665 "integrity": "sha512-EwM+teWt49HSHx+67qI08yLAW1zAsBxCXLCsUfxHYv1W7/R3ZLhrqKalh7j+kjgPna1h5LQMSMwns4tB4ww2yQ==", 14666 "dependencies": { 14667 "clsx": "^1.1.1" 14668 }, 14669 "peerDependencies": { 14670 "react": ">=16", 14671 "react-dom": ">=16" 14672 } 14673 }, 14661 14674 "node_modules/react-transition-group": { 14662 14675 "version": "4.4.5", … … 27673 27686 } 27674 27687 }, 27688 "react-toastify": { 27689 "version": "9.0.8", 27690 "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.0.8.tgz", 27691 "integrity": "sha512-EwM+teWt49HSHx+67qI08yLAW1zAsBxCXLCsUfxHYv1W7/R3ZLhrqKalh7j+kjgPna1h5LQMSMwns4tB4ww2yQ==", 27692 "requires": { 27693 "clsx": "^1.1.1" 27694 } 27695 }, 27675 27696 "react-transition-group": { 27676 27697 "version": "4.4.5", -
frontend/package.json
r717ceae r16237c4 24 24 "react-router-dom": "^6.3.0", 25 25 "react-scripts": "5.0.1", 26 "react-toastify": "^9.0.8", 26 27 "web-vitals": "^2.1.4" 27 28 }, -
frontend/src/App.js
r717ceae r16237c4 11 11 import CategoryScreen from "./screens/CategoryScreen"; 12 12 import SigninScreen from "./screens/SigninScreen"; 13 import { ToastContainer } from "react-toastify"; 14 import "react-toastify/dist/ReactToastify.css"; 15 import ShippingAddressScreen from "./screens/ShippingAddressScreen"; 16 import SignupScreen from "./screens/SignupScreen"; 17 import PaymentMethodScreen from "./screens/PaymentMethodScreen"; 18 import PlaceOrderScreen from "./screens/PlaceOrderScreen"; 19 import OrderScreen from "./screens/OrderScreen"; 20 import CardPaymentScreen from "./screens/CardPaymentScreen"; 21 import OrderHistoryScreen from "./screens/OrderHistoryScreen"; 13 22 14 23 function App() { … … 17 26 return ( 18 27 <BrowserRouter> 28 <ToastContainer position="bottom-center" limit={1} /> 19 29 <Header /> 20 30 … … 24 34 <Route path="/cart" element={<CartScreen />} /> 25 35 <Route path="/signin" element={<SigninScreen />} /> 36 <Route path="/signup" element={<SignupScreen />} /> 37 <Route path="/shipping" element={<ShippingAddressScreen />} /> 38 <Route path="/payment" element={<PaymentMethodScreen />} /> 39 <Route path="/placeorder" element={<PlaceOrderScreen />} /> 40 <Route path="placeorder/payment" element={<CardPaymentScreen />} /> 41 <Route path="/orderhistory" element={<OrderHistoryScreen />} /> 42 <Route path="/order/:id" element={<OrderScreen />} /> 26 43 <Route path="/products" element={<CategoryScreen />} /> 27 44 </Routes> -
frontend/src/Store.js
r717ceae r16237c4 4 4 5 5 const initialState = { 6 userInfo: localStorage.getItem("userInfo") 7 ? JSON.parse(localStorage.getItem("userInfo")) 8 : null, 6 9 cart: { 10 shippingAddress: localStorage.getItem("shippingAddress") 11 ? JSON.parse(localStorage.getItem("shippingAddress")) 12 : {}, 13 paymentMethod: localStorage.getItem("paymentMethod") 14 ? localStorage.getItem("paymentMethod") 15 : "", 7 16 cartItems: localStorage.getItem("cartItems") 8 17 ? JSON.parse(localStorage.getItem("cartItems")) … … 32 41 return { ...state, cart: { ...state.cart, cartItems } }; 33 42 } 43 case "CART_CLEAR": 44 return { ...state, cart: { ...state.cart, cartItems: [] } }; 45 case "USER_SIGNIN": 46 return { ...state, userInfo: action.payload }; 47 case "USER_SIGNOUT": 48 return { 49 ...state, 50 userInfo: null, 51 cart: { cartItems: [], shippingAddress: {}, paymentMethod: "" }, 52 }; 53 case "SAVE_SHIPPING_ADDRESS": 54 return { 55 ...state, 56 cart: { ...state.cart, shippingAddress: action.payload }, 57 }; 58 case "SAVE_PAYMENT_METHOD": 59 return { 60 ...state, 61 cart: { ...state.cart, paymentMethod: action.payload }, 62 }; 34 63 default: 35 64 return state; -
frontend/src/components/Header.js
r717ceae r16237c4 16 16 import ShoppingBasketIcon from "@mui/icons-material/ShoppingCart"; 17 17 import MenuIcon from "@mui/icons-material/Menu"; 18 import { Link } from "react-router-dom";18 import { Link, NavLink, useNavigate } from "react-router-dom"; 19 19 import logo2 from "../Images/logo2.png"; 20 20 import Badge from "react-bootstrap/Badge"; … … 22 22 import { Store } from "../Store"; 23 23 import { useContext } from "react"; 24 import NavDropdown from "react-bootstrap/NavDropdown"; 24 25 25 26 const toggleMenu = (event) => { 27 event.stopPropagation(); 26 28 let menu = document.querySelector(".mobile-menu-container"); 27 29 menu.classList.remove("hidden"); … … 30 32 31 33 const toggleSubMenu = (event) => { 34 event.stopPropagation(); 32 35 let menu = document.querySelector(".subDropdown"); 33 36 menu.classList.remove("hidden"); … … 68 71 69 72 function Header() { 70 const { state } = useContext(Store); 71 const { cart } = state; 73 const { state, dispatch: ctxDispatch } = useContext(Store); 74 const { cart, userInfo } = state; 75 const navigate = useNavigate(); 76 77 const signoutHandler = () => { 78 ctxDispatch({ type: "USER_SIGNOUT" }); 79 localStorage.removeItem("userInfo"); 80 localStorage.removeItem("shippingAddress"); 81 localStorage.removeItem("paymentMethod"); 82 }; 83 72 84 return ( 73 85 <div className="header"> … … 78 90 onClick={toggleMenu} 79 91 /> 80 <img className="header__icon" src={logo2} alt="logo"></img> 92 <img 93 className="header__icon" 94 src={logo2} 95 alt="logo" 96 onClick={() => { 97 navigate("/"); 98 }} 99 ></img> 81 100 </div> 82 101 <div className="mobile-menu-container hidden"> … … 85 104 </div> 86 105 <ul className="mobile-menu"> 87 <li>Почетна</li> 106 <Link 107 to="/" 108 style={{ textDecoration: "none", color: "black" }} 109 onClick={closeMenu} 110 > 111 <li>Почетна</li> 112 </Link> 88 113 <li onClick={toggleSubMenu} className="subMenu"> 89 114 Производи <ArrowDropDownIcon /> … … 492 517 <div className="header__right"> 493 518 <div className="header__buttons"> 494 <span> 495 <AccountCircleIcon className="header__login" fontSize="large" /> 496 <p>Најави се</p> 497 </span> 519 {userInfo ? ( 520 <NavDropdown 521 title={ 522 <span> 523 <AccountCircleIcon 524 className="header__login" 525 fontSize="large" 526 /> 527 <p>{userInfo.name}</p> 528 </span> 529 } 530 id="basic-nav-dropdown" 531 > 532 <NavDropdown.Item 533 onClick={() => { 534 navigate("/profile"); 535 }} 536 > 537 Профил 538 </NavDropdown.Item> 539 540 <NavDropdown.Item 541 onClick={() => { 542 navigate("/orderhistory"); 543 }} 544 > 545 Нарачки 546 </NavDropdown.Item> 547 548 <NavDropdown.Divider /> 549 <Link 550 className="drowdown-item" 551 to="#signout" 552 onClick={signoutHandler} 553 > 554 Одјави се 555 </Link> 556 </NavDropdown> 557 ) : ( 558 <Link 559 to={"/signin"} 560 className="link" 561 onClick={() => { 562 navigate("/orderhistory"); 563 }} 564 > 565 <span> 566 <AccountCircleIcon className="header__login" fontSize="large" /> 567 <p>Најави се</p> 568 </span> 569 </Link> 570 )} 571 498 572 <Link to="/cart" className="badgee"> 499 573 <span> -
frontend/src/index.css
r717ceae r16237c4 1 .checkout-steps > div { 2 border-bottom: 0.2rem solid #a0a0a0; 3 color: #a0a0a0; 4 } 5 6 .checkout-steps > div.active { 7 border-bottom: 0.2rem solid #f08000; 8 color: #f08000; 9 } -
frontend/src/screens/SigninScreen.js
r717ceae r16237c4 1 import Axios from "axios"; 1 2 import Container from "react-bootstrap/Container"; 2 3 import Form from "react-bootstrap/Form"; … … 4 5 import Button from "react-bootstrap/Button"; 5 6 import "../styles/SigninScreen.css"; 6 import React from "react"; 7 import { Link, useLocation } from "react-router-dom"; 7 import React, { useContext, useEffect, useState } from "react"; 8 import { Link, useLocation, useNavigate } from "react-router-dom"; 9 import { Store } from "../Store"; 10 import { toast } from "react-toastify"; 11 import { getError } from "../components/utils"; 8 12 9 13 function SigninScreen() { 14 const navigate = useNavigate(); 10 15 const { search } = useLocation(); 11 16 const redirectInUrl = new URLSearchParams(search).get("redirect"); 12 17 const redirect = redirectInUrl ? redirectInUrl : "/"; 18 19 const [email, setEmail] = useState(""); 20 const [password, setPassword] = useState(""); 21 22 const { state, dispatch: ctxDispatch } = useContext(Store); 23 const { userInfo } = state; 24 25 const submitHandler = async (e) => { 26 e.preventDefault(); 27 try { 28 const { data } = await Axios.post("/api/users/signin", { 29 email, 30 password, 31 }); 32 ctxDispatch({ type: "USER_SIGNIN", payload: data }); 33 localStorage.setItem("userInfo", JSON.stringify(data)); 34 navigate(redirect || "/"); 35 } catch (err) { 36 toast.error(getError(err)); 37 } 38 }; 39 40 useEffect(() => { 41 if (userInfo) { 42 navigate(redirect); 43 } 44 }, [navigate, redirect, userInfo]); 45 13 46 return ( 14 47 <div className="pageContainer"> … … 18 51 </Helmet> 19 52 <h1>Најави се</h1> 20 <Form className="formCointainer" >53 <Form className="formCointainer" onSubmit={submitHandler}> 21 54 <Form.Group controlId="email"> 22 55 <Form.Label>Email</Form.Label> 23 <Form.Control type="email" required /> 56 <Form.Control 57 type="email" 58 required 59 onChange={(e) => setEmail(e.target.value)} 60 /> 24 61 </Form.Group> 25 62 <Form.Group controlId="password"> 26 63 <Form.Label>Лозинка</Form.Label> 27 <Form.Control type="email" required /> 64 <Form.Control 65 type="password" 66 required 67 onChange={(e) => setPassword(e.target.value)} 68 /> 28 69 </Form.Group> 29 70 <div className="submitBtnContainer"> -
frontend/src/styles/Header.css
r717ceae r16237c4 6 6 margin: 0; 7 7 padding: 0; 8 margin-top: 10px; 8 9 height: 70px; 9 10 width: 100%; … … 200 201 } 201 202 203 #basic-nav-dropdown { 204 display: flex; 205 justify-content: center; 206 align-items: center; 207 } 208 202 209 @media only screen and (max-width: 1015px) { 203 210 .header__dropdown { -
frontend/src/styles/SigninScreen.css
r717ceae r16237c4 13 13 .formCointainer { 14 14 width: 400px; 15 } 16 17 .shipPC { 18 display: flex; 19 flex-direction: column; 20 justify-content: center; 21 align-items: center; 22 } 23 24 .shipPC .checkout-steps { 25 width: 70%; 15 26 } 16 27 … … 32 43 } 33 44 } 45 46 @media only screen and (max-width: 559px) { 47 .shipPC .checkout-steps { 48 width: 100%; 49 } 50 } 51 52 @media only screen and (max-width: 331px) { 53 .shipPC .checkout-steps { 54 display: none; 55 } 56 }
Note:
See TracChangeset
for help on using the changeset viewer.