Browse Source

first commit, add postEditor (edit title, text) and some components (user, createPost in progress) + actions

LenDoc 2 years ago
commit
1620d87ca0
22 changed files with 30110 additions and 0 deletions
  1. 23 0
      .gitignore
  2. 70 0
      README.md
  3. 29344 0
      package-lock.json
  4. 51 0
      package.json
  5. BIN
      public/favicon.ico
  6. 23 0
      public/index.html
  7. BIN
      public/logo192.png
  8. BIN
      public/logo512.png
  9. 25 0
      public/manifest.json
  10. 3 0
      public/robots.txt
  11. 304 0
      src/App.js
  12. 61 0
      src/App.scss
  13. 8 0
      src/App.test.js
  14. 109 0
      src/actions/index.js
  15. 13 0
      src/index.css
  16. 13 0
      src/index.js
  17. 1 0
      src/logo.svg
  18. BIN
      src/materials/user.png
  19. 44 0
      src/reducers/index.js
  20. 13 0
      src/reportWebVitals.js
  21. 5 0
      src/setupTests.js
  22. BIN
      src/user.png

+ 23 - 0
.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
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)

File diff suppressed because it is too large
+ 29344 - 0
package-lock.json


+ 51 - 0
package.json

@@ -0,0 +1,51 @@
+{
+  "name": "hipstagram",
+  "version": "0.1.0",
+  "private": true,
+  "dependencies": {
+    "@ant-design/icons": "^4.7.0",
+    "@testing-library/jest-dom": "^5.16.2",
+    "@testing-library/react": "^12.1.2",
+    "@testing-library/user-event": "^13.5.0",
+    "antd": "^4.18.6",
+    "antd-img-crop": "^4.1.0",
+    "array-move": "^4.0.0",
+    "react": "^17.0.2",
+    "react-dom": "^17.0.2",
+    "react-dropzone": "^12.0.2",
+    "react-redux": "^7.2.6",
+    "react-router-dom": "^5.3.0",
+    "react-scripts": "5.0.0",
+    "react-sortable-hoc": "^2.0.0",
+    "redux": "^4.1.2",
+    "redux-thunk": "^2.4.1",
+    "web-vitals": "^2.1.4"
+  },
+  "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"
+    ]
+  },
+  "devDependencies": {
+    "sass": "^1.49.7"
+  }
+}

BIN
public/favicon.ico


+ 23 - 0
public/index.html

@@ -0,0 +1,23 @@
+<!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" />
+  
+    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+    
+    <title>LenDocGram</title>
+  </head>
+  <body>
+    <noscript>You need to enable JavaScript to run this app.</noscript>
+    <div id="root"></div>
+   
+  </body>
+</html>

BIN
public/logo192.png


BIN
public/logo512.png


+ 25 - 0
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
public/robots.txt

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

+ 304 - 0
src/App.js

