diff --git a/Lab5/data.json b/Lab5/data.json index 9aaa2e5..f7f49a3 100644 --- a/Lab5/data.json +++ b/Lab5/data.json @@ -5,6 +5,26 @@ "name": "Новость" } ], + "users": [ + { + "id": 1, + "login": "user1", + "password": "password1", + "status": "user" + }, + { + "id": 2, + "login": "user2", + "password": "password2", + "status": "admin" + }, + { + "id": 3, + "login": "user3", + "password": "password3", + "status": "user" + } + ], "lines": [ { "typeId": "1", @@ -29,14 +49,6 @@ "sum": "14.12.2023", "image": "", "id": 12 - }, - { - "typeId": "1", - "price": "jhkh", - "count": "kjh", - "sum": "14.12.2023", - "image": "", - "id": 13 } ] } \ No newline at end of file diff --git a/Lab5/package-lock.json b/Lab5/package-lock.json index 879fe73..5b30a01 100644 --- a/Lab5/package-lock.json +++ b/Lab5/package-lock.json @@ -8,15 +8,19 @@ "name": "lec4", "version": "0.0.0", "dependencies": { - "axios": "^1.6.1", + "axios": "^1.6.2", "bootstrap": "^5.3.2", + "fs": "^0.0.1-security", "prop-types": "^15.8.1", "react": "^18.2.0", "react-bootstrap": "^2.9.1", "react-bootstrap-icons": "^1.10.3", "react-dom": "^18.2.0", + "react-hook-form": "^7.49.2", "react-hot-toast": "^2.4.1", - "react-router-dom": "^6.18.0" + "react-redux": "^9.0.4", + "react-router-dom": "^6.21.0", + "redux": "^5.0.0" }, "devDependencies": { "@types/react": "^18.2.15", @@ -956,9 +960,9 @@ } }, "node_modules/@remix-run/router": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.11.0.tgz", - "integrity": "sha512-BHdhcWgeiudl91HvVa2wxqZjSHbheSgIiDvxrF1VjFzBzpTtuDPkOdOi3Iqvc08kXtFkLjhbS+ML9aM8mJS+wQ==", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.14.0.tgz", + "integrity": "sha512-WOHih+ClN7N8oHk9N4JUiMxQJmRVaOxcg8w7F/oHUXzJt920ekASLI/7cYX8XkntDWRhLZtsk6LbGrkgOAvi5A==", "engines": { "node": ">=14.0.0" } @@ -1094,6 +1098,11 @@ "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.6.tgz", "integrity": "sha512-Vlktnchmkylvc9SnwwwozTv04L/e1NykF5vgoQ0XTmI8DD+wxfjQuHuvHS3p0r2jz2x2ghPs2h1FVeDirIteWA==" }, + "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/warning": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.3.tgz", @@ -1355,9 +1364,9 @@ } }, "node_modules/axios": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.1.tgz", - "integrity": "sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -2849,6 +2858,11 @@ "node": ">= 0.6" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4750,6 +4764,22 @@ "react": "^18.2.0" } }, + "node_modules/react-hook-form": { + "version": "7.49.2", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.49.2.tgz", + "integrity": "sha512-TZcnSc17+LPPVpMRIDNVITY6w20deMdNi6iehTFLV1x8SqThXGwu93HjlUVU09pzFgZH7qZOvLMM7UYf2ShAHA==", + "engines": { + "node": ">=18", + "pnpm": "8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-hook-form" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18" + } + }, "node_modules/react-hot-toast": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz", @@ -4775,6 +4805,32 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "node_modules/react-redux": { + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.0.4.tgz", + "integrity": "sha512-9J1xh8sWO0vYq2sCxK2My/QO7MzUMRi3rpiILP/+tDr8krBHixC6JMM17fMK88+Oh3e4Ae6/sHIhNBgkUivwFA==", + "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.14.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", @@ -4785,11 +4841,11 @@ } }, "node_modules/react-router": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.18.0.tgz", - "integrity": "sha512-vk2y7Dsy8wI02eRRaRmOs9g2o+aE72YCx5q9VasT1N9v+lrdB79tIqrjMfByHiY5+6aYkH2rUa5X839nwWGPDg==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.21.0.tgz", + "integrity": "sha512-hGZ0HXbwz3zw52pLZV3j3+ec+m/PQ9cTpBvqjFQmy2XVUWGn5MD+31oXHb6dVTxYzmAeaiUBYjkoNz66n3RGCg==", "dependencies": { - "@remix-run/router": "1.11.0" + "@remix-run/router": "1.14.0" }, "engines": { "node": ">=14.0.0" @@ -4799,12 +4855,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.18.0.tgz", - "integrity": "sha512-Ubrue4+Ercc/BoDkFQfc6og5zRQ4A8YxSO3Knsne+eRbZ+IepAsK249XBH/XaFuOYOYr3L3r13CXTLvYt5JDjw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.21.0.tgz", + "integrity": "sha512-1dUdVj3cwc1npzJaf23gulB562ESNvxf7E4x8upNJycqyUm5BRRZ6dd3LrlzhtLaMrwOCO8R0zoiYxdaJx4LlQ==", "dependencies": { - "@remix-run/router": "1.11.0", - "react-router": "6.18.0" + "@remix-run/router": "1.14.0", + "react-router": "6.21.0" }, "engines": { "node": ">=14.0.0" @@ -4843,6 +4899,11 @@ "node": ">=4" } }, + "node_modules/redux": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.0.tgz", + "integrity": "sha512-blLIYmYetpZMET6Q6uCY7Jtl/Im5OBldy+vNPauA8vvsdqyt66oep4EUpAMWNHauTC6xa9JuRPhRB72rY82QGA==" + }, "node_modules/reflect.getprototypeof": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz", @@ -5640,6 +5701,14 @@ "punycode": "^2.1.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/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", diff --git a/Lab5/package.json b/Lab5/package.json index 5023b33..62bc9cf 100644 --- a/Lab5/package.json +++ b/Lab5/package.json @@ -11,15 +11,19 @@ "prod": "npm-run-all lint 'vite build' --parallel rest 'vite preview'" }, "dependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-router-dom": "^6.18.0", - "react-hot-toast": "^2.4.1", - "axios": "^1.6.1", + "axios": "^1.6.2", "bootstrap": "^5.3.2", + "fs": "^0.0.1-security", + "prop-types": "^15.8.1", + "react": "^18.2.0", "react-bootstrap": "^2.9.1", "react-bootstrap-icons": "^1.10.3", - "prop-types": "^15.8.1" + "react-dom": "^18.2.0", + "react-hook-form": "^7.49.2", + "react-hot-toast": "^2.4.1", + "react-redux": "^9.0.4", + "react-router-dom": "^6.21.0", + "redux": "^5.0.0" }, "devDependencies": { "@types/react": "^18.2.15", @@ -35,4 +39,4 @@ "npm-run-all": "^4.1.5", "vite": "^4.4.5" } -} \ No newline at end of file +} diff --git a/Lab5/src/App.jsx b/Lab5/src/App.jsx index 9548590..be5c76a 100644 --- a/Lab5/src/App.jsx +++ b/Lab5/src/App.jsx @@ -2,18 +2,31 @@ import PropTypes from 'prop-types'; import { Container } from 'react-bootstrap'; import { Toaster } from 'react-hot-toast'; import { Outlet } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import React, { useEffect } from 'react'; import Footer from './components/footer/Footer.jsx'; import Navigation from './components/navigation/Navigation.jsx'; +import { BrowserRouter as Router } from 'react-router-dom'; + +import store from './Reducer/store'; // Путь к вашему store const App = ({ routes }) => { + useEffect(() => { + const storedUser = localStorage.getItem('user'); + if (storedUser) { + store.dispatch({ type: 'SET_USER', payload: JSON.parse(storedUser) }); + } + }, []); return ( <> +