Vladislav342 пре 2 година
родитељ
комит
fbe7bd8f23
41 измењених фајлова са 31216 додато и 0 уклоњено
  1. 23 0
      React/CodePen/.gitignore
  2. 70 0
      React/CodePen/README.md
  3. 30405 0
      React/CodePen/package-lock.json
  4. 43 0
      React/CodePen/package.json
  5. BIN
      React/CodePen/public/favicon.ico
  6. 43 0
      React/CodePen/public/index.html
  7. BIN
      React/CodePen/public/logo192.png
  8. BIN
      React/CodePen/public/logo512.png
  9. 25 0
      React/CodePen/public/manifest.json
  10. 3 0
      React/CodePen/public/robots.txt
  11. 58 0
      React/CodePen/src/App.js
  12. 1 0
      React/CodePen/src/App.scss
  13. 8 0
      React/CodePen/src/App.test.js
  14. 1 0
      React/CodePen/src/actions/actionAuthLogin.js
  15. 1 0
      React/CodePen/src/actions/actionAuthLogout.js
  16. 22 0
      React/CodePen/src/actions/actionFullLogin.js
  17. 12 0
      React/CodePen/src/actions/actionFullRegister.js
  18. 1 0
      React/CodePen/src/actions/actionPending.js
  19. 16 0
      React/CodePen/src/actions/actionPromise.js
  20. 7 0
      React/CodePen/src/actions/actionRegister.js
  21. 1 0
      React/CodePen/src/actions/actionRejected.js
  22. 1 0
      React/CodePen/src/actions/actionResolved.js
  23. 17 0
      React/CodePen/src/actions/gql.js
  24. 27 0
      React/CodePen/src/actions/gqlRequests.js
  25. 10 0
      React/CodePen/src/actions/jwtDecode.js
  26. 14 0
      React/CodePen/src/components/header.js
  27. 25 0
      React/CodePen/src/components/privateRout.js
  28. 39 0
      React/CodePen/src/components/routes.js
  29. 13 0
      React/CodePen/src/index.css
  30. 17 0
      React/CodePen/src/index.js
  31. BIN
      React/CodePen/src/logo.png
  32. 1 0
      React/CodePen/src/logo.svg
  33. 29 0
      React/CodePen/src/pages/cabinet.js
  34. 69 0
      React/CodePen/src/pages/login.js
  35. 12 0
      React/CodePen/src/pages/mainPage.js
  36. 81 0
      React/CodePen/src/pages/reg.js
  37. 37 0
      React/CodePen/src/reducers/authReducer.js
  38. 11 0
      React/CodePen/src/reducers/promiseRedicer.js
  39. 55 0
      React/CodePen/src/reducers/store.js
  40. 13 0
      React/CodePen/src/reportWebVitals.js
  41. 5 0
      React/CodePen/src/setupTests.js

+ 23 - 0
React/CodePen/.gitignore

@@ -0,0 +1,23 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.js
+
+# testing
+/coverage
+
+# production
+/build
+
+# misc
+.DS_Store
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*

+ 70 - 0
React/CodePen/README.md