@@ -0,0 +1,304 @@
+import './App.scss'
+import { Provider, connect } from 'react-redux'
+import { Router, Route, Link, Redirect, Switch } from 'react-router-dom'
+import createHistory from 'history/createBrowserHistory'
+import React, { useMemo, useState, useEffect } from 'react'
+import { store } from './reducers'
+import { sortableContainer, sortableElement } from 'react-sortable-hoc'
+import { arrayMove, arrayMoveImmutable, arrayMoveMutable } from 'array-move'
+import { useDropzone } from 'react-dropzone'
+import 'antd/dist/antd.css' // or 'antd/dist/antd.less'
+import {
+  actionPromise,
+  actionPending,
+  actionFulfilled,
+  actionFullLogin,
+  actionRegister,
+  actionFullRegister,
+  gql,
+  backendURL,
+} from './actions'
+import { Upload, Button } from 'antd'
+import { UploadOutlined } from '@ant-design/icons'
+import ImgCrop from 'antd-img-crop'
+import { Avatar, Image, Divider, Radio } from 'antd'
+import { UserOutlined } from '@ant-design/icons'
+import user from './materials/user.png'
+console.log(store.getState())
+store.subscribe(() => console.log(store.getState()))
+const PageMain = () => <div className="PageMain">ГЛАВНАЯ</div>
+const uploadFile = (file) => {
+  const myForm = new FormData()
+  myForm.append('photo', file)
+  return fetch(backendURL + '/upload', {
+    method: 'POST',
+    headers: localStorage.authToken
+      ? { Authorization: 'Bearer ' + localStorage.authToken }
+      : {},
+    body: myForm,
+  }).then((result) => result.json())
+}
+const actionUploadFile = (file) => actionPromise('uploadFile', uploadFile(file))
+
+const actionAvatar = (imageId) => async (dispatch, getState) => {
+  await dispatch(
+    actionPromise(
+      'setAvatar',
+      gql(
+        `mutation setAvatar($imageId:ID, $userId:String){
+    UserUpsert(user:{_id: $userId, avatar: {_id: $imageId}}){
+    _id, avatar{
+        _id
+    }
+    }
+    }`,
+        { imageId, userId: getState().auth?.payload?.sub?.id },
+      ),
+    ),
+  )
+}
+const actionAboutMe = () => async (dispatch, getState) => {
+  await dispatch(
+    actionPromise(
+      'aboutMe',
+      gql(
+        `query AboutMe($userId:String){
+  UserFindOne(query:$userId)
+  {
+    _id createdAt login nick  avatar{_id url} 
+    likesCount followers{_id login nick} following{_id login nick}
+  }
+}`,
+        {
+          userId: JSON.stringify([{ _id: getState().auth?.payload?.sub?.id }]),
+        },
+      ),
+    ),
+  )
+}
+const actionPostUpsert = (post) =>
+  actionPromise(
+    'postUpsert',
+    gql(
+      `
+mutation PostUpsert($post:PostInput){
+  PostUpsert(post:$post){
+    _id title text 
+  }
+}`,
+      {
+        post: {
+          ...post,
+          images: post.images.map(({ _id }) => ({ _id })),
+          // title: post.title,
+          // text:post.text,
+          // title:post.title
+        },
+      },
+    ),
+  )
+const actionSetAvatar = (file) => async (dispatch) => {
+  let result = await dispatch(actionUploadFile(file))
+  if (result) {
+    await dispatch(actionAvatar(result._id))
+    await dispatch(actionAboutMe())
+  }
+}
+const Page2 = () => <div className="PageMain">юзер</div>
+const PageCreatePost = () => (
+  <div style={{ maxWidth: '700px', maxHeight: '700px', background: '#FFFACD' }}>
+    <h2>Edit Post</h2>
+    <CBasic />
+  </div>
+)
+const Main = () => (
+  <main>
+    <Switch>
+      <Route path="/" exact component={PageMain} />
+      <Route path="/profile/:_id" component={Page2} />
+      <Route path="/edit/post" component={PageCreatePost} />
+      <CBasic />
+    </Switch>
+  </main>
+)
+const Header = () => (
+  <section className="Header">
+    <AddPost />
+    <Recommendations />
+    <Likes />
+    <CUser />
+  </section>
+)
+const Likes = () => <button className="Likes"> Likes </button>
+const Recommendations = () => (
+  <button className="Recomendations"> Recommendations </button>
+)
+const AddPost = ({ children }) => {
+  const [state, setState] = useState(false)
+
+  return (
+    <>
+      <Link to={`/edit/post`}>
+        <button onClick={() => setState(!state)}> + </button>
+        {!state && children}
+      </Link>
+    </>
+  )
+}
+
+const CBasic = connect(null, { onLoad: actionSetAvatar })(Basic)
+// const CAddPost =connect(null,{actionPostUpsert})
+const User = ({ aboutMe: { _id, login, avatar } = {}, getData }) => (
+  <Link className="User" to={`/profile/${_id}`} onClick={() => getData()}>
+    <Avatar src={backendURL + '/' + avatar?.url || user} />
+  </Link>
+)
+
+const CUser = connect(
+  (state) => ({ aboutMe: state.promise.aboutMe?.payload }),
+  { getData: actionAboutMe },
+)(User)
+
+function Basic({ onLoad }) {
+  const { acceptedFiles, getRootProps, getInputProps } = useDropzone()
+
+  const files = acceptedFiles.map((file) => (
+    <li key={file.path}>
+      {file.path} - {file.size} bytes
+    </li>
+  )) // console.log('FILES',acceptedFiles[0])
+  useEffect(() => {
+    acceptedFiles[0] && onLoad(acceptedFiles[0])
+  }, [acceptedFiles])
+  return (
+    <section className="container">
+      <div {...getRootProps({ className: 'Dropzone' })}>
+        <input {...getInputProps()} />
+        <Button icon={<UploadOutlined />}>
+          Drag 'n' drop some files here, or click to select files
+        </Button>
+      </div>
+      <aside>
+        <h4 style={{ color: 'black' }}>Files</h4>
+        <ul>{files}</ul>
+      </aside>
+    </section>
+  )
+}
+
+const defaultPost = {
+  _id: '620b83e3ad55d22f3e2fb319',
+  title: 'Bmw',
+  text: 'Bmw',
+  images: [
+    {
+      _id: '620b8374ad55d22f3e2fb316',
+      url: 'images/e125a428191726307968880977dac103',
+    },
+    {
+      _id: '620b8399ad55d22f3e2fb317',
+      url: 'images/4ae46578989c497582995ba8caeb5de5',
+    },
+    {
+      _id: '620b83b0ad55d22f3e2fb318',
+      url: 'images/ae839539f61249b15feda98cad7eb858',
+    },
+  ],
+}
+
+store.getState().auth?.token && store.dispatch(actionAboutMe())
+
+const SortableItem = sortableElement(({ url }) => (
+  <li>
+    <img
+      src={backendURL + '/' + url}
+      style={{ maxWidth: '200px', maxHeight: '200px' }}
+    />
+  </li>
+))
+
+const SortableContainer = sortableContainer(({ children }) => {
+  return (
+    <>
+      <ul>{children}</ul>
+      {/* <input value={title}/> */}
+    </>
+  )
+})
+const Input = ({ state, onChangeText }) => (
+  <input
+    className="Input"
+    value={state}
+    placeholder={state || ''}
+    onChange={onChangeText}
+  />
+)
+const PostEditor = ({ post = defaultPost, onSave, onFileDrop, fileStatus }) => {
+  const [state, setState] = useState(post)
+  // const [newTitle, setTitle] = useState(post.title || '')
+  const onSortEnd = ({ oldIndex, newIndex }) => {
+    setState({
+      ...state,
+      images: arrayMoveImmutable(state.images, oldIndex, newIndex),
+    })
+  }
+ const onChangeTitle=(event)=> 
+    setState({
+      ...state,
+      title: event.target.value})
+
+  const onChangeText=(event)=> 
+      setState({
+        ...state,
+        text: event.target.value})
+  return (
+    <section className="Post">
+      <SortableContainer onSortEnd={onSortEnd}>
+        {(state.images || []).map(({ _id, url }, index) => (
+          <SortableItem key={`item-${_id}`} index={index} url={url} />
+        ))}
+      </SortableContainer>
+       <h1 className="Title"> Title </h1>
+      <Input state={state.title} onChangeText={onChangeTitle}/>
+      <h1 className="Title"> Text </h1>
+
+      <Input state={state.text} onChangeText={onChangeText}/>
+     
+      <button onClick={() => onSave(state)}> Save </button>
+    </section>
+  )
+}
+
+const CPost = connect(null, { onSave: actionPostUpsert })(PostEditor)
+// fileStatus=actionUploadFile(entity)
+//по файлу в дропзоне:
+//дергать onFileDrop
+//fileStatus - информация о заливке файла из redux
+//через useEffect дождаться когда файл зальется
+//и сделать setState({...state, array: [...state.array, {объект файла с бэка с _id и url}]})
+//по react-sortable-hoc
+//делаете как в пример arrayMove для state.array
+//по кнопке сохранения делаем onSave(state)
+//где-то рядом остальные поля из state типа title name text
+//но это вы уже знаете
+
+const history = createHistory()
+function App() {
+  return (
+    <Router history={history}>
+      <Provider store={store}>
+        <div className="App">
+          <Header />
+          <Divider />
+          <Main />
+
+          {/* <PostEditor /> */}
+          <CPost />
+          {/* <MyImages Images={Images}/> */}
+        </div>
+      </Provider>
+    </Router>
+  )
+}
+
+export default App

