From d4d51941d7a80e0377a61689b4530ff1f2757c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Thu, 8 Apr 2021 12:29:19 +0500 Subject: [PATCH] maket sage0 --- package-lock.json | 65 ++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/App.js | 2 +- src/context/Context.js | 5 ++++ src/pages/Login.jsx | 4 +-- src/pages/Main.jsx | 7 +++-- src/pages/Well.jsx | 5 +++- src/pages/Wells.jsx | 5 ++-- 8 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 src/context/Context.js diff --git a/package-lock.json b/package-lock.json index c998f59..667a657 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1873,6 +1873,28 @@ "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", "dev": true }, + "@microsoft/signalr": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-5.0.5.tgz", + "integrity": "sha512-1aIr9LfuVHkJA6YHvJ9+V2GPUOlVtH94babg4LmBHk3tO7bI9YDHz3axYsp/GI5MVMqCKg/7BzEorr6zs/w2XA==", + "requires": { + "abort-controller": "^3.0.0", + "eventsource": "^1.0.7", + "fetch-cookie": "^0.7.3", + "node-fetch": "^2.6.0", + "ws": "^6.0.0" + }, + "dependencies": { + "ws": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, "@nodelib/fs.scandir": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", @@ -2768,6 +2790,14 @@ "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==" }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "requires": { + "event-target-shim": "^5.0.0" + } + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -5677,6 +5707,11 @@ "next-tick": "~1.0.0" } }, + "es6-denodeify": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-denodeify/-/es6-denodeify-0.1.5.tgz", + "integrity": "sha1-MdTV/pxVA+ElRgQ5MQ4WoqPznB8=" + }, "es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", @@ -6338,6 +6373,11 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, "eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -6687,6 +6727,26 @@ "bser": "2.1.1" } }, + "fetch-cookie": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.3.tgz", + "integrity": "sha512-rZPkLnI8x5V+zYAiz8QonAHsTb4BY+iFowFBI1RFn0zrO343AVp9X7/yUj/9wL6Ef/8fLls8b/vGtzUvmyAUGA==", + "requires": { + "es6-denodeify": "^0.1.1", + "tough-cookie": "^2.3.3" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } + } + }, "figgy-pudding": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.2.tgz", @@ -10814,6 +10874,11 @@ } } }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + }, "node-forge": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", diff --git a/package.json b/package.json index 13021bd..59ec63c 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@craco/craco": "^6.1.1", + "@microsoft/signalr": "^5.0.5", "@testing-library/jest-dom": "^5.11.10", "@testing-library/react": "^11.2.6", "@testing-library/user-event": "^12.8.3", diff --git a/src/App.js b/src/App.js index bd18221..fb162ae 100644 --- a/src/App.js +++ b/src/App.js @@ -21,7 +21,7 @@ function PrivateRoute({ children, ...rest }) { render={({ location }) => token ? (children) - : () + : () } /> ); diff --git a/src/context/Context.js b/src/context/Context.js new file mode 100644 index 0000000..ea1c502 --- /dev/null +++ b/src/context/Context.js @@ -0,0 +1,5 @@ +import {createContext} from 'react' + +const Context = createContext() + +export default Context \ No newline at end of file diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index d30b00a..efdb70b 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -27,7 +27,7 @@ export default function Login() { const logoIcon = АСБ - let handleSubmit = async (formData) =>{ + let handleLogin = async (formData) =>{ setLoader(true) try{ let user = await login(formData) @@ -44,7 +44,7 @@ export default function Login() { return (
-
+ diff --git a/src/pages/Main.jsx b/src/pages/Main.jsx index 5ca64af..bc5c657 100644 --- a/src/pages/Main.jsx +++ b/src/pages/Main.jsx @@ -4,6 +4,7 @@ import logo from '../images/logo_32.png' import { useState } from 'react' import { Switch, Route, Redirect, Link} from "react-router-dom" import Wells from './Wells' +import Well from './Well' import Files from './Files' const { Header, Content, Sider } = Layout @@ -12,7 +13,7 @@ export default function Main(){ const [sidebarVisible, setSidebarVisible] = useState(true) const login = localStorage['login'] - let handlerExit = ()=>{ + let handleLogout = () => { localStorage.removeItem('login') localStorage.removeItem('token') } @@ -23,7 +24,7 @@ export default function Main(){ @@ -55,7 +56,7 @@ export default function Main(){ - + diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx index d1c0119..4097e84 100644 --- a/src/pages/Well.jsx +++ b/src/pages/Well.jsx @@ -1,3 +1,6 @@ +import {useParams} from 'react-router-dom' + export default function Well(props){ - return(
Well id: {props.id}
) + let { id } = useParams(); + return(
Well id: {id}
) } \ No newline at end of file diff --git a/src/pages/Wells.jsx b/src/pages/Wells.jsx index 8136938..88bfb4f 100644 --- a/src/pages/Wells.jsx +++ b/src/pages/Wells.jsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { WellService, OpenAPI } from '../services/api' +import { WellService } from '../services/api' import Loader from '../components/Loader' import { Table } from 'antd'; import { useHistory } from 'react-router-dom' @@ -35,6 +35,7 @@ export default function Wells(props){ let updateWellsList = async () => { setLoader(true) try{ + setWells( await WellService.get()) } catch(e){ @@ -52,7 +53,7 @@ export default function Wells(props){ columns={columns} onRow={(record, rowIndex) => { return { - onClick: event => {history.push(`wells/${record.id}`)}, + onClick: event => {history.push(`well/${record.id}`)}, }; }}/> {loader&&}