@@ -0,0 +1,70 @@
+# Getting Started with Create React App
+
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
+
+## Available Scripts
+
+In the project directory, you can run:
+
+### `npm start`
+
+Runs the app in the development mode.\
+Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
+
+The page will reload when you make changes.\
+You may also see any lint errors in the console.
+
+### `npm test`
+
+Launches the test runner in the interactive watch mode.\
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
+
+### `npm run build`
+
+Builds the app for production to the `build` folder.\
+It correctly bundles React in production mode and optimizes the build for the best performance.
+
+The build is minified and the filenames include the hashes.\
+Your app is ready to be deployed!
+
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
+
+### `npm run eject`
+
+**Note: this is a one-way operation. Once you `eject`, you can't go back!**
+
+If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
+
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
+
+You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
+
+## Learn More
+
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
+
+To learn React, check out the [React documentation](https://reactjs.org/).
+
+### Code Splitting
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
+
+### Analyzing the Bundle Size
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
+
+### Making a Progressive Web App
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
+
+### Advanced Configuration
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
+
+### Deployment
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
+
+### `npm run build` fails to minify
+
+This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

Разлика између датотеке није приказан због своје велике величине
+ 30405 - 0
React/CodePen/package-lock.json


+ 43 - 0
React/CodePen/package.json

@@ -0,0 +1,43 @@
+{
+  "name": "firstproj",
+  "version": "0.1.0",
+  "private": true,
+  "dependencies": {
+    "@testing-library/jest-dom": "^5.16.1",
+    "@testing-library/react": "^12.1.2",
+    "@testing-library/user-event": "^13.5.0",
+    "node-sass": "^7.0.0",
+    "react": "^17.0.2",
+    "react-dom": "^17.0.2",
+    "react-redux": "^7.2.6",
+    "react-router-dom": "^5.3.0",
+    "react-scripts": "5.0.0",
+    "redux": "^4.1.2",
+    "redux-thunk": "^2.4.1",
+    "web-vitals": "^2.1.2"
+  },
+  "scripts": {
+    "start": "react-scripts start",
+    "build": "react-scripts build",
+    "test": "react-scripts test",
+    "eject": "react-scripts eject"
+  },
+  "eslintConfig": {
+    "extends": [
+      "react-app",
+      "react-app/jest"
+    ]
+  },
+  "browserslist": {
+    "production": [
+      ">0.2%",
+      "not dead",
+      "not op_mini all"
+    ],
+    "development": [
+      "last 1 chrome version",
+      "last 1 firefox version",
+      "last 1 safari version"
+    ]
+  }
+}

BIN
React/CodePen/public/favicon.ico


+ 43 - 0
React/CodePen/public/index.html

@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8" />
+    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1" />
+    <meta name="theme-color" content="#000000" />
+    <meta
+      name="description"
+      content="Web site created using create-react-app"
+    />
+    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
+    <!--
+      manifest.json provides metadata used when your web app is installed on a
+      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
+    -->
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+    <!--
+      Notice the use of %PUBLIC_URL% in the tags above.
+      It will be replaced with the URL of the `public` folder during the build.
+      Only files inside the `public` folder can be referenced from the HTML.
+
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
+      work correctly both with client-side routing and a non-root public URL.
+      Learn how to configure a non-root public URL by running `npm run build`.
+    -->
+    <title>React App</title>
+  </head>
+  <body>
+    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <div id="root"></div>
+    <!--
+      This HTML file is a template.
+      If you open it directly in the browser, you will see an empty page.
+
+      You can add webfonts, meta tags, or analytics to this file.
+      The build step will place the bundled scripts into the <body> tag.
+
+      To begin the development, run `npm start` or `yarn start`.
+      To create a production bundle, use `npm run build` or `yarn build`.
+    -->
+  </body>
+</html>

BIN
React/CodePen/public/logo192.png


BIN
React/CodePen/public/logo512.png


+ 25 - 0
React/CodePen/public/manifest.json

@@ -0,0 +1,25 @@
+{
+  "short_name": "React App",
+  "name": "Create React App Sample",
+  "icons": [
+    {
+      "src": "favicon.ico",
+      "sizes": "64x64 32x32 24x24 16x16",
+      "type": "image/x-icon"
+    },
+    {
+      "src": "logo192.png",
+      "type": "image/png",
+      "sizes": "192x192"
+    },
+    {
+      "src": "logo512.png",
+      "type": "image/png",
+      "sizes": "512x512"
+    }
+  ],
+  "start_url": ".",
+  "display": "standalone",
+  "theme_color": "#000000",
+  "background_color": "#ffffff"
+}

+ 3 - 0
React/CodePen/public/robots.txt

@@ -0,0 +1,3 @@
+# https://www.robotstxt.org/robotstxt.html
+User-agent: *
+Disallow:

+ 58 - 0
React/CodePen/src/App.js

@@ -0,0 +1,58 @@
+import './App.scss';
+import {Provider, connect} from 'react-redux';
+import {createStore, combineReducers, applyMiddleware} from 'redux';
+import thunk from 'redux-thunk';
+import {useEffect, useState, useRef} from "react";
+import React, {useCallback} from 'react';
+import {Router, Route, Link, Redirect, Switch} from 'react-router-dom';
+import createHistory from "history/createBrowserHistory";
+import {store} from "./reducers/store";
+import Routes from "./components/routes";
+
+//import {useDropzone} from 'react-dropzone'
+
+/*const actionAboutMe = () => {
+	async(dispatch, getState)=>{
+		
+	}
+}
+
+const actioUploadFile = file =>{
+	return actionPromise('uploadFile', fetch().then(res=>res.json))
+}
+
+const actionSetAvatar = file =>{
+	async(dispatch, getState) => {
+		
+	}
+}*/
+
+
+//const store = createStore(combineReducers({promise: promiseReducer, auth: authReducer}),applyMiddleware(thunk))
+
+//store.subscribe(()=>console.log(store.getState()))
+
+//store.dispatch(actionCatById('5dc49f4d5df9d670df48cc64'))
+
+//store.dispatch(actionFullLogin('vladBraun4','123'))
+
+
+
+
+
+
+const history = createHistory();
+
+function App() {
+  return (
+  		<Router history={history}>
+  			<Provider store={store} >
+	      		<Routes />
+	    	</Provider>
+	    </Router>
+  );
+}
+
+export default App;
+
+

+ 1 - 0
React/CodePen/src/App.scss

@@ -0,0 +1 @@
+

+ 8 - 0
React/CodePen/src/App.test.js

@@ -0,0 +1,8 @@
+import { render, screen } from '@testing-library/react';
+import App from './App';
+
+test('renders learn react link', () => {
+  render(<App />);
+  const linkElement = screen.getByText(/learn react/i);
+  expect(linkElement).toBeInTheDocument();
+});

+ 1 - 0
React/CodePen/src/actions/actionAuthLogin.js

@@ -0,0 +1 @@
+export const actionAuthLogin = token => ({ type: 'AUTH_LOGIN', token })

+ 1 - 0
React/CodePen/src/actions/actionAuthLogout.js

@@ -0,0 +1 @@
+export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })

+ 22 - 0
React/CodePen/src/actions/actionFullLogin.js

@@ -0,0 +1,22 @@
+import {actionPromise} from "./actionPromise";
+import {actionAuthLogin} from "./actionAuthLogin";
+import {log} from "./gqlRequests";
+
+export const actionFullLogin = (login, password) => 
+	async (dispatch) => {
+  		let result = await dispatch(actionPromise("login", log(login, password)));
+  		if (result?.data?.login !== null) {
+    		dispatch(actionAuthLogin(result.data.login));
+  		} else {
+    		alert("Такого пользователя не существует!");
+  		}
+	};
+
+/*const actionFullLogin = (login,password) =>
+	async function i(dispatch){
+		let token = await dispatch(actionLogin(login,password));
+		console.log(token);
+		if(token){
+			dispatch(actionAuthLogin(token));
+		}
+	}*/

+ 12 - 0
React/CodePen/src/actions/actionFullRegister.js

@@ -0,0 +1,12 @@
+import { actionRegister } from "./actionRegister";
+import { actionFullLogin } from "./actionFullLogin";
+
+export const actionFullRegister = (login, password) => 
+async (dispatch) => {
+    let result = await dispatch(actionRegister(login, password));
+    if (result?.data?.createUser !== null) {
+      await dispatch(actionFullLogin(login, password));
+    } else {
+      alert("Такой пользователь уже есть!");
+    }
+  };

+ 1 - 0
React/CodePen/src/actions/actionPending.js

@@ -0,0 +1 @@
+export const actionPending = name => ({ type: 'PROMISE', status: 'PENDING', name })

+ 16 - 0
React/CodePen/src/actions/actionPromise.js

@@ -0,0 +1,16 @@
+import {actionPending} from "./actionPending";
+import {actionResolved} from "./actionResolved";
+import {actionRejected} from "./actionRejected";
+
+export const actionPromise = (name, promise) =>
+    async dispatch => {
+        dispatch(actionPending(name))
+        try {
+            let data = await promise
+            dispatch(actionResolved(name, data))
+            return data
+        }
+        catch (error) {
+            dispatch(actionRejected(name, error))
+        }
+    }

+ 7 - 0
React/CodePen/src/actions/actionRegister.js