+ 61 - 0
src/App.scss

@@ -0,0 +1,61 @@
+.App {
+  text-align: center;
+}
+.Dropzone{
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 20px;
+  border-width: 2px;
+  border-radius: 2px;
+  border-style: dashed;
+  background-color: #fafafa;
+  color: #bdbdbd;
+  outline: none;
+  transition: border .24s ease-in-out;
+}
+.Header{
+  display: flex;
+  padding: 10px;
+  margin: 10px;
+  float: right;
+}
+.Recomendations{
+  margin-left: 10px;
+
+  padding: 10px;
+}
+.Likes{
+  margin-left: 10px;
+  padding: 10px;
+}
+.User{
+  padding: 10px;
+}
+.Post{
+  max-width: 600px;
+  display: block; margin: 0 auto;
+  background-color: #faf6fd;
+  border: 6px solid #7922CC;
+  padding: 10px;
+  border-radius: 25px;
+}
+ul{
+  margin: 0; 
+    padding: 4px; 
+}
+li {
+  display: inline; /* Отображать как строчный элемент */
+  margin-right: 5px; /* Отступ слева */
+  padding: 3px; /* Поля вокруг текста */
+  list-style-type: none; /* Убираем маркеры */
+ }
+
+.Title{
+  text-align: left;
+}
+.Input{
+  display: flex;
+  width: 100%;
+}

+ 8 - 0
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();
+});

+ 109 - 0
src/actions/index.js