@@ -0,0 +1,7 @@
+import {reg} from "./gqlRequests";
+import {actionPromise} from "./actionPromise";
+
+export const actionRegister = (login,password) => 
+	async (dispatch) =>{
+		return await dispatch(actionPromise('register',reg(login,password)));
+	}

+ 1 - 0
React/CodePen/src/actions/actionRejected.js

@@ -0,0 +1 @@
+export const actionRejected = (name, error) => ({ type: 'PROMISE', status: 'REJECTED', name, error })

+ 1 - 0
React/CodePen/src/actions/actionResolved.js

@@ -0,0 +1 @@
+export const actionResolved = (name, payload) => ({ type: 'PROMISE', status: 'RESOLVED', name, payload })

+ 17 - 0
React/CodePen/src/actions/gql.js

@@ -0,0 +1,17 @@
+const getGQL = url =>
+    async (query, variables = {}) => {
+        let obj = await fetch(url, {
+            method: 'POST',
+            headers: {
+                "Content-Type": "application/json",
+                Authorization: localStorage.authToken ? 'Bearer ' + localStorage.authToken : {},
+            },
+            body: JSON.stringify({ query, variables })
+        })
+        let a = await obj.json()
+        if (!a.data && a.errors)
+            throw new Error(JSON.stringify(a.errors))
+        return a.data[Object.keys(a.data)[0]]
+    }
+const backURL = 'http://snippet.asmer.fs.a-level.com.ua'
+export const gql = getGQL(backURL + '/graphql');

+ 27 - 0
React/CodePen/src/actions/gqlRequests.js

@@ -0,0 +1,27 @@
+import {gql} from "./gql";
+
+export const reg = async (login, password) => {
+    let query = `mutation reg($l:String! , $p:String!) {
+        createUser(login:$l,password:$p){
+    _id login
+  }
+  }`;
+    let qVariables = {
+      l: login,
+      p: password,
+    };
+    let result = await gql(query, qVariables);
+    return result;
+  };
+
+  export const log = async (login, password) => {
+    let query = ` query log($l:String!,$p:String!) {
+        login(login:$l,password:$p)
+      }`;
+    let qVariables = {
+      l: login,
+      p: password,
+    };
+    let result = await gql(query, qVariables);
+    return result;
+  };

+ 10 - 0
React/CodePen/src/actions/jwtDecode.js

@@ -0,0 +1,10 @@
+const jwtDecode = token => {
+    try {
+        let arrToken = token.split('.')
+        let base64Token = atob(arrToken[1])
+        return JSON.parse(base64Token)
+    }
+    catch (e) {
+        console.log('Лажа, Бро ' + e);
+    }
+}

+ 14 - 0
React/CodePen/src/components/header.js

@@ -0,0 +1,14 @@
+import React from "react";
+import { connect } from "react-redux";
+import { useState } from "react";
+
+const Header = ({onSearch}) => {
+  	const [request, setRequest] = useState('');
+  	return (
+    	<nav className="">
+    		<p>hello</p>
+    	</nav>
+  	);
+};
+
+export default Header;

+ 25 - 0
React/CodePen/src/components/privateRout.js

@@ -0,0 +1,25 @@
+import React from "react"
+import { connect } from "react-redux"
+import { Redirect,Route } from "react-router"
+
+const PrivateRoute = ({component,roles,auth, ...originProps}) => {
+    const PageWrapper = (pageProps) => {
+      const OriginalPage = component
+      if(roles.includes('unknown')){
+        return <OriginalPage {...pageProps} />
+      }
+      if(auth === undefined) {
+        return <Redirect to='/login' />
+      }
+      let userL = roles.filter(item => auth.includes(item))
+      if(userL){
+        return <OriginalPage {...pageProps} />
+      }
+      return <Redirect to='/login' />
+    }
+    return (
+      <Route component={PageWrapper} {...originProps} />
+    )
+  }
+const ConnectedPrivateRoute = connect(state => ({auth: state?.auth?.token}))(PrivateRoute)
+export default ConnectedPrivateRoute

+ 39 - 0
React/CodePen/src/components/routes.js