@@ -0,0 +1,109 @@
+export const actionAuthLogin = (token) => ({ type: 'AUTH_LOGIN', token })
+export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })
+
+export const getGQL = (url) => (query, variables) =>
+  fetch(url, {
+    method: 'POST',
+    headers: {
+      'Content-Type': 'application/json',
+      ...(localStorage.authToken
+        ? { Authorization: 'Bearer ' + localStorage.authToken }
+        : {}),
+    },
+    body: JSON.stringify({ query, variables }),
+  })
+    .then((res) => res.json())
+    .then((data) => {
+      if (data.data) {
+        return Object.values(data.data)[0]
+      } else {
+        throw new Error(JSON.stringify(data.errors))
+      }
+    })
+
+export const backendURL = 'http://hipstagram.asmer.fs.a-level.com.ua'
+
+export const gql = getGQL(backendURL + '/graphql')
+
+export const actionPending = (name) => ({ type: 'PROMISE', name, status: 'PENDING' })
+export const actionFulfilled = (name, payload) => ({
+  type: 'PROMISE',
+  name,
+  status: 'FULFILLED',
+  payload,
+})
+export const actionRejected = (name, error) => ({
+  type: 'PROMISE',
+  name,
+  status: 'REJECTED',
+  error,
+})
+  export const actionPromise = (name, promise) => async (dispatch) => {
+  dispatch(actionPending(name))
+  try {
+    let payload = await promise
+    dispatch(actionFulfilled(name, payload))
+    return payload
+  } catch (error) {
+    dispatch(actionRejected(name, error))
+  }
+}
+
+  export const actionFullLogin = (login, password) => async (dispatch) => {
+  let token = await dispatch(
+    actionPromise(
+      'auth',
+      gql(
+        ` query login($login:String!, $password:String!){
+            login(login:$login, password:$password)} `,
+        { login, password },
+      ),
+    ),
+  )
+  if (token) {
+    dispatch(actionAuthLogin(token))
+  }
+}
+export const actionRegister = (login, password) =>
+  actionPromise(
+    'register',
+    gql(
+      `mutation register($login: String!, $password: String!) {
+                UserUpsert(user: {login: $login, password: $password, nick: $login}) {
+                  _id login
+                }
+              }`,
+      { login: login, password: password },
+    ),
+  )
+
+  export const actionFullRegister = (login, password) => async (dispatch) => {
+  let tokenCheck = await dispatch(actionRegister(login, password))
+
+  if (tokenCheck?.login === login) {
+    dispatch(actionFullLogin(login, password))
+  }
+}
+
+// export const actionAllAboutMe = (_id) =>
+//   actionPromise(
+//     'aboutMe',
+//     gql(
+//       `query AboutMe($userId:String){
+//         UserFindOne(query:$userId)
+//         {
+//           _id createdAt login nick  avatar{_id url} 
+//           likesCount followers{_id login nick} following{_id login nick}
+//         }
+//     }`,
+//       { userId: JSON.stringify([{ _id }]) },
+//     ),
+//   )
+
+  // const actionAboutMe = (id) => 
+  // actionPromise('aboutMe',gql(`query AboutMe($userId:String){
+  //     UserFindOne(query:$userId)
+  //     {
+  //       login nick  avatar{_id url} createdAt
+  //     }
+  //   }`,{userId: JSON.stringify([{_id:id}])}))

+ 13 - 0
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;
+}

+ 13 - 0
src/index.js

@@ -0,0 +1,13 @@
+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')
+);
+reportWebVitals();

File diff suppressed because it is too large
+ 1 - 0
src/logo.svg


BIN
src/materials/user.png


+ 44 - 0
src/reducers/index.js

@@ -0,0 +1,44 @@
+import thunk from 'redux-thunk';
+import { actionAuthLogin } from '../actions'
+import {createStore, combineReducers, applyMiddleware} from 'redux';
+function promiseReducer(state = {}, { type, name, status, payload, error }) {
+    if (type === 'PROMISE') {
+      return {
+        ...state,
+        [name]: { status, payload, error },
+      }
+    }
+    return state
+  }
+  
+const jwtDecode = (token) => {
+    try {
+      return JSON.parse(atob(token.split('.')[1]))
+    } catch (e) {
+      return null
+    }
+  }
+  function authReducer(state, { type, token }) {
+    if (state === undefined && localStorage.authToken) {
+      token = localStorage.authToken
+      type = 'AUTH_LOGIN'
+    }
+    if (type === 'AUTH_LOGIN') {
+      if (jwtDecode(token)) {
+        localStorage.authToken = token
+        return { token, payload: jwtDecode(token) }
+      }
+    }
+    if (type === 'AUTH_LOGOUT') {
+      localStorage.authToken = ''
+      return {}
+    }
+    return state || {}
+  }
+ export const store = createStore(
+    combineReducers({
+      promise: promiseReducer,
+      auth: authReducer,
+    }),
+    applyMiddleware(thunk),
+  )

+ 13 - 0
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
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';

BIN
src/user.png