@@ -0,0 +1,39 @@
+import Home from "../pages/mainPage";
+import LogForm from "../pages/login";
+import RegForm from "../pages/reg";
+import React from "react";
+import createHistory from "history/createBrowserHistory";
+import { connect } from "react-redux";
+import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
+import ConnectedPrivateRoute from "./privateRout";
+import { Redirect } from "react-router";
+import {useEffect, useState, useRef} from "react";
+
+const LoginForm = ({onLogin}) =>{
+  const [login, setLogin] = useState(''); //braunvlad4
+  const [pass, setPass] = useState('');   //123
+  return( 
+    <div className='LoginForm'>
+      <input value={login} style={{backgroundColor: login.length>0 ? 'green' : 'red'}} 
+            placeholder='your login' onChange={e=>setLogin(e.target.value)} />
+      <input value={pass} style={{backgroundColor: pass.length>0 ? 'green' : 'red'}} 
+            placeholder='your pass' onChange={e=>setPass(e.target.value)} />
+      <button onClick={()=>onLogin(login,pass)} disabled={(login.length!==0 && pass.length!==0)?false:true }>Send</button>
+    </div>
+  )
+}
+
+const Routes = ({ isAuth }) => {
+  return (
+    <div className="App">
+      <div className="contentDiv">
+          <LoginForm onLogin={(l,p)=>console.log(l,p)} />
+          <ConnectedPrivateRoute exact path="/" roles = {['user']} component={Home} />
+          <ConnectedPrivateRoute path="/login" roles = {['unknown']} component={LogForm} /> 
+          <ConnectedPrivateRoute path="/registration" roles = {['unknown']} component={RegForm} />
+      </div>
+    </div>
+  );
+};
+
+export default Routes

+ 13 - 0
React/CodePen/src/index.css

@@ -0,0 +1,13 @@
+body {
+  margin: 0;
+  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+    sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+code {
+  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
+    monospace;
+}

+ 17 - 0
React/CodePen/src/index.js

@@ -0,0 +1,17 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+import './index.css';
+import App from './App';
+import reportWebVitals from './reportWebVitals';
+
+ReactDOM.render(
+  <React.StrictMode>
+    <App />
+  </React.StrictMode>,
+  document.getElementById('root')
+);
+
+// If you want to start measuring performance in your app, pass a function
+// to log results (for example: reportWebVitals(console.log))
+// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
+reportWebVitals();

BIN
React/CodePen/src/logo.png


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
React/CodePen/src/logo.svg


+ 29 - 0
React/CodePen/src/pages/cabinet.js

@@ -0,0 +1,29 @@
+import { actionAuthLogout } from "../actions/actionAuthLogout";
+import React from "react";
+import { connect } from "react-redux";
+
+const Cabinet = ({ onLogOut }) => {
+  return (
+    <>
+      <div className="" >
+        <div className="card" style = {{boxShadow:'7px 5px 10px 2px rgba(34, 60, 80, 0.2)'}}>
+          <div className="">
+            <a href="/projects">
+              <button type="button" className="">My Projects</button>
+            </a>
+            <div className="">
+              <a href="/">
+                <button className=" ">Main Page</button>
+              </a>
+            </div>
+            <button className="" onClick={() => onLogOut()}>Log out</button>
+          </div>
+        </div>
+      </div>
+    </>
+  );
+};
+
+const ConnectCabinet = connect(null, { onLogOut: actionAuthLogout })(Cabinet);
+
+export default ConnectCabinet;

+ 69 - 0
React/CodePen/src/pages/login.js

@@ -0,0 +1,69 @@
+import { actionFullLogin } from "../actions/actionFullLogin";
+import { connect } from "react-redux";
+import { useState } from "react";
+import { Redirect } from "react-router";
+
+const Log = ({ onLog, LogedIn }) => {
+  const [login, setLogin] = useState("");
+  const [password, setPassword] = useState("");
+  return LogedIn ? (
+    <Redirect to ="/"/>
+  ) : (
+    <>
+      <div className="container" >
+        <div id="loginbox" style={{ marginTop: "120px"}} className="">
+          <div className="" style = {{boxShadow:'0px 5px 10px 2px rgba(34, 60, 80, 0.5)'}}>
+            <div className="">
+              <div className="">Login</div>
+            </div>
+
+            <div style={{ "padding-top": "30px" }} className="">
+              <div style={{ display: "none" }} id="" className=""></div>
+
+              <form id="loginform" className="form-horizontal" role="form">
+                <div style={{ "margin-bottom": "25px" }} className="input-group">
+                  <span className="">
+                    <i className=""></i>
+                  </span>
+                  <input id="login-username" type="text" className="form-control" 
+                  		name="username" value={login} placeholder="Login"
+                    	onChange={(e) => setLogin(e.target.value) && <Redirect to ="/"/>}	
+                  />
+                </div>
+                <div style={{ "margin-bottom": "25px" }} className="input-group">
+                  <span className="">
+                    <i className=""></i>
+                  </span>
+                  <input id="login-password" type="password" className="form-control"
+                    name="password" placeholder="Password" value={password}
+                 	onChange={(e) => setPassword(e.target.value)}
+                  />
+                </div>
+                <div style={{ "margin-top": "10px" }} className="form-group">
+                  <div className="">
+                    <a id="btn-login" href="#" className="" onClick={() =>onLog(login, password)}>
+                      Sign In
+                    </a>
+                  </div>
+                </div>
+                <div className="form-group">
+                  <div className="">
+                    <div style={{"border-top": "1px solid#888","padding-top": "15px","font-size": "85%",}}>
+                      <a href="/registration">Sign Up Here</a>
+                    </div>
+                  </div>
+                </div>
+              </form>
+            </div>
+          </div>
+        </div>
+      </div>
+    </>
+  );
+};
+
+const LogForm = connect((state) => ({ LogedIn: state?.auth?.token }), {
+  onLog: actionFullLogin,
+})(Log);
+
+export default LogForm

+ 12 - 0
React/CodePen/src/pages/mainPage.js

@@ -0,0 +1,12 @@
+import Header from "../components/header";
+import React from "react";
+
+const Main = () =>{
+	return (
+		<div>
+			<Header />
+		</div>
+	)
+}
+
+export default Main;

+ 81 - 0
React/CodePen/src/pages/reg.js

@@ -0,0 +1,81 @@
+import { connect } from "react-redux";
+import { useState } from "react";
+import { actionFullRegister } from "../actions/actionFullRegister";
+import { Redirect } from "react-router";
+
+const Reg = ({ onReg, LogedIn }) => {
+  const [login, setLogin] = useState("");
+  const [password, setPassword] = useState("");
+  return (
+    <>
+      <div className="container">
+        <div
+          id="loginbox"
+          style={{ marginTop: "120px" }}
+          className=""
+        >
+          <div className="" style = {{boxShadow:'0px 5px 10px 2px rgba(34, 60, 80, 0.5)'}}>
+            <div className="" style = {{backgroundColor:'#ADD8E6' }}>
+              <div className="" >Registration</div>
+            </div>
+
+            <div style={{ "padding-top": "30px" }} className="panel-body">
+              <div
+                style={{ display: "none" }}
+                id=""
+                className=""
+              ></div>
+
+              <form id="loginform" className="" role="form">
+                <div style={{ "margin-bottom": "25px" }}>
+                  <span className="">
+                    <i className=""></i>
+                  </span>
+                  <input id="login-username" type="text" className="form-control" name="username"
+                    value={login} onChange={(e) => setLogin(e.target.value)} placeholder="Login"/>
+                </div>
+
+                <div style={{ "margin-bottom": "25px" }} className="">
+                  <span className="">
+                    <i className=""></i>
+                  </span>
+                  <input id="login-password" type="password" className="form-control"
+                    name="password" placeholder="Password" value={password}
+                    onChange={(e) => setPassword(e.target.value)}
+                  />
+                </div>
+                <div style={{ "margin-top": "10px" }} className="form-group">
+                  <div className="">
+                    <a id="btn-login" href="#" className="" onClick={() => onReg(login, password)}>
+                      Sign up{" "}
+                    </a>
+                  </div>
+                </div>
+
+                <div className="form-group">
+                  <div className="">
+                    <div
+                      style={{
+                        "border-top": "1px solid#888",
+                        "padding-top": "15px",
+                        "font-size": "85%",
+                      }}
+                    >
+                      <a href="/login">Login Here</a>
+                    </div>
+                  </div>
+                </div>
+              </form>
+            </div>
+          </div>
+        </div>
+      </div>
+    </>
+  );
+};
+
+const RegForm = connect((state) => ({ LogedIn: state?.auth?.token }), {
+  onReg: actionFullRegister,
+})(Reg);
+
+export default RegForm;

+ 37 - 0
React/CodePen/src/reducers/authReducer.js

@@ -0,0 +1,37 @@
+const jwtDecode = token => {
+    try {
+        let arrToken = token.split('.')
+        let base64Token = atob(arrToken[1])
+        return JSON.parse(base64Token)
+    }
+    catch (e) {
+        console.log('Лажа, Бро ' + e);
+    }
+}
+
+function authReducer(state, { type, token }) {
+    if (!state) {
+        if (localStorage.authToken) {
+            type = 'AUTH_LOGIN'
+            token = localStorage.authToken
+        } else state = {}
+    }
+    if (type === 'AUTH_LOGIN') {
+        localStorage.setItem('authToken', token)
+        let payload = jwtDecode(token)
+        if (typeof payload === 'object') {
+            return {
+                ...state,
+                token,
+                payload
+            }
+        } else return state
+    }
+    if (type === 'AUTH_LOGOUT') {
+        localStorage.removeItem('authToken')
+        return {}
+    }
+    return state
+}
+
+//export default authReducer

+ 11 - 0
React/CodePen/src/reducers/promiseRedicer.js

@@ -0,0 +1,11 @@
+function promiseReducer(state = {}, { type, status, payload, error, name }) {
+    if (type === 'PROMISE') {
+        return {
+            ...state,
+            [name]: { status, payload, error }
+        }
+    }
+    return state;
+}
+
+//export default promiseReducer;

+ 55 - 0
React/CodePen/src/reducers/store.js

@@ -0,0 +1,55 @@
+//import {promiseReducer} from "./promiseReducer";
+//import {authReducer} from "./authReducer";
+import {createStore, combineReducers, applyMiddleware} from "redux";
+import thunk from "redux-thunk";
+
+const jwtDecode = token => {
+    try {
+        let arrToken = token.split('.')
+        let base64Token = atob(arrToken[1])
+        return JSON.parse(base64Token)
+    }
+    catch (e) {
+        console.log('Лажа, Бро ' + e);
+    }
+}
+
+function authReducer(state, { type, token }) {
+    if (!state) {
+        if (localStorage.authToken) {
+            type = 'AUTH_LOGIN'
+            token = localStorage.authToken
+        } else state = {}
+    }
+    if (type === 'AUTH_LOGIN') {
+        localStorage.setItem('authToken', token)
+        let payload = jwtDecode(token)
+        if (typeof payload === 'object') {
+            return {
+                ...state,
+                token,
+                payload
+            }
+        } else return state
+    }
+    if (type === 'AUTH_LOGOUT') {
+        localStorage.removeItem('authToken')
+        return {}
+    }
+    return state
+}
+
+function promiseReducer(state = {}, { type, status, payload, error, name }) {
+    if (type === 'PROMISE') {
+        return {
+            ...state,
+            [name]: { status, payload, error }
+        }
+    }
+    return state;
+}
+
+export const store = createStore(
+	combineReducers({promise: promiseReducer, auth: authReducer}),
+	applyMiddleware(thunk)
+);

+ 13 - 0
React/CodePen/src/reportWebVitals.js

@@ -0,0 +1,13 @@
+const reportWebVitals = onPerfEntry => {
+  if (onPerfEntry && onPerfEntry instanceof Function) {
+    import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
+      getCLS(onPerfEntry);
+      getFID(onPerfEntry);
+      getFCP(onPerfEntry);
+      getLCP(onPerfEntry);
+      getTTFB(onPerfEntry);
+    });
+  }
+};
+
+export default reportWebVitals;

+ 5 - 0
React/CodePen/src/setupTests.js

@@ -0,0 +1,5 @@
+// jest-dom adds custom jest matchers for asserting on DOM nodes.
+// allows you to do things like:
+// expect(element).toHaveTextContent(/react/i)
+// learn more: https://github.com/testing-library/jest-dom
+import '@testing-library/jest-dom';