Преглед изворни кода

Update sorted code into folders

LenDoc пре 2 година
родитељ
комит
7b38203828
76 измењених фајлова са 1452 додато и 1787 уклоњено
  1. 6 10
      src/App.js
  2. 0 956
      src/actions/index.js
  3. 83 0
      src/actions/query/aboutMeQuery.js
  4. 60 0
      src/actions/query/aboutUserQuery.js
  5. 134 0
      src/actions/query/commentQuery.js
  6. 54 0
      src/actions/query/exploreQuery.js
  7. 81 0
      src/actions/query/likeQuery.js
  8. 13 0
      src/actions/query/loginQuery.js
  9. 64 0
      src/actions/query/postFeedQuery.js
  10. 59 0
      src/actions/query/postQuery.js
  11. 16 0
      src/actions/query/registerQuery.js
  12. 28 0
      src/actions/query/searchUserQuery.js
  13. 53 0
      src/actions/query/subscribeQuery.js
  14. 23 0
      src/actions/query/uploadFilesQuery.js
  15. 9 0
      src/actions/typeSaga/commentTypesSaga.js
  16. 5 0
      src/actions/typeSaga/exploreTypesSaga.js
  17. 3 0
      src/actions/typeSaga/feedTypesSaga.js
  18. 8 0
      src/actions/typeSaga/likeTypesSaga.js
  19. 3 0
      src/actions/typeSaga/logOutTypesSaga.js
  20. 2 0
      src/actions/typeSaga/loginTypesSaga.js
  21. 11 0
      src/actions/typeSaga/myDataTypesSaga.js
  22. 5 2
      src/actions/typeSaga/postActionSaga.js
  23. 2 0
      src/actions/typeSaga/registerTypesSaga.js
  24. 12 0
      src/actions/typeSaga/subscribeTypesSaga.js
  25. 6 0
      src/actions/typeSaga/userTypesSaga.js
  26. 12 0
      src/actions/types/commentTypes.js
  27. 8 0
      src/actions/types/exploreTypes.js
  28. 12 0
      src/actions/types/feedTypes.js
  29. 7 0
      src/actions/types/likeTypes.js
  30. 2 0
      src/actions/types/loginTypes.js
  31. 15 0
      src/actions/types/myDataTypes.js
  32. 0 13
      src/actions/types/postActionTypes.js
  33. 17 0
      src/actions/types/postTypes.js
  34. 28 0
      src/actions/types/promiseTypes.js
  35. 7 0
      src/actions/types/subscribeTypes.js
  36. 17 0
      src/actions/types/userTypes.js
  37. 2 5
      src/components/EditAvatar.jsx
  38. 2 2
      src/components/HeaderButtons.jsx
  39. 3 3
      src/components/Search_Users.jsx
  40. 3 8
      src/components/Subscribe.jsx
  41. 3 2
      src/components/authorization/LogOut.jsx
  42. 6 7
      src/components/authorization/LoginForm.jsx
  43. 2 2
      src/components/authorization/RegisterForm.jsx
  44. 1 1
      src/components/comment/Comment.jsx
  45. 1 1
      src/components/comment/Reply.jsx
  46. 4 4
      src/components/like/Like.jsx
  47. 21 0
      src/helpers/getGQL.js
  48. 19 0
      src/helpers/getGQLAnon.js
  49. 4 0
      src/helpers/history.js
  50. 0 3
      src/helpers/index.js
  51. 10 14
      src/pages/createAndEditPost/index.js
  52. 7 11
      src/pages/explorePosts/index.js
  53. 7 19
      src/pages/feedPosts/index.js
  54. 3 13
      src/pages/onePost/index.js
  55. 3 3
      src/pages/profilePage/index.js
  56. 3 8
      src/pages/setting/index.js
  57. 0 80
      src/redux/index.js
  58. 0 16
      src/redux/reducers/exploreReducer.js
  59. 2 34
      src/redux/reducers/feedReducer.js
  60. 0 18
      src/redux/reducers/myProfileReducer.js
  61. 0 2
      src/redux/reducers/postReducer.js
  62. 49 0
      src/redux/rootSaga.js
  63. 73 0
      src/redux/saga/comment/index.js
  64. 27 0
      src/redux/saga/explore/index.js
  65. 38 0
      src/redux/saga/feed/index.js
  66. 0 550
      src/redux/saga/index.js
  67. 34 0
      src/redux/saga/like/index.js
  68. 25 0
      src/redux/saga/logOut/index.js
  69. 13 0
      src/redux/saga/login/index.js
  70. 50 0
      src/redux/saga/myProfile/index.js
  71. 53 0
      src/redux/saga/post/index.js
  72. 18 0
      src/redux/saga/promise/index.js
  73. 17 0
      src/redux/saga/register/index.js
  74. 39 0
      src/redux/saga/subscribe/index.js
  75. 20 0
      src/redux/saga/userProfile/index.js
  76. 25 0
      src/redux/store.js

+ 6 - 10
src/App.js

@@ -2,23 +2,19 @@ import './App.scss'
 import { Provider, connect } from 'react-redux'
 import { Router, Route, Redirect, Switch } from 'react-router-dom'
 import React from 'react'
-import { store } from './redux'
+import { store } from './redux/store'
 import 'antd/dist/antd.css'
-import { actionFullProfilePage } from './redux/saga'
-import { actionFullAllGetPosts } from './actions'
+import { actionFullProfilePageTypeSaga } from './actions/typeSaga/myDataTypesSaga'
 
 import { CShowHeader } from './pages/header'
 import { CRouting } from './components/Routing'
-import {history} from './helpers'
-console.log(store.getState())
+import history from './helpers/history'
 store.subscribe(() => console.log(store.getState()))
-console.log('ABOUT ME', store.getState().auth?.payload?.sub?.id)
 
 function App() {
-  if (store.getState().auth?.token) {
-    console.log('токен', store.getState().auth?.payload?.sub?.id)
-    store.dispatch(actionFullProfilePage())
-    }
+  if (store.getState().auth?.token) 
+    store.dispatch(actionFullProfilePageTypeSaga())
+    
   return (
     <Router history={history}>
       <Provider store={store}>

+ 0 - 956
src/actions/index.js

@@ -1,956 +0,0 @@
-import { ConsoleSqlOutlined } from '@ant-design/icons'
-import {
-  actionFullProfilePageUser,
-  actionFullProfilePage,
-} from '../redux/saga'
-import { actionFeedTypeCount } from '../redux/reducers/feedReducer'
-import { actionFeedType } from '../redux/reducers/feedReducer'
-import { actionExploreTypeCount } from '../redux/reducers/exploreReducer'
-import { actionClearExplorePosts } from '../redux/reducers/exploreReducer'
-import { actionExploreType } from '../redux/reducers/exploreReducer'
-import { actionClearFeedPostsType } from '../redux/reducers/feedReducer'
-import {actionProfilePageDataType} from '../redux/reducers/myProfileReducer'
-import { history } from '../helpers'
-import{promiseWorker} from '../redux/saga'
-import { all, put, takeEvery, takeLatest, takeLeading, select,call } from 'redux-saga/effects'; //
-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 gql = getGQL('/graphql')
-
-export const getGQLAnon = (url) => (query, variables) =>
-  fetch(url, {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'application/json'
-    },
-    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 gqlAnon = getGQLAnon('/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))
-//   }
-// }
-const actionPromise = (name, promise) =>
-  ({ type: 'PROMISE_START', name, promise })
-
-
-export const actionAboutMe = (_id) =>
-  actionPromise(
-    'aboutMe',
-    gql(
-      `query AboutMe($userId:String){
-            UserFindOne(query:$userId)
-            {
-              _id createdAt login nick avatar{_id url} 
-              followers{_id login nick avatar{_id url}} 
-              following{_id login nick avatar{_id url}}
-              likesCount
-            }
-          }`,
-      {
-        userId: JSON.stringify([{ _id }]),
-      },
-    ),
-  )
-
-  export const actionGetAvatar= (_id) =>
-  actionPromise(
-    'getAvatar',
-    gql(
-      `query AboutMe($userId:String){
-            UserFindOne(query:$userId)
-            {
-             avatar{_id url}
-            }
-          }`,
-      {
-        userId: JSON.stringify([{ _id }]),
-      },
-    ),
-  )
-  export const actionAboutMeLikes = (_id) =>
-  actionPromise(
-    'aboutMeLikes',
-    gql(
-      `query Likes($postId:String){
-            LikeFind(query:$postId)
-            {
-              _id
-              owner { _id nick login
-                avatar{_id url}
-                  }
-            }
-          }`,
-      {
-        postId: JSON.stringify([{ "post._id":_id }]),
-      },
-    ),
-  )
-export const actionLogin = (login, password) => {
-    return actionPromise(
-        "auth",
-        gql(
-            `query log($login:String!, $password:String!) {
-              login(login:$login, password:$password)
-             }`,
-            { login, password }
-        )
-    );
-};
-
-
-// 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) {
-//     await dispatch(actionAuthLogin(token))
-//   }
-// }
-
-export const actionRegister = (login, password) =>
-  actionPromise(
-    'register',
-    gql(
-      `mutation register($login: String!, $password: String!) {
-        createUser (login: $login, password: $password) {
-                  _id login
-                }
-              }`,
-      { login, password },
-    ),
-  )
-
-export const actionChangePassword = (login, password, newPassword) =>
-  actionPromise(
-    'newPassword',
-    gqlAnon(
-      `mutation changePassword($login: String!, $password: String!, $newPassword: String!) {
-        changePassword (login: $login, password: $password, newPassword: $newPassword) {
-                  _id login
-                }
-              }`,
-      { login, password, newPassword },
-    ),
-  )
-// export const actionFullRegister = (login, password) => async (dispatch) => {
-//   let tokenCheck = await dispatch(actionRegister(login, password))
-//   if (tokenCheck?.login === login) {
-//     await dispatch(actionFullLogin(login, password))
-//     history.push('/feed')
-//   }
-// }
-export const uploadFile = (file) => {
-  const myForm = new FormData()
-  myForm.append('photo', file)
-  return fetch('/upload', {
-    method: 'POST',
-    headers: localStorage.authToken
-      ? { Authorization: 'Bearer ' + localStorage.authToken }
-      : {},
-    body: myForm,
-  }).then((result) => result.json())
-}
-
-export const uploadFileType = {
-  name: 'photo',
-  action: `/upload`,
-  headers: localStorage.authToken
-    ? { Authorization: 'Bearer ' + localStorage.authToken }
-    : {},
-}
-export const actionUploadFile = (file) =>
-  actionPromise('uploadFile', uploadFile(file))
-
-export const actionClearPromise = (name) => (dispatch) => {
-  return dispatch(actionClearPromiseForName(name))
-}
-export const actionClearPromiseForName = (name) => ({
-  type: 'PROMISE_CLEAR',
-  name,
-})
-export const actionAllClearPromiseType = () => ({
-  type: 'PROMISE_All_CLEAR',
-})
-
-export const actionUploadFiles = (files) =>
-  actionPromise(
-    'uploadFiles',
-    Promise.all(files.map((file) => uploadFile(file))),
-  )
-
-export const actionAvatar = (imageId, _id) =>
-  actionPromise(
-    'setAvatar',
-    gql(
-      `mutation setAvatar($imageId:ID, $userId:String){
-    UserUpsert(user:{_id: $userId, avatar: {_id: $imageId}}){
-    _id, avatar{
-        _id
-    }
-    }
-    }`,
-      { imageId, userId: _id },
-    ),
-  )
-
-export const actionPostUpsert = (post, postId) => 
-    actionPromise(
-      'postUpsert',
-      gql(
-        `
-mutation PostUpsert($post:PostInput){
-  PostUpsert(post:$post){
-    _id title text images{_id url}
-  }
-}`,
-        {
-          post: {
-            ...post,
-            _id:postId,
-            images: post.images.map(({ _id }) => ({ _id })),
-          },
-        },
-      ),
-    )
-// export const actionAllPosts = (userId) =>
-//   actionPromise(
-//     'allPostsMe',
-//     gql(
-//       `query allPosts($userId:String!){
-//   PostFind(query:$userId){
-//            owner{_id} _id title text images{_id url}
-//     }
-// }`,
-//       {
-//         userId: JSON.stringify([
-//           { ___owner: userId },
-
-//           {
-//             sort: [{ _id: -1 }],
-//             skip: [0],
-//             limit: [300],
-//           },
-//         ]),
-//       },
-//     ),
-//   )
-
-export const actionPostsCount = (_id) =>
-  actionPromise(
-    'countPosts',
-    gql(
-      ` query CountAllPostsUser($_id:String!){
-                PostCount(query:$_id)
-
-                }`,
-
-      {
-        _id:
-          JSON.stringify([{ ___owner: { $in: [_id] } }])
-      },
-    ),
-  )
-
-// export const actionAllPostsFeed = () =>
-//   actionPromise(
-//     'postsAllFeed',
-//     gql(
-//       ` query allPosts($_id:String){
-//                 PostFind(query:$_id){
-//                   owner{_id login avatar{_id url}}
-//                    _id title text images{_id url}
-//                    likes{
-//                     _id
-//                     owner{
-//                        _id login avatar {_id url}
-//                       }
-//                 }
-//                 comments{
-//                   _id, createdAt, text  owner{_id login avatar{_id url}}
-//                   answers{
-//                     _id, createdAt, text owner{_id login  avatar{_id url}}
-
-//                   }
-
-//                 }
-//               }
-//             }`,
-//       {
-//         _id: JSON.stringify([
-//           {},
-//           {
-//             sort: [{ _id: -1 }],
-//             skip: [0],
-//             limit: [10],
-//           },
-//         ]),
-//       },
-//     ),
-//   )
-
-export const actionOnePost = (_id) =>
-  actionPromise(
-    'onePost',
-    gql(
-      `query OneFind($post:String){
-        PostFindOne(query:$post){
-          _id createdAt title text 
-          images{_id url originalFileName}
-          comments {
-              _id createdAt text 
-              likes { _id owner {_id login nick avatar {url} }}   
-              owner {_id login nick
-                      avatar {url}
-                  }
-              answers{
-                  _id  
-                  }
-                 answerTo{_id} 
-              }
-              likes{
-                _id
-                owner{				
-                   _id login avatar {url}
-                  }
-            }
-          owner {_id login nick
-              avatar {url}
-              }
-          }
-      }
-      `,
-      {
-        post: JSON.stringify([{ _id }]),
-      },
-    ),
-  )
-
-export const actionFindLikes = (_id) => 
-    actionPromise(
-      'onePostLikes',
-      gql(
-        `query OneFind($post:String){
-         PostFindOne(query:$post){
-        likes{
-          _id
-          owner{				
-             _id login avatar {url}
-            }
-      }
-        }
-      }`,
-        {
-          post: JSON.stringify([{ _id }]),
-        },
-      ),
-    )
-
-export const actionAllFollowers = (_id) => 
-    actionPromise(
-      'allFollowers',
-      gql(
-        `query AllFollowers($userId:String){
-  UserFindOne(query:$userId)
-        {
-          _id
-          followers{_id login}
-        }
-      }`,
-        {
-          userId: JSON.stringify([{ _id }]),
-        },
-      ),
-    )
-
-export const actionAllFollowing = (_id) =>
-    actionPromise(
-      'allFollowing',
-      gql(
-        `query AllFollowing($userId:String){
-  UserFindOne(query:$userId)
-    {_id
-          following{_id login}
-    }
-}`,
-        {
-          userId: JSON.stringify([{ _id }]),
-        },
-      ),
-    )
-  
-export const actionAddComment = (postId, text) => 
-
-    actionPromise(
-      "addComment",
-      gql(
-        `mutation AddComment($comment:CommentInput){
-          CommentUpsert(comment:$comment)
-          {
-            _id
-            text 
-            createdAt
-          }
-        }`,
-        {
-          comment: {
-            post: {
-              _id: postId,
-            },
-            text
-          },
-        },
-      ),
-    )
-
-export const actionGetCommentsOnePost = (postId) =>
-  actionPromise('commentsOnePost',
-    gql(`query commentFindPost ($id:String!){
-        PostFindOne(query:$id){
-            comments {
-                _id text createdAt 
-                owner{
-                    _id nick login
-                    avatar{
-                        _id url
-                        }
-                    } 
-                    likes{_id}
-                }
-        }
-    }`, { id: JSON.stringify([{ _id: postId }]) }))
-
-
-export const actionAddSubComment = (commentId, newResult) =>
-    actionPromise(
-      'addSubComment',
-      gql(
-        `mutation AddComment($comment:CommentInput){
-          CommentUpsert(comment:$comment)
-          {
-            _id
-            text 
-            createdAt
-          }
-        }`,
-        {
-          comment: {
-            answerTo: {
-              _id: commentId,
-            },
-            text: newResult,
-          },
-        },
-      ),
-    )
-
-// export const actionAddFullComment = (postId,comment) => async(dispatch) => {
-//   let addComment = await dispatch(actionAddComment(postId,comment));
-//   if(addComment){
-//     await dispatch(actionOnePost(postId));
-//   }
-// }
-
-// export const actionAddFullComment = (postId, comment) => async (
-//   dispatch,
-//   getState,
-// ) => {
-//   await dispatch(actionAddComment(postId, comment))
-//   const {
-//     promise: {
-//       addComment: { status },
-//     },
-//   } = getState()
-//   if (status === 'FULFILLED') {
-//     await dispatch(actionOnePost(postId))
-//   }
-//   // await dispatch(actionOnePost(postId));
-// }
-
-// export const actionAddlike = _id =>
-//             actionPromise("addLike", gql(`mutation AddLike($like:LikeInput){
-//               LikeUpsert(like:$like){
-//                 _id
-//               }
-//             }`,{
-//               like:{
-//                   "post":{
-//                       "_id": _id
-//                   }
-//               }
-//             }))
-
-export const actionAddLike = (postId) =>
-  actionPromise(
-    'addLike',
-    gql(
-      `mutation AddLike($like:LikeInput){
-          LikeUpsert(like:$like)
-          {
-            _id
-          }
-        }`,
-      {
-        like: {
-          post: {
-            _id: postId,
-          },
-        },
-      },
-    ),
-  )
-
-export const actionGetFindLiked = (_id) => 
-    actionPromise(
-      'findLiked',
-      gql(
-        ` query LikeFindPost($id:String!) {
-          LikeFind(query:$id){
-             owner { _id nick login
-                avatar{_id url}
-                  }
-                }
-            } `,
-        {
-          id: JSON.stringify([{ 'post._id': _id }]),
-        },
-      ),
-    )
-
-// export const actionDeleteFullLike = (likeId) => async(dispatch,getState) => {
-//   let unLike = await dispatch(actionDeleteLike(likeId));
-//   if(unLike){
-//     await dispatch(actionOnePost(unLike?.post?._id));
-//   }
-// }
-
-// export const actionDeleteFullLike = (likeId, postId) => async (
-//   dispatch,
-//   getState,
-// ) => {
-//   await dispatch(actionDeleteLike(likeId, postId))
-//   const {
-//     promise: {
-//       deleteLike: { status },
-//     },
-//   } = getState()
-//   if (status === 'FULFILLED') {
-//     await dispatch(actionOnePost(postId))
-//   }
-//   //  await dispatch(actionOnePost(postId));
-// }
-export const actionDeleteLike = (likeId, postId) =>
-  actionPromise(
-    'deleteLike',
-    gql(
-      `mutation DeleteLike($like:LikeInput){
-          LikeDelete(like: $like)
-          {
-            _id
-          }
-        }`,
-      {
-        like: {
-          _id: likeId,
-          post: {
-            _id: postId,
-          },
-        },
-      },
-    ),
-  )
-
-// export const actionSetAvatar = (file, myId) => async (dispatch) => {
-//   const avatar = await dispatch(actionAvatar(file, myId))
-//   if (avatar) {
-//     await dispatch(actionFullProfilePageUser(myId))
-//     await dispatch(actionFullProfilePage(myId))
-//     await dispatch(actionClearPromise('setAvatar'))
-//     await dispatch(actionClearPromise('uploadFile'))
-//   }
-// }
-
-export const actionPostsFeed = (myFollowing, skip) =>
-  actionPromise(
-    'postsFeed',
-    gql(
-      `query PostsFeed($ownerId:String){
-          PostFind(query:$ownerId){
-          owner{_id login avatar{url}}
-          images{_id url} title text
-          _id likesCount 
-            likes{
-                  _id
-                  owner{				
-                     _id login avatar {_id url}
-                    }
-              }
-              comments{
-                _id, createdAt, text  owner{_id login avatar{_id url}}
-                answers{
-                  _id, createdAt, text owner{_id login  avatar{_id url}}
-                 
-                }
-      }
-  }
-}`,
-      {
-        ownerId: JSON.stringify([
-          {
-            ___owner: {
-              $in: myFollowing,
-            },
-          },
-          {
-            sort: [{ _id: -1 }],
-            skip: [skip || 0],
-            limit: [10],
-          },
-        ]),
-      },
-    ),
-  )
-
-export const actionFullAllGetPosts = () => ({
-  type:"FEED_POSTS"
-})
-
-export const actionFullExplorePosts = () => ({
-  type:"EXPLORE_POSTS"
-})
-
-export const actionPostsFeedCount = (myFollowing) =>
-  actionPromise(
-    'postsFeedCount',
-    gql(
-      ` query CountAllPostsFeed($_id:String!){
-                PostCount(query:$_id)
-
-                }`,
-
-      {
-        _id: JSON.stringify([
-          {
-            ___owner: {
-              $in: myFollowing,
-            },
-          },
-        ]),
-      },
-    ),
-  )
-
-export const actionExplorePosts = (skip) =>
-  actionPromise(
-    'explorePosts',
-    gql(
-      ` query PostsFeed($_id:String){
-        PostFind(query:$_id){
-        owner{_id login avatar{url}}
-        images{_id url} title text
-        _id likesCount 
-
-          likes{
-                _id
-                owner{				
-                   _id login avatar {_id url}
-                  }
-            }
-            comments{
-              _id, createdAt, text  owner{_id login avatar{_id url}}
-              answers{
-                _id, createdAt, text owner{_id login  avatar{_id url}}
-               
-              }
-    }
-}
-            }`,
-      {
-        _id: JSON.stringify([
-          {},
-          {
-            sort: [{ _id: -1 }],
-            skip: [skip || 0],
-            limit: [12],
-          },
-        ]),
-      },
-    ),
-  )
-export const actionExplorePostsCount = () =>
-  actionPromise(
-    'explorePostsCount',
-    gql(
-      ` query CountAllPosts($_id:String!){
-                PostCount(query:$_id)
-
-                }`,
-
-      {
-        _id: JSON.stringify([{}]),
-      },
-    ),
-  )
-export const actionSearchUser = (userName) =>
-    actionPromise(
-      'searchUser',
-      gql(
-        `
-    query gf($query: String){
-        UserFind(query: $query){
-            _id, login avatar{url}
-        }
-    }`,
-        {
-          query: JSON.stringify([
-            {
-              $or: [{ login: `/${userName}/` }], //регулярки пишутся в строках
-            },
-            {
-              sort: [{ login: 1 }],
-            }, //сортируем по title алфавитно
-          ]),
-        },
-      ),
-    )
-
-export const actionUserUpsert = (user, _id) =>
-  actionPromise(
-    'userUpsert',
-    gql(
-      `mutation UserUpsert($user:UserInput){
-                  UserUpsert(user:$user){
-                      _id login nick avatar{_id}
-                  }
-              }`,
-      {
-        user: {
-          _id,
-          login: user?.login,
-          nick : user?.nick
-        },
-      },
-    ),
-  )
-
-// export con
-export const actionAboutUser = (_id) =>
-  actionPromise(
-    'aboutUser',
-    gql(
-      `query AboutMe($userId:String){
-      UserFindOne(query:$userId)
-      {
-        _id createdAt login nick avatar{_id url} 
-        followers{_id login nick avatar{_id url}} 
-        following{_id login nick avatar{_id url}}
-      }
-    }`,
-      {
-        userId: JSON.stringify([{ _id }]),
-      },
-    ),
-  )
-
-
-  export const actionGetFollowing = (_id) =>
-  actionPromise(
-    'getFollowing',
-    gql(
-      `query GetFollowing($userId:String){
-      UserFindOne(query:$userId)
-      {
-        following{_id login nick avatar{_id url}}
-      }
-    }`,
-      {
-        userId: JSON.stringify([{ _id }]),
-      },
-    ),
-  )
-
-
-  export const actionGetFollowers = (userId) =>
-  actionPromise(
-    'getFollowers',
-    gql(
-      `query GetFollowers($userId:String){
-      UserFindOne(query:$userId)
-      {
-       _id
-        followers{_id login nick avatar{_id url}}
-      }
-    }`,
-      {
-        userId: JSON.stringify([{ _id:userId }]),
-      },
-    ),
-  )
-
-
-export const actionAllPostsUser = (userId, skip) =>
-  actionPromise(
-    'allPosts',
-    gql(
-      `query allPosts($userId:String!){
-PostFind(query:$userId){
-       owner{_id} _id title text images{_id url}
-}
-}`,
-      {
-        userId: JSON.stringify([
-          { ___owner: userId },
-
-          {
-            sort: [{ _id: -1 }],
-            skip: [skip || 0],
-            limit: [12],
-          },
-        ]),
-      },
-    ),
-  )
-
-
-  export const actionChangeSubscribe = (oldFollowing) =>
-  actionPromise(
-    'changeSubscribe',
-    gql(
-      `mutation changeSubscribe($user:UserInput) {
-        UserUpsert(user: $user) {
-          _id
-        }
-      }
-      `,
-      {
-        user: 
-         oldFollowing 
-        ,
-      },
-    ),
-  )
-
-
-export const actionAddFullLikeForFeed = (postId) => async (
-  dispatch,
-  getState,
-) => {
-  await dispatch(actionAddLike(postId))
-  const {
-    promise: {
-      addLike: { status },
-    },
-  } = getState()
-  if (status === 'FULFILLED') {
-    await dispatch(actionOnePost(postId))
-    await dispatch(actionFullAllGetPosts())
-  }
-  //  await dispatch(actionOnePost(postId));
-}
-export const actionDeleteFullLikeForFeed = (likeId, postId) => async (
-  dispatch,
-  getState,
-) => {
-  await dispatch(actionDeleteLike(likeId, postId))
-  const {
-    promise: {
-      deleteLike: { status },
-    },
-  } = getState()
-  if (status === 'FULFILLED') {
-    await dispatch(actionOnePost(postId))
-    await dispatch(actionFullAllGetPosts())
-  }
-  //  await dispatch(actionOnePost(postId));
-}
-
-
-export const actionFindSubComment = (findId) =>
-  actionPromise(
-    'subComments',
-    gql(
-      `query commentFindOne ($id:String!){
-        CommentFindOne(query:$id){
-       _id text answers { 
-                _id text
-                post {_id }
-                answers { _id}
-                createdAt
-                likes { _id owner 
-                {_id avatar{_id url} login nick } }
-                owner {
-                    _id login nick 
-                    avatar { _id url } 
-                    } 
-                }
-        } 
-    }`,
-      {
-        id: JSON.stringify([
-          {
-            _id: findId,
-          },
-        ]),
-      },
-    ),
-  )

+ 83 - 0
src/actions/query/aboutMeQuery.js

@@ -0,0 +1,83 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+import { gqlAnon } from "../../helpers/getGQLAnon";
+
+export const actionAboutMe = (_id) =>
+  actionPromise(
+    'aboutMe',
+    gql(
+      `query AboutMe($userId:String){
+            UserFindOne(query:$userId)
+            {
+              _id createdAt login nick avatar{_id url} 
+              followers{_id login nick avatar{_id url}} 
+              following{_id login nick avatar{_id url}}
+              likesCount
+            }
+          }`,
+      {
+        userId: JSON.stringify([{ _id }]),
+      },
+    ),
+  )
+  export const actionUserUpsert = (user, _id) =>
+  actionPromise(
+    'userUpsert',
+    gql(
+      `mutation UserUpsert($user:UserInput){
+                  UserUpsert(user:$user){
+                      _id login nick avatar{_id}
+                  }
+              }`,
+      {
+        user: {
+          _id,
+          login: user?.login,
+          nick : user?.nick
+        },
+      },
+    ),
+  )
+  export const actionAvatar = (imageId, _id) =>
+  actionPromise(
+    'setAvatar',
+    gql(
+      `mutation setAvatar($imageId:ID, $userId:String){
+    UserUpsert(user:{_id: $userId, avatar: {_id: $imageId}}){
+    _id, avatar{
+        _id
+    }
+    }
+    }`,
+      { imageId, userId: _id },
+    ),
+  )
+  export const actionGetAvatar= (_id) =>
+  actionPromise(
+    'getAvatar',
+    gql(
+      `query getAvatar($userId:String){
+            UserFindOne(query:$userId)
+            {
+             avatar{_id url}
+            }
+          }`,
+      {
+        userId: JSON.stringify([{ _id }]),
+      },
+    ),
+  )
+  
+
+  export const actionChangePassword = (login, password, newPassword) =>
+  actionPromise(
+    'newPassword',
+    gqlAnon(
+      `mutation changePassword($login: String!, $password: String!, $newPassword: String!) {
+        changePassword (login: $login, password: $password, newPassword: $newPassword) {
+                  _id login
+                }
+              }`,
+      { login, password, newPassword },
+    ),
+  )

+ 60 - 0
src/actions/query/aboutUserQuery.js

@@ -0,0 +1,60 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionAboutUser = (_id) =>
+actionPromise(
+  'aboutUser',
+  gql(
+    `query AboutMe($userId:String){
+    UserFindOne(query:$userId)
+    {
+      _id createdAt login nick avatar{_id url} 
+      followers{_id login nick avatar{_id url}} 
+      following{_id login nick avatar{_id url}}
+    }
+  }`,
+    {
+      userId: JSON.stringify([{ _id }]),
+    },
+  ),
+)
+
+
+export const actionAllPostsUser = (userId, skip) =>
+  actionPromise(
+    'allPosts',
+    gql(
+      `query allPosts($userId:String!){
+PostFind(query:$userId){
+       owner{_id} _id title text images{_id url}
+}
+}`,
+      {
+        userId: JSON.stringify([
+          { ___owner: userId },
+
+          {
+            sort: [{ _id: -1 }],
+            skip: [skip || 0],
+            limit: [12],
+          },
+        ]),
+      },
+    ),
+  )
+
+  export const actionPostsCount = (_id) =>
+  actionPromise(
+    'countPosts',
+    gql(
+      ` query CountAllPostsUser($_id:String!){
+                PostCount(query:$_id)
+
+                }`,
+
+      {
+        _id:
+          JSON.stringify([{ ___owner: { $in: [_id] } }])
+      },
+    ),
+  )

+ 134 - 0
src/actions/query/commentQuery.js

@@ -0,0 +1,134 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionAddComment = (postId, text) => 
+actionPromise(
+  "addComment",
+  gql(
+    `mutation AddComment($comment:CommentInput){
+      CommentUpsert(comment:$comment)
+      {
+        _id
+        text 
+        createdAt
+      }
+    }`,
+    {
+      comment: {
+        post: {
+          _id: postId,
+        },
+        text
+      },
+    },
+  ),
+    )
+
+export const actionOnePost = (_id) =>
+  actionPromise(
+    'onePost',
+    gql(
+      `query OneFind($post:String){
+        PostFindOne(query:$post){
+          _id createdAt title text 
+          images{_id url originalFileName}
+          comments {
+              _id createdAt text 
+              likes { _id owner {_id login nick avatar {url} }}   
+              owner {_id login nick
+                      avatar {url}
+                  }
+              answers{
+                  _id  
+                  }
+                 answerTo{_id} 
+              }
+              likes{
+                _id
+                owner{				
+                   _id login avatar {url}
+                  }
+            }
+          owner {_id login nick
+              avatar {url}
+              }
+          }
+      }
+      `,
+      {
+        post: JSON.stringify([{ _id }]),
+      },
+    ),
+    )
+  
+    
+
+export const actionGetCommentsOnePost = (postId) =>
+actionPromise('commentsOnePost',
+  gql(`query commentFindPost ($id:String!){
+      PostFindOne(query:$id){
+          comments {
+              _id text createdAt 
+              owner{
+                  _id nick login
+                  avatar{
+                      _id url
+                      }
+                  } 
+                  likes{_id}
+              }
+      }
+  }`, { id: JSON.stringify([{ _id: postId }]) }))
+  
+export const actionFindSubComment = (findId) =>
+actionPromise(
+  'subComments',
+  gql(
+    `query commentFindOne ($id:String!){
+      CommentFindOne(query:$id){
+     _id text answers { 
+              _id text
+              post {_id }
+              answers { _id}
+              createdAt
+              likes { _id owner 
+              {_id avatar{_id url} login nick } }
+              owner {
+                  _id login nick 
+                  avatar { _id url } 
+                  } 
+              }
+      } 
+  }`,
+    {
+      id: JSON.stringify([
+        {
+          _id: findId,
+        },
+      ]),
+    },
+  ),
+)
+export const actionAddSubComment = (commentId, newResult) =>
+    actionPromise(
+      'addSubComment',
+      gql(
+        `mutation AddComment($comment:CommentInput){
+          CommentUpsert(comment:$comment)
+          {
+            _id
+            text 
+            createdAt
+          }
+        }`,
+        {
+          comment: {
+            answerTo: {
+              _id: commentId,
+            },
+            text: newResult,
+          },
+        },
+      ),
+  )
+

+ 54 - 0
src/actions/query/exploreQuery.js

@@ -0,0 +1,54 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionExplorePosts = (skip) =>
+actionPromise(
+  'explorePosts',
+  gql(
+    ` query PostsFeed($_id:String){
+      PostFind(query:$_id){
+      owner{_id login avatar{url}}
+      images{_id url} title text
+      _id likesCount 
+
+        likes{
+              _id
+              owner{				
+                 _id login avatar {_id url}
+                }
+          }
+          comments{
+            _id, createdAt, text  owner{_id login avatar{_id url}}
+            answers{
+              _id, createdAt, text owner{_id login  avatar{_id url}}
+             
+            }
+  }
+}
+          }`,
+    {
+      _id: JSON.stringify([
+        {},
+        {
+          sort: [{ _id: -1 }],
+          skip: [skip || 0],
+          limit: [12],
+        },
+      ]),
+    },
+  ),
+)
+export const actionExplorePostsCount = () =>
+actionPromise(
+  'explorePostsCount',
+  gql(
+    ` query CountAllPosts($_id:String!){
+              PostCount(query:$_id)
+
+              }`,
+
+    {
+      _id: JSON.stringify([{}]),
+    },
+  ),
+)

+ 81 - 0
src/actions/query/likeQuery.js

@@ -0,0 +1,81 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionAddLike = (postId) =>
+  actionPromise(
+    'addLike',
+    gql(
+      `mutation AddLike($like:LikeInput){
+        LikeUpsert(like:$like)
+        {
+          _id
+        }
+      }`,
+      {
+        like: {
+          post: {
+            _id: postId,
+          },
+        },
+      },
+    ),
+  )
+
+export const actionDeleteLike = (likeId, postId) =>
+  actionPromise(
+    'deleteLike',
+    gql(
+      `mutation DeleteLike($like:LikeInput){
+        LikeDelete(like: $like)
+        {
+          _id
+        }
+      }`,
+      {
+        like: {
+          _id: likeId,
+          post: {
+            _id: postId,
+          },
+        },
+      },
+    ),
+  )
+
+export const actionFindLikes = (_id) =>
+  actionPromise(
+    'onePostLikes',
+    gql(
+      `query OnePostLikes($post:String){
+         PostFindOne(query:$post){
+        likes{
+          _id
+          owner{				
+             _id login avatar {url}
+            }
+      }
+        }
+      }`,
+      {
+        post: JSON.stringify([{ _id }]),
+      },
+    ),
+  )
+
+//   export const actionGetFindLiked = (_id) => 
+//     actionPromise(
+//       'findLiked',
+//       gql(
+//         ` query LikeFindPost($id:String!) {
+//           LikeFind(query:$id){
+//              owner { _id nick login
+//                 avatar{_id url}
+//                   }
+//                 }
+//             } `,
+//         {
+//           id: JSON.stringify([{ 'post._id': _id }]),
+//         },
+//       ),
+//     )
+

+ 13 - 0
src/actions/query/loginQuery.js

@@ -0,0 +1,13 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+export const actionLogin = (login, password) => {
+    return actionPromise(
+        "auth",
+        gql(
+            `query log($login:String!, $password:String!) {
+              login(login:$login, password:$password)
+             }`,
+            { login, password }
+        )
+    );
+};

+ 64 - 0
src/actions/query/postFeedQuery.js

@@ -0,0 +1,64 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionPostsFeed = (myFollowing, skip) =>
+actionPromise(
+  'postsFeed',
+  gql(
+    `query PostsFeed($ownerId:String){
+        PostFind(query:$ownerId){
+        owner{_id login avatar{url}}
+        images{_id url} title text
+        _id likesCount 
+          likes{
+                _id
+                owner{				
+                   _id login avatar {_id url}
+                  }
+            }
+            comments{
+              _id, createdAt, text  owner{_id login avatar{_id url}}
+              answers{
+                _id, createdAt, text owner{_id login  avatar{_id url}}
+               
+              }
+    }
+}
+}`,
+    {
+      ownerId: JSON.stringify([
+        {
+          ___owner: {
+            $in: myFollowing,
+          },
+        },
+        {
+          sort: [{ _id: -1 }],
+          skip: [skip || 0],
+          limit: [10],
+        },
+      ]),
+    },
+  ),
+    )
+
+    export const actionPostsFeedCount = (myFollowing) =>
+    actionPromise(
+      'postsFeedCount',
+      gql(
+        ` query CountAllPostsFeed($_id:String!){
+                  PostCount(query:$_id)
+  
+                  }`,
+  
+        {
+          _id: JSON.stringify([
+            {
+              ___owner: {
+                $in: myFollowing,
+              },
+            },
+          ]),
+        },
+      ),
+    )

+ 59 - 0
src/actions/query/postQuery.js

@@ -0,0 +1,59 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionOnePost = (_id) =>
+actionPromise(
+  'onePost',
+  gql(
+    `query OneFind($post:String){
+      PostFindOne(query:$post){
+        _id createdAt title text 
+        images{_id url originalFileName}
+        comments {
+            _id createdAt text 
+            likes { _id owner {_id login nick avatar {url} }}   
+            owner {_id login nick
+                    avatar {url}
+                }
+            answers{
+                _id  
+                }
+               answerTo{_id} 
+            }
+            likes{
+              _id
+              owner{				
+                 _id login avatar {url}
+                }
+          }
+        owner {_id login nick
+            avatar {url}
+            }
+        }
+    }
+    `,
+    {
+      post: JSON.stringify([{ _id }]),
+    },
+  ),
+    )
+    export const actionPostUpsert = (post, postId) => 
+    actionPromise(
+      'postUpsert',
+      gql(
+        `
+mutation PostUpsert($post:PostInput){
+  PostUpsert(post:$post){
+    _id title text images{_id url}
+  }
+}`,
+        {
+          post: {
+            ...post,
+            _id:postId,
+            images: post.images.map(({ _id }) => ({ _id })),
+          },
+        },
+      ),
+    )
+

+ 16 - 0
src/actions/query/registerQuery.js

@@ -0,0 +1,16 @@
+import { gql } from '../../helpers/getGQL';
+import { actionPromise } from "../types/promiseTypes";
+
+const actionRegister = (login, password) =>
+  actionPromise(
+    'register',
+    gql(
+      `mutation register($login: String!, $password: String!) {
+        createUser (login: $login, password: $password) {
+                  _id login
+                }
+              }`,
+      { login, password },
+    ),
+    )
+  export default actionRegister

+ 28 - 0
src/actions/query/searchUserQuery.js

@@ -0,0 +1,28 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+export const actionSearchUser = (userName) =>
+actionPromise(
+  'searchUser',
+  gql(
+    `
+query gf($query: String){
+    UserFind(query: $query){
+        _id, login avatar{url}
+    }
+}`,
+    {
+      query: JSON.stringify([
+        {
+          $or: [{ login: `/${userName}/` }],
+        },
+        {
+          sort: [{ login: 1 }],
+        }, 
+      ]),
+    },
+  ),
+)
+
+
+

+ 53 - 0
src/actions/query/subscribeQuery.js

@@ -0,0 +1,53 @@
+import { gql } from "../../helpers/getGQL";
+import { actionPromise } from "../types/promiseTypes";
+
+  export const actionChangeSubscribe = (oldFollowing) =>
+  actionPromise(
+    'changeSubscribe',
+    gql(
+      `mutation changeSubscribe($user:UserInput) {
+        UserUpsert(user: $user) {
+          _id
+        }
+      }
+      `,
+      {
+        user: 
+         oldFollowing 
+        ,
+      },
+    ),
+    )
+export const actionGetFollowing = (_id) =>
+  actionPromise(
+    'getFollowing',
+    gql(
+      `query GetFollowing($userId:String){
+      UserFindOne(query:$userId)
+      {
+        following{_id login nick avatar{_id url}}
+      }
+    }`,
+      {
+        userId: JSON.stringify([{ _id }]),
+      },
+    ),
+  )
+
+
+  export const actionGetFollowers = (userId) =>
+  actionPromise(
+    'getFollowers',
+    gql(
+      `query GetFollowers($userId:String){
+      UserFindOne(query:$userId)
+      {
+       _id
+        followers{_id login nick avatar{_id url}}
+      }
+    }`,
+      {
+        userId: JSON.stringify([{ _id:userId }]),
+      },
+    ),
+  )

+ 23 - 0
src/actions/query/uploadFilesQuery.js

@@ -0,0 +1,23 @@
+
+import { actionPromise } from '../types/promiseTypes'
+
+export const uploadFile = (file) => {
+  const myForm = new FormData()
+  myForm.append('photo', file)
+  return fetch('/upload', {
+    method: 'POST',
+    headers: localStorage.authToken
+      ? { Authorization: 'Bearer ' + localStorage.authToken }
+      : {},
+    body: myForm,
+  }).then((result) => result.json())
+}
+
+export const actionUploadFile = (file) =>
+  actionPromise('uploadFile', uploadFile(file))
+
+export const actionUploadFiles = (files) =>
+  actionPromise(
+    'uploadFiles',
+    Promise.all(files.map((file) => uploadFile(file))),
+  )

+ 9 - 0
src/actions/typeSaga/commentTypesSaga.js

@@ -0,0 +1,9 @@
+
+export const actionAddCommentFeedTypeSaga = (postId, text) => ({
+    type:"FEED_POST_COMMENT", postId, text
+    
+  })
+  
+  export const actionAddFullCommentFeed = (postId, newResult) => ({
+    type:"ADD_COMMENT_FEED", postId, newResult
+  })

+ 5 - 0
src/actions/typeSaga/exploreTypesSaga.js

@@ -0,0 +1,5 @@
+export const actionFullExplorePostsTypeSaga = () => ({
+    type:"EXPLORE_POSTS"
+  })
+  
+  

+ 3 - 0
src/actions/typeSaga/feedTypesSaga.js

@@ -0,0 +1,3 @@
+export const actionFullAllGetPostsSaga = () => ({
+    type:"FEED_POSTS"
+  })

+ 8 - 0
src/actions/typeSaga/likeTypesSaga.js

@@ -0,0 +1,8 @@
+export const actionChangeLikeTypeSaga = (likeId, postId) =>
+({
+    type:"CHANGE_LIKE_POST", likeId,postId
+})
+export const actionChangeFeedLikeTypeSaga = (likeId, postId) =>
+({
+    type:"CHANGE_LIKE_POST_FEED", likeId,postId
+})

+ 3 - 0
src/actions/typeSaga/logOutTypesSaga.js

@@ -0,0 +1,3 @@
+export const actionClearDataLogoutTypeSaga = () => ({
+    type:"CLEAR_ALL_DATA"
+  })

+ 2 - 0
src/actions/typeSaga/loginTypesSaga.js

@@ -0,0 +1,2 @@
+export const actionLoginTypeSaga = (login, password) => 
+({type: 'FULL_LOGIN', login, password})

+ 11 - 0
src/actions/typeSaga/myDataTypesSaga.js

@@ -0,0 +1,11 @@
+
+export const actionUserUpdateTypeSaga = (user) => ({
+    type:"USER_UPDATE", user
+})
+export const actionSetAvatarTypeSaga = (file) => ({
+    type:"SET_AVATAR", file
+  })
+  export const actionFullProfilePageTypeSaga = () =>
+({
+    type:"FULLPROFILE_PAGE",
+})

+ 5 - 2
src/actions/typeSaga/postActionSaga.js

@@ -5,7 +5,6 @@ export const actionAddFullCommentSaga = (postId, text) => ({
     type:"ONE_POST_COMMENT", postId, text
     
   })
-  
 export const actionAddSubCommentTypeSaga = ( commentId,
   newResult) => ({
   type:"POST_SUB_COMMENT",  commentId, newResult
@@ -14,4 +13,8 @@ export const actionAddSubCommentTypeSaga = ( commentId,
 export const actionFindSubCommentTypeSaga = (commentId) => ({
   type:"GET_SUB_COMMENT",commentId
     
-  })
+})
+export const actionCreateEditPostTypeSaga= (state) =>
+({
+    type:"CREATE_EDIT_POST", state
+})

+ 2 - 0
src/actions/typeSaga/registerTypesSaga.js

@@ -0,0 +1,2 @@
+export const actionRegisterTypeSaga = (login, password) => 
+({type: 'REGISTER', login, password})

+ 12 - 0
src/actions/typeSaga/subscribeTypesSaga.js

@@ -0,0 +1,12 @@
+
+export const actionChangeSubscribeSaga = (followId,checkFollowId) =>
+({
+    type:"CHANGE_SUBSCRIBE", followId,checkFollowId
+})
+export const actionChangeFollowingType = (newResult) => ({
+    type:"UPDATE_FOLLOWING", newResult
+  })
+  
+  export const actionChangeFollowersType = (newResult) => ({
+    type:"UPDATE_FOLLOWERS", newResult
+  })

+ 6 - 0
src/actions/typeSaga/userTypesSaga.js

@@ -0,0 +1,6 @@
+export const actionFullProfilePageUserTypeSaga = (_id) =>
+  ({ type: "USER_PAGE", _id })
+  
+  
+  export const actionPostsPortionTypeSaga = (_id) => 
+  ({ type: 'USER_POSTS_PORTION', _id})

+ 12 - 0
src/actions/types/commentTypes.js

@@ -0,0 +1,12 @@
+export const actionAddCommentPostFeedType = (postId, newResult) => ({
+    type: 'ADD_COMMENT_POSTS',
+    postId,
+    newResult,
+  })
+  export const actionAddCommentType = (newResult) => ({
+    type:"ADD_COMMENT", newResult
+})
+export const actionAddSubCommentType = (commentId,newResult) => ({
+    type:"ANSWERS-COMMENT",commentId, newResult
+  })
+  

+ 8 - 0
src/actions/types/exploreTypes.js

@@ -0,0 +1,8 @@
+export const actionClearExplorePostsType = () =>
+  ({ type: 'CLEAR_EXPLORE_POSTS' })
+
+export const actionExploreType = (newPosts,newPostsExploreCount) => 
+  ({ type: 'ADD-EXPLORE-POSTS', newPosts, newPostsExploreCount })
+  
+  export const actionExploreTypeCount = (explorePostsCount) => 
+  ({ type: 'EXPLORE-COUNT', explorePostsCount })

+ 12 - 0
src/actions/types/feedTypes.js

@@ -0,0 +1,12 @@
+export const actionClearFeedPostsType = () => ({ type: 'CLEAR_POSTS' })
+
+
+export const actionFeedType = (newPosts, newPostsFeedCount) => ({
+  type: 'ADD-POSTS',
+  newPosts,
+  newPostsFeedCount,
+})
+export const actionFeedTypeCount = (postsFeedCount) => ({
+  type: 'COUNT',
+  postsFeedCount,
+})

+ 7 - 0
src/actions/types/likeTypes.js

@@ -0,0 +1,7 @@
+export const actionChangeLikeType = (newResult) => ({
+    type:"CHANGE_LIKE", newResult
+  })
+  export const actionAddLikePostFeedType = (newResult) => ({
+    type: 'LIKE_POST_FEED',
+    newResult,
+  })

+ 2 - 0
src/actions/types/loginTypes.js

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

+ 15 - 0
src/actions/types/myDataTypes.js

@@ -0,0 +1,15 @@
+export const actionProfilePageDataType = (aboutMe) => ({
+    type: 'PROFILE-PAGE',
+    aboutMe,
+  })
+
+export const actionClearAboutMeType = () => 
+({ type: 'REMOVE-DATA' })
+
+export const actionChangeFollowingType = (newResult) => ({
+  type:"UPDATE_FOLLOWING", newResult
+})
+
+export const actionUpdateAvatarType= (newResult) => ({
+type:"UPDATE_AVATAR", newResult
+})

+ 0 - 13
src/actions/types/postActionTypes.js

@@ -1,13 +0,0 @@
-
-export const actionOnePostType = (onePost) => ({ type: 'POST', onePost })
-export const actionClearOnePostType = () => ({ type: 'CLEAR_ONE_POST' })
-export const actionChangeLikeType = (newResult) => ({
-    type:"CHANGE_LIKE", newResult
-    
-  })
-  export const actionAddCommentType = (newResult) => ({
-    type:"ADD_COMMENT", newResult
-})
-export const actionAddSubCommentType = (commentId,newResult) => ({
-  type:"ANSWERS-COMMENT",commentId, newResult
-})

+ 17 - 0
src/actions/types/postTypes.js

@@ -0,0 +1,17 @@
+
+export const actionOnePostType = (onePost) =>
+  ({ type: 'POST', onePost })
+export const actionClearOnePostType = () =>
+  ({ type: 'CLEAR_ONE_POST' })
+export const actionChangeLikeType = (newResult) => ({
+    type:"CHANGE_LIKE", newResult
+  })
+
+export const actionPostsType = (newPosts, newPostsCount) => 
+  ({ type: 'ADD-USER-POSTS', newPosts, newPostsCount })
+  export const actionUserAllPostsType = (allPosts) => 
+  ({ type: 'USER-POSTS', allPosts })
+  export const actionClearAllPostsType= () =>
+  ({ type: 'CLEAR_ALL_POSTS' })
+  export const actionCountPostsType = (countPosts) =>
+  ({ type: "COUNT_ALL_POSTS", countPosts })

+ 28 - 0
src/actions/types/promiseTypes.js

@@ -0,0 +1,28 @@
+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) =>
+    ({ type: 'PROMISE_START', name, promise })
+
+    export const actionClearPromiseForName = (name) => ({
+      type: 'PROMISE_CLEAR',
+      name,
+    })
+    export const actionAllClearPromiseType = () => ({
+        type: 'PROMISE_All_CLEAR',
+      })
+      

+ 7 - 0
src/actions/types/subscribeTypes.js

@@ -0,0 +1,7 @@
+export const actionChangeFollowingType = (newResult) => ({
+    type:"UPDATE_FOLLOWING", newResult
+  })
+  
+  export const actionChangeFollowersType = (newResult) => ({
+    type:"UPDATE_FOLLOWERS", newResult
+  })

+ 17 - 0
src/actions/types/userTypes.js

@@ -0,0 +1,17 @@
+export const actionAvatarUpdateType = (aboutUser) => ({
+    type: 'CHANGE-AVATAR-USER',
+    aboutUser,
+})
+export const actionProfilePageDataUserType = (aboutUser) => ({
+  type: 'PROFILE-PAGE-USER',
+  aboutUser})
+  
+export const actionProfilePageData = (id) => 
+({ type: 'DATA_PROFILE', id })
+
+export const actionClearDataUserType = () =>
+  ({ type: 'CLEAR-DATA' })
+  
+  export const actionChangeFollowersType = (newResult) => ({
+    type:"UPDATE_FOLLOWERS", newResult
+  })

+ 2 - 5
src/components/EditAvatar.jsx

@@ -2,14 +2,11 @@ import { connect } from 'react-redux'
 import { message, Image, Button } from 'antd'
 import {
   actionUploadFile,
-  actionSetAvatar,
-  actionUserUpsert,
-  actionUserUpdate,
-} from '../actions'
+} from '../actions/query/uploadFilesQuery'
 import React, { useState, useEffect } from 'react'
 import { Dropzone, ConstructorModal } from '../helpers'
 import { Input } from './Input'
-import {actionSetAvatarTypeSaga} from '../redux/saga'
+import {actionSetAvatarTypeSaga} from '../actions/typeSaga/myDataTypesSaga'
 const EditAvatar = ({
   info,
   onSaveAvatar,

+ 2 - 2
src/components/HeaderButtons.jsx

@@ -1,5 +1,5 @@
 import user from '../materials/user.png'
-import { actionFullProfilePageUser } from '../redux/saga'
+import { actionFullProfilePageUserTypeSaga } from '../actions/typeSaga/userTypesSaga'
 import { Avatar, Button } from 'antd'
 import { CSearch } from './Search_Users'
 import { Link} from 'react-router-dom'
@@ -65,5 +65,5 @@ export const CUser = connect(
     my_Id: state.auth?.payload?.sub?.id,
     aboutMe: state.myData.aboutMe,
   }),
-  { onMyPage: actionFullProfilePageUser },
+  { onMyPage: actionFullProfilePageUserTypeSaga },
 )(User)

+ 3 - 3
src/components/Search_Users.jsx

@@ -2,10 +2,10 @@ import { Link } from 'react-router-dom'
 import { connect } from 'react-redux'
 import { Row, Col,Avatar, Input,  Popover } from 'antd'
 import user from '../materials/user.png'
-import { actionSearchUser } from '../actions'
+import { actionSearchUser } from '../actions/query/searchUserQuery'
 import {UserOutlined,SearchOutlined } from '@ant-design/icons'
 
-import { actionFullProfilePageUser } from '../redux/saga'
+import { actionFullProfilePageUserTypeSaga } from '../actions/typeSaga/userTypesSaga'
 import LinkToUser from './LinkToUser'
 export const ResultUserFind = ({
   userFind = [],
@@ -66,6 +66,6 @@ export const CSearch = connect(
 
   {
     onSearch: actionSearchUser,
-    onPageData: actionFullProfilePageUser,
+    onPageData: actionFullProfilePageUserTypeSaga,
   },
 )(SearchUser)

+ 3 - 8
src/components/Subscribe.jsx

@@ -1,8 +1,5 @@
-import {
-    actionFullUnSubscribe,
-    actionFullSubscribe,
-} from '../actions'
-import {actionChangeSubscribeSaga} from '../redux/saga'
+
+import {actionChangeSubscribeSaga} from '../actions/typeSaga/subscribeTypesSaga'
 import { Button} from 'antd'
 import { connect } from 'react-redux'
   
@@ -16,10 +13,9 @@ const Subscribe = ({
     const checkFollowId = aboutMeFollowing?.find(
       (follower) => follower?._id === followId,
   )?._id
-  console.log('check following in subscribe component', checkFollowId)
     return (
       <>
-        <div style={{ display: 'flex', alignItems:'center' }} onClick={()=>changeSubscribe(followId,checkFollowId)}>
+        <div style={{ display: 'flex' }} onClick={()=>changeSubscribe(followId,checkFollowId)}>
           {checkFollowId ?
           
             (
@@ -56,7 +52,6 @@ export const CSubscribe = connect((state) => ({
 export const CSubscribeLinkUser = connect((state) => ({
   myId: state.auth?.payload?.sub?.id,
   aboutMeFollowing: state.myData?.aboutMe?.following,
-  // followId: state.userData?.aboutUser?._id,
 }),
   {
     changeSubscribe:actionChangeSubscribeSaga

+ 3 - 2
src/components/authorization/LogOut.jsx

@@ -1,9 +1,10 @@
 import {
     actionClearDataLogoutTypeSaga,
-} from '../../redux/saga'
+} from '../../actions/typeSaga/logOutTypesSaga'
 import { LogOut } from '../HeaderButtons'
 import { connect } from 'react-redux'
 
 export const CLogout = connect(null, {
     onClick: actionClearDataLogoutTypeSaga,
-  })(LogOut)
+})(LogOut)
+  

+ 6 - 7
src/components/authorization/LoginForm.jsx

@@ -5,13 +5,13 @@ import { Link } from 'react-router-dom'
 import { message } from 'antd'
 import { useEffect } from 'react'
 import { ImportOutlined } from '@ant-design/icons'
-import {
-  actionClearDataLogoutTypeSaga,
-  actionLoginTypeSaga,
-  actionRegisterTypeSaga,
-} from '../../redux/saga'
+// import {
+//   actionClearDataLogoutTypeSaga,
+//   actionRegisterTypeSaga,
+// } from '../../redux/saga'
 import InitialForm from './InitialForm'
-import {actionClearPromiseForName} from '../../actions/index'
+import { actionClearPromiseForName } from '../../actions/types/promiseTypes'
+import { actionLoginTypeSaga } from '../../actions/typeSaga/loginTypesSaga'
 const LoginForm = ({ onLogin, children, auth, onClearPromise }) => {
  
   useEffect(() => {
@@ -36,7 +36,6 @@ const LoginForm = ({ onLogin, children, auth, onClearPromise }) => {
 }
 export const CLoginForm = connect(
     (state) => ({
-      // children: `Sign In`,
       auth: state.promise?.auth,
     }),
     {

+ 2 - 2
src/components/authorization/RegisterForm.jsx

@@ -7,9 +7,9 @@ import { useEffect } from 'react'
 import { ImportOutlined } from '@ant-design/icons'
 import {
   actionRegisterTypeSaga,
-} from '../../redux/saga'
+} from '../../actions/typeSaga/registerTypesSaga'
 import InitialForm from './InitialForm'
-import { actionClearPromiseForName } from '../../actions'
+import { actionClearPromiseForName } from '../../actions/types/promiseTypes'
 const RegisterForm = ({ onLogin, children, register,onClearPromise }) => {
  
     useEffect(() => {

+ 1 - 1
src/components/comment/Comment.jsx

@@ -7,7 +7,7 @@ import { CommentDate } from './CommentDate'
 import {
   actionAddSubCommentTypeSaga,
   actionFindSubCommentTypeSaga,
-} from '../../actions/typeSaga/postActionSaga'
+} from '../../actions/typeSaga/postTypesSaga'
 import { Typography } from 'antd'
 import CommentAuthor from './CommentAuthor'
 import CommentAvatar from './CommentAvatar'

+ 1 - 1
src/components/comment/Reply.jsx

@@ -1,7 +1,7 @@
 import React, { useState } from 'react'
 import { Input, Button } from 'antd'
 import { connect } from 'react-redux'
-import { actionAddSubCommentTypeSaga } from '../../actions/typeSaga/postActionSaga'
+import { actionAddSubCommentTypeSaga } from '../../actions/typeSaga/postTypesSaga'
 import { ReplyButton } from './SpoilerButton'
 export const CommentAction = ({ commentId }) => {
   return (

+ 4 - 4
src/components/like/Like.jsx

@@ -1,7 +1,7 @@
 import { HeartOutlined, HeartFilled } from '@ant-design/icons'
 import {
-  actionChangeLike, actionChangeFeedLike
-} from '../../redux/saga'
+  actionChangeLikeTypeSaga, actionChangeFeedLikeTypeSaga
+} from '../../actions/typeSaga/likeTypesSaga'
 import { connect } from 'react-redux'
 import ModalLikes from './ModalLikes'
 export const Like = ({
@@ -46,7 +46,7 @@ export const CLike = connect(
     my_Id: state.auth?.payload?.sub?.id || '',
   }),
   {
-    changeLike: actionChangeLike
+    changeLike: actionChangeLikeTypeSaga
   },
 )(AllLikes)
 
@@ -55,7 +55,7 @@ export const CLikeFeed = connect(
     my_Id: state.auth?.payload?.sub?.id || '',
   }),
   {
-    changeLike: actionChangeFeedLike
+    changeLike: actionChangeFeedLikeTypeSaga
   },
 )(AllLikes)
 

+ 21 - 0
src/helpers/getGQL.js

@@ -0,0 +1,21 @@
+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 gql = getGQL('/graphql')

+ 19 - 0
src/helpers/getGQLAnon.js

@@ -0,0 +1,19 @@
+
+export const getGQLAnon = (url) => (query, variables) =>
+fetch(url, {
+  method: 'POST',
+  headers: {
+    'Content-Type': 'application/json'
+  },
+  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 gqlAnon = getGQLAnon('/graphql')

+ 4 - 0
src/helpers/history.js

@@ -0,0 +1,4 @@
+import createHistory from 'history/createBrowserHistory'
+
+const history = createHistory()
+export default history

+ 0 - 3
src/helpers/index.js

@@ -2,9 +2,6 @@ import { Modal,Button } from 'antd'
 import { useDropzone } from 'react-dropzone'
 import React, {useEffect } from 'react'
 import { UploadOutlined } from '@ant-design/icons'
-import createHistory from 'history/createBrowserHistory'
-
-export const history = createHistory()
 
 export const ConstructorModal = ({
   title,

+ 10 - 14
src/pages/createAndEditPost/index.js

@@ -3,10 +3,9 @@ import { Link } from 'react-router-dom'
 import { connect } from 'react-redux'
 import {
   actionUploadFiles,
-  actionPostUpsert,
-  actionClearPromise,
-} from '../../actions'
-import { actionClearOnePostType } from '../../actions/types/postActionTypes'
+
+} from '../../actions/query/uploadFilesQuery'
+import { actionClearOnePostType } from '../../actions/types/postTypes'
 import { Button, message } from 'antd'
 import {
   Dropzone
@@ -17,10 +16,11 @@ import {
 } from '../../components/Sortable'
 import { arrayMoveImmutable } from 'array-move'
 import { Row, Col } from 'antd'
-import { history } from '../../helpers'
+import history  from '../../helpers/history'
 import { CustomInput } from '../../components/Input'
-import {actionCreateEditPost} from '../../redux/saga'
+import {actionCreateEditPostTypeSaga} from '../../actions/typeSaga/postTypesSaga'
 
+  import {actionClearPromiseForName} from '../../actions/types/promiseTypes'
 const checkRoute = ({ match }) => {
   console.log('match route', match)
 }
@@ -122,11 +122,7 @@ const PostEditor = ({
       </div>
       
         {checkLength()}
-     
-          {/* </Col> */}
-        {/* </Col> */}
-      {/* </Row> */}
-
+    
       <h2 className="Title"> Title </h2>
       <CustomInput
         state={state?.title || ''}
@@ -185,10 +181,10 @@ export const CPostCreator = connect(
     newPost:true
   }),
   {
-    onSave: actionCreateEditPost,
+    onSave: actionCreateEditPostTypeSaga,
     onFileDrop: actionUploadFiles,
     clearPostOne: actionClearOnePostType,
-    clearPromise: actionClearPromise,
+    clearPromise: actionClearPromiseForName,
   },
 )(PostEditor)
 
@@ -199,7 +195,7 @@ export const CPostEditor = connect(
     myId: state?.myData?.aboutMe?._id,
   }),
   {
-    onSave: actionCreateEditPost,
+    onSave: actionCreateEditPostTypeSaga,
     onFileDrop: actionUploadFiles,
     clearPostOne: actionClearOnePostType,
     // clearPromise: actionClearPromise,

+ 7 - 11
src/pages/explorePosts/index.js

@@ -1,16 +1,12 @@
-import {
-    actionOnePost,
-    actionExplorePosts,
-    actionFullExplorePosts,
-  } from '../../actions'
+
+import {actionOnePost} from '../../actions/query/postQuery'
+  import {actionFullExplorePostsTypeSaga} from '../../actions/typeSaga/exploreTypesSaga'
   import { Row, Col } from 'antd'
   import { Card } from '../../components/post/PostCard'
   import React, { useEffect, useState } from 'react'
   import { connect } from 'react-redux'
-  import {
-    actionClearExplorePosts,
-    actionAllClearExplore,
-  } from '../../redux/reducers/exploreReducer'
+
+import { actionClearExplorePostsType } from '../../actions/types/exploreTypes'
 import load from '../../materials/load.gif'
   
   const ExplorePosts = ({
@@ -89,9 +85,9 @@ import load from '../../materials/load.gif'
       explorePostsCount: state.explore?.explorePostsCount,
     }),
     {
-      onExlorePosts: actionFullExplorePosts,
+      onExlorePosts: actionFullExplorePostsTypeSaga,
       onPost: actionOnePost,
-      onClearExplore: actionClearExplorePosts,
+      onClearExplore: actionClearExplorePostsType,
     },
   )(ExplorePosts)
   

+ 7 - 19
src/pages/feedPosts/index.js

@@ -1,20 +1,11 @@
 import React, { useMemo, useState, useEffect } from 'react'
+
+import { actionFullAllGetPostsSaga } from '../../actions/typeSaga/feedTypesSaga'
 import {
-  actionAllPostsFeed,
-  actionFullAllGetPosts,
-  actionAddSubFullComment,
-  actionFindLikes,
-  actionGetFindLiked,
-  actionDeleteFullLike,
-  actionAddFullLikeForFeed,
-  actionDeleteFullLikeForFeed,
-  actionAddFullLike,
-} from '../../actions'
-import {
-  actionClearFeedPostsType,
   actionAddCommentFeedTypeSaga
 } from
-  '../../redux/reducers/feedReducer'
+  '../../actions/typeSaga/commentTypesSaga'
+import {actionClearFeedPostsType} from '../../actions/types/feedTypes'
 import { Link } from 'react-router-dom'
 import { Provider, connect } from 'react-redux'
 import { Upload, Button, DatePicker, Space } from 'antd'
@@ -30,7 +21,7 @@ import load from '../../materials/load.gif'
 import {
   actionAddSubCommentTypeSaga,
   actionFindSubCommentTypeSaga,
-} from '../../actions/typeSaga/postActionSaga'
+} from '../../actions/typeSaga/postTypesSaga'
 import { CLikeFeed } from '../../components/like/Like'
 const MyPostFeed = ({
   // myData,
@@ -108,8 +99,7 @@ const MyPostFeed = ({
                       </div>
                       <div style={{ display: 'flex', margin: '20px 0px' }}>
                       <CLikeFeed likes={likes} postId={_id}/>
-                          {/* <CLikeForFeed likes={likes} postId={_id} /> */}
-
+                  
                           <AddComment addComment={addComment}
                             postId={_id} style={{
                               position: 'absolute', bottom: '70px',
@@ -120,10 +110,8 @@ const MyPostFeed = ({
                     
                         </div>
                         </div>
-                       {/* </center> */}
                     </div>
                   </div>
-                //  </div>
                 ),
               )}
              
@@ -169,7 +157,7 @@ export const CPostForFeed = connect(
   }),
   {
 
-    onPostsFeed: actionFullAllGetPosts,
+    onPostsFeed: actionFullAllGetPostsSaga,
     onClearFeed: actionClearFeedPostsType,
     addComment: actionAddCommentFeedTypeSaga,
     // addCommentReply: actionAddSubFullComment,

+ 3 - 13
src/pages/onePost/index.js

@@ -1,9 +1,4 @@
 import { Link } from 'react-router-dom'
-import {
-  actionAddSubFullComment,
-  actionDeleteFullLike,
-  actionAddFullLike,
-} from '../../actions'
 
 import { Avatar, Divider, Input, Button } from 'antd'
 import user from '../../materials/user.png'
@@ -12,13 +7,11 @@ import { Row, Col } from 'antd'
 import { CComments, CCommentsOnePost } from '../../components/comment/Comment'
 import { CPostEditor } from '../createAndEditPost'
 import  AddComment from '../../components/comment/AddComment'
-import { actionFullOnePostSaga,actionAddFullCommentSaga } from '../../actions/typeSaga/postActionSaga'
+import { actionFullOnePostSaga,actionAddFullCommentSaga } from '../../actions/typeSaga/postTypesSaga'
 import { CLike} from '../../components/like/Like'
 import { ConstructorModal } from '../../helpers'
 import React, { useState, useEffect } from 'react'
-import {
-  actionAddFullCommentFeed,
-} from '../../redux/saga'
+
 import { LinkToUser } from '../../components/LinkToUser'
 import { MyCarousel } from '../../components/post/Carousel'
 import {EditMyPostButton} from '../../components/EditPostButton'
@@ -80,10 +73,7 @@ export const PagePost = ({
           <h2> Text: {onePost?.text || ''} </h2>
           <Divider>Comments</Divider>
           <div className="Scroll">
-            {/* <CCommentsOnePost
-              postId={onePost?._id}
-              comments={onePost?.comments || []}
-            /> */}
+
             <CCommentsOnePost/>
           </div>
           <div style={{ display: 'flex', margin: '20px 0px' }}>

+ 3 - 3
src/pages/profilePage/index.js

@@ -1,11 +1,11 @@
-import { actionOnePost, actionUploadFile } from '../../actions'
+import {actionOnePost} from '../../actions/query/postQuery'
 import user from '../../materials/user.png'
 import React, { useState, useEffect } from 'react'
 import { Card } from '../../components/post/PostCard'
 import ListOfUsers from '../../components/ListOfUsers'
 import { connect } from 'react-redux'
 import { Avatar, Button } from 'antd'
-import { actionFullProfilePageUser } from '../../redux/saga'
+import { actionFullProfilePageUserTypeSaga } from '../../actions/typeSaga/userTypesSaga'
 import { Row, Col } from 'antd'
 import {actionClearAllPostsType,actionPostsPortionTypeSaga} from '../../redux/reducers/userProfileReducer'
 import { CSubscribe } from '../../components/Subscribe'
@@ -170,7 +170,7 @@ export const CPageAboutUser = connect(
     userPostPromise:state.promise?.allPosts
   }),
   {
-    onAboutUser: actionFullProfilePageUser,
+    onAboutUser: actionFullProfilePageUserTypeSaga,
     onPost: actionOnePost,
     onClearPosts: actionClearAllPostsType,
     onUserPosts:actionPostsPortionTypeSaga

+ 3 - 8
src/pages/setting/index.js

@@ -4,17 +4,12 @@ import { CustomInput } from '../../components/Input'
 import { message, Image, Button } from 'antd'
 import { connect } from 'react-redux'
 import {
-  actionUploadFile,
-  actionSetAvatar,
-  actionUserUpsert,
-  actionUserUpdate,
   actionChangePassword,
-  actionClearPromiseForName,
-} from '../../actions'
-
+} from '../../actions/query/aboutMeQuery'
+import {actionClearPromiseForName} from '../../actions/types/promiseTypes'
 import { Basic, ConstructorModal } from '../../helpers'
 import { SpoilerButton } from '../../components/comment/SpoilerButton'
-import { actionUserUpdateTypeSaga } from '../../redux/saga'
+import { actionUserUpdateTypeSaga } from '../../actions/typeSaga/myDataTypesSaga'
 import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'
 export const EditAccount = ({ showModalEdit }) => {
   return (

+ 0 - 80
src/redux/index.js

@@ -1,80 +0,0 @@
-import { createStore, combineReducers, applyMiddleware } from 'redux'
-import thunk from 'redux-thunk'
-import { promiseReducer } from './reducers/promiseReducer'
-import { authReducer } from './reducers/authReducer'
-import { myProfileReducer } from './reducers/myProfileReducer'
-import { userProfileReducer } from './reducers/userProfileReducer'
-import { feedReducer } from './reducers/feedReducer'
-import { postReducer } from './reducers/postReducer'
-import { exploreReducer } from './reducers/exploreReducer'
-import {
-  promiseWatcher,
-  fullProfilePageWatcher,
-  loginWatcher,
-  fullPageAboutUserWatcher,
-  feedWatcher,
-  exploreWatcher,
-onePostWatcher,
-  addCommentFeedWatcher,
-  addCommentOnePostWatcher,
-  changeLikePostWatcher,
-  editPostWatcher,
-  changeSubscribeWatcher,
-  userUpdateWatcher,
-  setAvatarWatcher,
-  clearAllDataWatcher,
-  registerWatcher,
-  postsWatcher,
-  addSubCommentWatcher,
-  getSubCommentWatcher,
-  changeLikePostFeedWatcher
-} from './saga'
-import createSagaMiddleware from 'redux-saga' //функция по созданию middleware
-import {
-  all,
-  put,
-  takeEvery,
-  takeLatest,
-  takeLeading,
-  select,
-} from 'redux-saga/effects' //
-const sagaMiddleware = createSagaMiddleware()
-
-export const store = createStore(
-  combineReducers({
-    promise: promiseReducer,
-    auth: authReducer,
-    myData: myProfileReducer,
-    userData: userProfileReducer,
-    feed: feedReducer,
-    post: postReducer,
-    explore: exploreReducer,
-  }),
-  applyMiddleware(sagaMiddleware),
-)
-function* rootSaga() {
-  yield all([
-    promiseWatcher(), 
-    fullProfilePageWatcher(),
-    loginWatcher(),
-    registerWatcher(),
-    fullPageAboutUserWatcher(),
-    feedWatcher(),
-    exploreWatcher(),
-    onePostWatcher(),
-    addCommentOnePostWatcher(),
-    changeLikePostWatcher(),
-    editPostWatcher(),
-    changeSubscribeWatcher(),
-    userUpdateWatcher(),
-    setAvatarWatcher(),
-    clearAllDataWatcher(),
-    postsWatcher(),
-    addCommentFeedWatcher(),
-    addSubCommentWatcher(),
-    getSubCommentWatcher(),
-    changeLikePostFeedWatcher()
-    // addCommentFeedWatcher()
-  ])
-}
-sagaMiddleware.run(rootSaga)

+ 0 - 16
src/redux/reducers/exploreReducer.js

@@ -34,19 +34,3 @@ export const exploreReducer = (
     }
     return state
 }
-// export const actionAllClearExplore = () => async (dispatch) => {
-//   Promise.all([
-//     await dispatch(actionClearPromiseForName('explorePosts')),
-//     await dispatch(actionClearPromiseForName('explorePostsCount')),
-//       await dispatch(actionClearExplorePosts())
-//   ])
-
-// }
-export const actionClearExplorePosts = () =>
-  ({ type: 'CLEAR_EXPLORE_POSTS' })
-
-export const actionExploreType = (newPosts,newPostsExploreCount) => 
-  ({ type: 'ADD-EXPLORE-POSTS', newPosts, newPostsExploreCount })
-  
-  export const actionExploreTypeCount = (explorePostsCount) => 
-  ({ type: 'EXPLORE-COUNT', explorePostsCount })

+ 2 - 34
src/redux/reducers/feedReducer.js

@@ -1,6 +1,3 @@
-import { actionClearPromiseForName } from '../../actions'
-// import { actionClearDataUserType } from '../profileUserPage/profileUserReducer'
-// import { actionProfilePageDataTypeUser } from '../profileUserPage/profileUserReducer'
 
 export const feedReducer = (
     state = {},
@@ -11,9 +8,7 @@ export const feedReducer = (
         return {
           ...state,
           postsFeed: state?.postsFeed ? [...state.postsFeed, ...newPosts] : [...newPosts],
-          // postsFeed: [...postsFeed || [], ...newPosts],
           postsFeedCount: postsFeedCount ? postsFeedCount : newPostsFeedCount
-         // postsFeed: postsFeed ? [...postsFeed, ...newPosts] : [...newPosts],
         }
       },
       'COUNT': () => {
@@ -34,13 +29,13 @@ export const feedReducer = (
         postsFeedCount: 0,
     }),
   
-      'LIKE-POST-FEED': () => ({
+      'LIKE_POST_FEED': () => ({
         ...state,
         postsFeed: postsFeed?.map((p) =>
           p._id === postId ? (p = { ...p, likes: [...newResult] }) : p,
         ),
       }),
-      'ADD-COMMENT-POSTS': () => ({
+      'ADD_COMMENT_POSTS': () => ({
         ...state,
         
         postsFeed: postsFeed?.map((p) =>
@@ -54,30 +49,3 @@ export const feedReducer = (
     return state
 }
 
-// export const actionFullClearFeedPosts = () => (dispatch) => {
-//   return dispatch(actionClearFeedPosts())
-// }
-
-export const actionClearFeedPostsType= () =>
-  ({ type: 'CLEAR_POSTS' })
-
-//type
-export const actionAddLikePostFeedType = (newResult) =>
- ({ type: 'LIKE-POST-FEED',newResult })
-
-
-  export const actionAddCommentPostFeedType = (postId, newResult) => ({
-    type: 'ADD-COMMENT-POSTS',
-    postId,
-    newResult,
-  })
-
-export const actionFeedType = (newPosts, newPostsFeedCount) => 
-({ type: 'ADD-POSTS', newPosts,newPostsFeedCount })
-export const actionFeedTypeCount = (postsFeedCount) => 
-({ type: 'COUNT', postsFeedCount })
-
-export const actionAddCommentFeedTypeSaga = (postId, text) => ({
-  type:"FEED_POST_COMMENT", postId, text
-  
-})

+ 0 - 18
src/redux/reducers/myProfileReducer.js

@@ -35,21 +35,3 @@ export const myProfileReducer = (state = {}, { type, aboutMe, newResult }) => {
     }
     return state
   }
-    //type
-    export const actionProfilePageDataType = (aboutMe) => ({
-      type: 'PROFILE-PAGE',
-      aboutMe,
-    })
-    
-
-  
-  export const actionClearAboutMeType = () => 
-  ({ type: 'REMOVE-DATA' })
-  
-  export const actionChangeFollowingType = (newResult) => ({
-    type:"UPDATE_FOLLOWING", newResult
-})
-  
-export const actionUpdateAvatarType= (newResult) => ({
-  type:"UPDATE_AVATAR", newResult
-})

+ 0 - 2
src/redux/reducers/postReducer.js

@@ -1,5 +1,3 @@
-import { PlusOutlined } from '@ant-design/icons'
-import { actionOnePost } from '../../actions'
 
 const addAnswers = (comments, commentId, newResult) =>
 comments.map(comment => {

+ 49 - 0
src/redux/rootSaga.js

@@ -0,0 +1,49 @@
+import { clearAllDataWatcher } from './saga/logOut'
+import { feedWatcher } from './saga/feed'
+import { all } from 'redux-saga/effects'
+import { promiseWatcher } from './saga/promise'
+import { loginWatcher } from './saga/login'
+import { registerWatcher } from './saga/register'
+import {
+  fullProfilePageWatcher,
+  userUpdateWatcher,
+  setAvatarWatcher,
+} from './saga/myProfile'
+import { fullPageAboutUserWatcher } from './saga/userProfile'
+import { exploreWatcher } from './saga/explore'
+import {
+  addCommentFeedWatcher,
+  addCommentOnePostWatcher,
+  addSubCommentWatcher,
+  getSubCommentWatcher,
+} from './saga/comment'
+import { onePostWatcher, postsWatcher } from './saga/post'
+import { changeLikePostWatcher, changeLikePostFeedWatcher } from './saga/like'
+import { changeSubscribeWatcher } from './saga/subscribe'
+import { editPostWatcher } from './saga/post'
+function* rootSaga() {
+  yield all([
+    promiseWatcher(),
+    fullProfilePageWatcher(),
+    loginWatcher(),
+    registerWatcher(),
+    fullPageAboutUserWatcher(),
+    feedWatcher(),
+    exploreWatcher(),
+    onePostWatcher(),
+    addCommentOnePostWatcher(),
+    changeLikePostWatcher(),
+    editPostWatcher(),
+    changeSubscribeWatcher(),
+    userUpdateWatcher(),
+    setAvatarWatcher(),
+    clearAllDataWatcher(),
+    postsWatcher(),
+    addCommentFeedWatcher(),
+    addSubCommentWatcher(),
+    getSubCommentWatcher(),
+    changeLikePostFeedWatcher(),
+  ])
+}
+
+export default rootSaga

+ 73 - 0
src/redux/saga/comment/index.js

@@ -0,0 +1,73 @@
+import { all, put,take, fork, takeEvery, takeLatest, takeLeading, select,call, join } from 'redux-saga/effects'; //
+import { promiseWorker } from '../promise';
+import {
+    actionAddComment, actionGetCommentsOnePost,
+    actionAddSubComment, actionFindSubComment
+} from '../../../actions/query/commentQuery'
+import { actionOnePost } from '../../../actions/query/postQuery'
+import {actionAddCommentPostFeedType, actionAddCommentType, actionAddSubCommentType} from '../../../actions/types/commentTypes'
+
+// actionAddCommentFeedTypeSaga
+function* addCommentOnePostWorker({ postId, text }) {
+    yield call(promiseWorker, actionAddComment(postId, text))
+    const {
+      promise: {
+        addComment: { status },
+      },
+    } = yield select()
+    if (status === 'FULFILLED') {
+      yield call(promiseWorker, actionOnePost(postId))
+      const { comments } = yield call(promiseWorker, actionGetCommentsOnePost(postId))
+      if (comments)
+        yield put (actionAddCommentType(comments))
+    }
+  }
+  export function* addCommentOnePostWatcher(){
+    yield takeLeading("ONE_POST_COMMENT",addCommentOnePostWorker)
+  }
+
+  function* addCommentFeedWorker({ postId, text }) {
+    yield call(promiseWorker, actionAddComment(postId, text))
+    const {
+      promise: {
+        addComment: { status },
+      },
+    } = yield select()
+    if (status === 'FULFILLED') {
+      yield call(promiseWorker, actionOnePost(postId))
+      const { comments } = yield call(promiseWorker,
+        actionGetCommentsOnePost(postId))
+      if (comments)
+        yield put (actionAddCommentPostFeedType(postId,comments))
+    }
+  }
+  export function* addCommentFeedWatcher(){
+    yield takeLeading("FEED_POST_COMMENT",addCommentFeedWorker)
+}
+function* addSubCommentWorker({ commentId, newResult }) {
+    yield call(promiseWorker, actionAddSubComment(commentId, newResult))
+    console.log('newResult ', newResult)
+    const {
+      promise: {
+        addSubComment: { status },
+      },
+    } = yield select()
+    if (status === 'FULFILLED') {
+      yield call(getSubCommentWorker, {commentId})
+      }
+    }
+  
+  export function* addSubCommentWatcher() {
+    yield takeEvery("POST_SUB_COMMENT", addSubCommentWorker)
+  }
+  function* getSubCommentWorker({ commentId }) {
+    const { answers } = yield call(promiseWorker,
+      actionFindSubComment(commentId))
+    if (answers) {
+        yield put(actionAddSubCommentType(commentId, answers))
+    }
+  }
+  
+  export function* getSubCommentWatcher() {
+    yield takeEvery("GET_SUB_COMMENT", getSubCommentWorker)
+  }

+ 27 - 0
src/redux/saga/explore/index.js

@@ -0,0 +1,27 @@
+
+ import { all, put,take, fork, takeEvery, takeLatest, takeLeading, select,call, join } from 'redux-saga/effects'; //
+ import { promiseWorker } from '../promise';
+import {actionExplorePostsCount,actionExplorePosts } from '../../../actions/query/exploreQuery'
+import { actionExploreType } from '../../../actions/types/exploreTypes'
+function* exploreWorker() {
+    const {
+      explore: { explorePosts, explorePostsCount },
+    } = yield select()
+    console.log('explorePosts', explorePosts)
+  
+    if (explorePosts?.length !== (explorePostsCount ? explorePostsCount : 1)) {
+      console.log('explorePosts', explorePosts)
+  
+      const newPosts = yield call(promiseWorker,
+        actionExplorePosts(explorePosts?.length))
+  
+      console.log('newPosts', newPosts)
+  
+      const newPostsExploreCount = yield call(promiseWorker, (actionExplorePostsCount()))
+      if (newPosts && newPostsExploreCount)
+        yield put(actionExploreType(newPosts, newPostsExploreCount))
+    }
+  }
+  export function* exploreWatcher() {
+    yield takeLeading("EXPLORE_POSTS", exploreWorker)
+  }

+ 38 - 0
src/redux/saga/feed/index.js

@@ -0,0 +1,38 @@
+import { all, put,take, fork, takeEvery, takeLatest, takeLeading, select,call, join } from 'redux-saga/effects'; //
+import { fullProfilePageWorker } from '../../saga/myProfile'
+import { promiseWorker } from '../promise';
+import {actionFullProfilePageTypeSaga} from '../../../actions/typeSaga/myDataTypesSaga'
+import {
+    actionPostsFeed,
+    actionPostsFeedCount
+} from '../../../actions/query/postFeedQuery'
+import { actionFeedType } from '../../../actions/types/feedTypes'
+function* feedWorker() {
+    const {
+      feed: { postsFeed, postsFeedCount },
+      myData: { aboutMe},
+      
+    }  = yield select()
+    let myFollowing = aboutMe?.following && aboutMe?.following?.map(({ _id }) => _id)
+    const myId = (yield select()).auth?.payload?.sub?.id
+  
+    if (!aboutMe) {
+      yield call(fullProfilePageWorker, actionFullProfilePageTypeSaga())
+    }
+    myFollowing = (yield select()).myData.aboutMe?.following &&
+      (yield select()).myData.aboutMe?.following?.map(({ _id }) => _id)
+    if (postsFeed?.length !== (postsFeedCount ? postsFeedCount : 1)) {
+      const newPosts = yield call(promiseWorker, 
+        actionPostsFeed([...(myFollowing || []), myId], postsFeed?.length),
+      )
+      const newPostsFeedCount = yield call(promiseWorker, (
+        actionPostsFeedCount([...(myFollowing || []), myId])))
+      if (newPosts && newPostsFeedCount) {
+        yield put(actionFeedType(newPosts, newPostsFeedCount))
+      }
+    }
+  }
+  
+  export function* feedWatcher() {
+    yield takeLeading("FEED_POSTS", feedWorker)
+  }

+ 0 - 550
src/redux/saga/index.js

@@ -1,550 +0,0 @@
-
-import {
-    actionAboutMe,
-    actionAllPostsUser,
-    actionAboutUser,
-    actionPostsFeed,
-    actionPostsFeedCount,
-    actionOnePost,
-    actionAddComment,
-    actionAddLike,
-    actionDeleteLike,
-    actionPostsCount,
-  actionAuthLogout,
-  actionRegister,
-  actionGetAvatar,
-  actionAddSubComment,
-  actionAllClearPromise,
-  actionAvatar,
-  actionLogin,
-  actionAuthLogin,
-  actionClearPromise,
-  actionGetCommentsOnePost,
-  actionFindLikes,
-  actionPostUpsert,
-  actionClearPromiseForName,
-  actionChangeSubscribe,
-  actionGetFollowing,
-  actionGetFollowers,
-  actionUserUpsert,
-  actionAllClearPromiseType,
-  actionFindSubComment
-  // actionOnePost
-} from '../../actions'
-import { message } from 'antd'
-
-import { actionClearAboutMeType } from '../reducers/myProfileReducer'
-import { history } from '../../helpers'
-import {
-  actionClearDataUserType,
-  actionChangeFollowersType,
-  actionUserAllPostsType,
-  actionPostsType
-
-} from '../reducers/userProfileReducer'
-import { actionProfilePageDataType,actionChangeFollowingType } from '../reducers/myProfileReducer'
-import { actionFullAllGetPosts } from '../../actions'
-import {
-  actionAddLikePostInTape,
-  actionDeleteLikePostInTape,
-  actionAddCommentPostInTape,
-  actionClearFeedPosts,
-  actionFeedType,
-  actionClearFeedPostsType,
-  actionAddCommentPostFeedType,
-  actionAddLikePostFeedType
-} from '../reducers/feedReducer'
-import { actionProfilePageDataTypeUser,actionCountPostsType } from '../reducers/userProfileReducer'
-import { actionRemoveDataAboutMe,actionUpdateAvatarType } from '../reducers/myProfileReducer'
-import {actionExploreType,actionClearExplorePosts} from '../reducers/exploreReducer'
-import { all, put,take, fork, takeEvery, takeLatest, takeLeading, select,call, join } from 'redux-saga/effects'; //
-import {actionPending,actionFulfilled,actionRejected,actionExplorePosts,actionExplorePostsCount} from '../../actions'
-import { actionOnePostType, actionChangeLikeType } from '../../actions/types/postActionTypes'
-import {actionAddCommentType,actionAddSubCommentType} from '../../actions/types/postActionTypes'
-import { actionAddSubCommentTypeSaga } from '../../actions/typeSaga/postActionSaga'
-//promise 
- export function* promiseWorker(action){ //это типа actionPromise который thunk
-    const {name, promise} = action
-    yield put(actionPending(name)) //это как dispatch
-    try {
-        let data = yield promise //а это как await
-        yield put(actionFulfilled(name, data))
-        return data //а этот результать можно забрать через yield call(promiseWorker, actionPromise(......) /*какой-то объект action*/)
-    }
-    catch (error) {
-        yield put(actionRejected(name, error))
-    }
-  }
-  
-  export function* promiseWatcher(){
-    yield takeEvery('PROMISE_START', promiseWorker)
-}
-
-//login
-function* loginWorker({login, password}){ //обработчик экшона FULL_LOGIN
-  let token = yield call(promiseWorker,actionLogin(login, password)) //dispatch(actionLogin(login, password));
-  console.log('token login ', token)
-  if (token) {
-      yield put(actionAuthLogin(token));
-  }
-  
-}
-export function* loginWatcher() {
-yield takeEvery("FULL_LOGIN", loginWorker)
-
-}
-export const actionLoginTypeSaga = (login, password) =>  //упрощенный action для саги
-({type: 'FULL_LOGIN', login, password})
-
-//register 
-
-function* registerWorker({ login, password }) {
-  let token = yield call(promiseWorker,actionRegister(login, password)) //dispatch(actionLogin(login, password));
-  console.log('token reg ', token)
-  if (token) {
-  console.log('token reg в ифе ', token)
-    yield put(actionLoginTypeSaga(login, password ))
-    history.push('/feed')
-  }
-}
-export function* registerWatcher() {
-yield takeEvery("REGISTER", registerWorker)
-
-}
-export const actionRegisterTypeSaga = (login, password) =>  //упрощенный action для саги
-({type: 'REGISTER', login, password})
-
-
-//profile page about me
-export const actionFullProfilePage = () =>
-({
-    type:"FULLPROFILE_PAGE",
-})
-
-function* fullProfilePageWorker() {
-  const { auth } = yield select()
-  // console.log('auth', auth)
-  if (auth?.payload?.sub?.id) {
-    const aboutMe = yield call(promiseWorker, actionAboutMe(auth?.payload?.sub.id))
-  // console.log('aboutMe in worker', aboutMe)
-   
-    if (aboutMe) {
-      yield put(actionProfilePageDataType(aboutMe))
-    
-    }
-  }
-}
-
-export function* fullProfilePageWatcher() {
-  yield takeEvery("FULLPROFILE_PAGE", fullProfilePageWorker)
-}
-
-//aboutUser
-//full profile user
-
-export const actionFullProfilePageUser = (_id) =>
-  ({ type: "USER_PAGE", _id })
-  
-function* fullPageAboutUserWorker({ _id }) {
-  // console.log('_id ',  _id)
-  const aboutUser = yield call(promiseWorker, actionAboutUser(_id))
-  // console.log('about user',  aboutUser)
-  const allPosts = yield call(promiseWorker, actionAllPostsUser(_id))
-  const countPosts = yield call(promiseWorker, actionPostsCount(_id))
-
-  if (aboutUser)
-  yield put(actionProfilePageDataTypeUser(aboutUser))
-  
-  if(allPosts) {
-    yield put(actionUserAllPostsType(allPosts))
-  }
-  if (countPosts)
-  yield put(actionCountPostsType(countPosts))
-  }
-
-
-export function* fullPageAboutUserWatcher() {
-  yield takeLeading("USER_PAGE", fullPageAboutUserWorker)
-}
-function* feedWorker() {
-  const {
-    feed: { postsFeed, postsFeedCount },
-    myData: { aboutMe},
-    
-  }  = yield select()
-  let myFollowing = aboutMe?.following && aboutMe?.following?.map(({ _id }) => _id)
-  const myId = (yield select()).auth?.payload?.sub?.id
-
-  if (!aboutMe) {
-    yield call(fullProfilePageWorker, actionFullProfilePage())
-  }
-  myFollowing = (yield select()).myData.aboutMe?.following &&
-    (yield select()).myData.aboutMe?.following?.map(({ _id }) => _id)
-  // console.log('myFollowing after if', myFollowing)
-  if (postsFeed?.length !== (postsFeedCount ? postsFeedCount : 1)) {
-    const newPosts = yield call(promiseWorker, 
-      actionPostsFeed([...(myFollowing || []), myId], postsFeed?.length),
-    )
-    console.log('newPosts', newPosts)
-    const newPostsFeedCount = yield call(promiseWorker, (
-      actionPostsFeedCount([...(myFollowing || []), myId])))
-    if (newPosts && newPostsFeedCount) {
-      console.log('newPosts', newPosts)
-      yield put(actionFeedType(newPosts, newPostsFeedCount))
-    }
-  }
-}
-
-export function* feedWatcher() {
-  yield takeLeading("FEED_POSTS", feedWorker)
-}
-
-function* postsWorker({_id}) {
-  const {
-    userData: {aboutUser, allPosts,countPosts },
-    // myData: { aboutMe },
-    // promise:{countAllPostsUser:{payload}}
-    
-  } = yield select()
-  
-  if (allPosts?.length !== (countPosts ? countPosts : 1)) {
-    const newPosts = yield call(promiseWorker, 
-      actionAllPostsUser(_id, allPosts?.length),
-    )
-    const newPostsCount = yield call(promiseWorker, 
-      actionPostsCount(_id))
-    if (newPosts && newPostsCount) {
-      yield put(actionPostsType(newPosts, newPostsCount))
-    }
-  }
-}
-
-export function* postsWatcher() {
-  yield takeLeading("USER_POSTS_PORTION", postsWorker)
-}
-
-//explore 
-function* exploreWorker(){
-  const {
-    explore: { explorePosts, explorePostsCount },
-  } = yield select()
-  console.log('explorePosts', explorePosts)
-
-  if (explorePosts?.length !== (explorePostsCount ? explorePostsCount : 1)) {
-    console.log('explorePosts', explorePosts)
-
-    const newPosts = yield call(promiseWorker,
-      actionExplorePosts(explorePosts?.length))
-
-    console.log('newPosts', newPosts)
-
-    const newPostsExploreCount = yield call(promiseWorker, (actionExplorePostsCount()))
-    if (newPosts && newPostsExploreCount)
-      yield put(actionExploreType(newPosts, newPostsExploreCount))
-  }
-}
-export function* exploreWatcher() {
-  yield takeLeading("EXPLORE_POSTS", exploreWorker)
-}
-
-// export const actionAddFullCommentFeed = (postId, newResult) => async (
-//   dispatch,
-//   getState,
-// ) => {
-//   await dispatch(actionAddComment(postId, newResult))
-//   const {
-//     promise: {
-//       addComment: { status },
-//     },
-//   } = getState()
-//   if (status === 'FULFILLED') {
-//     const onePost = await dispatch(actionOnePost(postId))
-//     if (onePost) await dispatch(actionAddCommentPostInTape(postId, newResult))
-//   }
-//   // await dispatch(actionOnePost(postId));
-// }
-
-//one post
-function* onePostWorker({ _id }) {
-  
-  const onePost = yield call(promiseWorker,actionOnePost(_id))
-  if (onePost)
-  yield put(actionOnePostType(onePost))
-}
-export function* onePostWatcher(){
-yield takeLeading("ONE_POST",onePostWorker)
-}
-
-//comment
-
-function* addCommentOnePostWorker({ postId, text }) {
-  yield call(promiseWorker, actionAddComment(postId, text))
-  const {
-    promise: {
-      addComment: { status },
-    },
-  } = yield select()
-  if (status === 'FULFILLED') {
-    yield call(promiseWorker, actionOnePost(postId))
-    const { comments } = yield call(promiseWorker, actionGetCommentsOnePost(postId))
-    if (comments)
-      yield put (actionAddCommentType(comments))
-  }
-}
-export function* addCommentOnePostWatcher(){
-  yield takeLeading("ONE_POST_COMMENT",addCommentOnePostWorker)
-}
-  
-
-function* addCommentFeedWorker({ postId, text }) {
-  yield call(promiseWorker, actionAddComment(postId, text))
-  const {
-    promise: {
-      addComment: { status },
-    },
-  } = yield select()
-  if (status === 'FULFILLED') {
-    yield call(promiseWorker, actionOnePost(postId))
-    const { comments } = yield call(promiseWorker,
-      actionGetCommentsOnePost(postId))
-    if (comments)
-      yield put (actionAddCommentPostFeedType(postId,comments))
-  }
-}
-export function* addCommentFeedWatcher(){
-  yield takeLeading("FEED_POST_COMMENT",addCommentFeedWorker)
-  }
-
-// export const actionAddFullLike = (postId) => async (dispatch, getState) => {
-//     await dispatch(actionAddLike(postId))
-//     const {
-//       promise: {
-//         addLike: { status },
-//       },
-//     } = getState()
-//     if (status === 'FULFILLED') {
-//       const onePost = await dispatch(actionOnePost(postId))
-//       if (onePost) await dispatch(actionAddLikePostInTape(postId))
-//     }
-// }
-
-//change like in post
-export const actionChangeLike = (likeId, postId) =>
-({
-    type:"CHANGE_LIKE_POST", likeId,postId
-})
-
-
-  
-function* changeLikeWorker({ likeId, postId }) {
-  console.log('likeId', likeId)
-  console.log('postId', postId)
-
-  const changeOneLike = () =>
-    likeId ? actionDeleteLike(likeId, postId) : actionAddLike(postId)
-
-  yield call(promiseWorker, changeOneLike())
-  return yield call(promiseWorker, actionFindLikes(postId))
-  
-}
-
-function* changeLikePostWorker({ likeId, postId }) {
- 
-  const { likes } = yield call(changeLikeWorker, {likeId, postId})
-  if (likes) {
-  
-    // yield call(promiseWorker, actionOnePost(postId))
-    yield put(actionChangeLikeType(likes))
-  }
-}
-
-function* changeLikePostFeedWorker({ likeId, postId }) {
-  const { likes } = yield call(changeLikeWorker, {likeId, postId})
-  if (likes) {
-  
-    // yield call(promiseWorker, actionOnePost(postId))
-    yield put(actionAddLikePostFeedType(likes))
-  }
-}
-
-
-export function* changeLikePostWatcher() {
-  yield takeLeading("CHANGE_LIKE_POST", changeLikePostWorker)
-}
-
-//change like in post feed
-export const actionChangeFeedLike = (likeId, postId) =>
-({
-    type:"CHANGE_LIKE_POST_FEED", likeId,postId
-})
-
-export function* changeLikePostFeedWatcher() {
-  yield takeLeading("CHANGE_LIKE_POST_FEED", changeLikePostFeedWorker)
-}
-
-// create and edit post
-
-function* editPostWorker({state }) {
-  
-  console.log('in worker default post', state)
-  console.log('in worker post id', state?._id)
-  const postUpsert = yield call(promiseWorker, actionPostUpsert(state,state?._id))
-  console.log('post Upsert', postUpsert)
-//   postUpsert
-//   const upsertPost = yield call(promiseWorker, actionPostUpsert(post))
-// console.log('upsert POST', upsertPost)
- 
-  if (postUpsert) {
-    yield put(actionClearPromiseForName('postUpsert'))
-    yield put(actionClearPromiseForName('uploadFiles'))
-  }
-  
-}
-export function* editPostWatcher() {
-  yield takeEvery("CREATE_EDIT_POST", editPostWorker)
-}
-export const actionCreateEditPost= (state) =>
-({
-    type:"CREATE_EDIT_POST", state
-})
-
-//change subscribe 
-function* changeSubscribeWorker({ followId, checkFollowId }) {
-  const { myData: { aboutMe: { _id, following } } } = yield select()
-  console.log('my following', following)
-  console.log('check follow id', checkFollowId)
-  console.log('my id', _id)
- 
-  const oldFollowing = checkFollowId ?
-    {
-      _id,
-      following: [...(following||[]).filter((item) =>
-        item._id !== followId).map(({ _id }) => ({ _id }))]
-    } 
-  : {
-      
-    _id,
-      following: [...(following||[]).map(({ _id }) =>
-        ({ _id })), { _id: followId }]
-    }
-  console.log('old following', oldFollowing)
-  console.log('еще раз май фолловинг ', following)
-  
-  const change = yield call(promiseWorker, actionChangeSubscribe(oldFollowing))
-console.log('change', change)
-
-  const updateUserFollowers = yield call(promiseWorker, actionGetFollowers(followId))
-  console.log('update user followers', updateUserFollowers)
-
-  const updateMyFollowing = yield call(promiseWorker, actionGetFollowing(_id))
-  console.log('update my following', updateMyFollowing)
-
-  if (updateMyFollowing)
-   yield put(actionChangeFollowingType(updateMyFollowing?.following))
- if (updateUserFollowers)
-    yield put(actionChangeFollowersType(updateUserFollowers?.followers))
-}
-
-
-export function* changeSubscribeWatcher() {
-  yield takeEvery("CHANGE_SUBSCRIBE", changeSubscribeWorker)
-}
-
-export const actionChangeSubscribeSaga= (followId,checkFollowId) =>
-({
-    type:"CHANGE_SUBSCRIBE", followId,checkFollowId
-})
-
-  //comment
-export const actionAddFullCommentFeed = (postId, newResult) => ({
-  type:"ADD_COMMENT_FEED", postId, newResult
-})
-
-export const actionUserUpdateTypeSaga = (user) => ({
-  type:"USER_UPDATE", user
-})
-function* userUpdateWorker({ user }) {
-  const {myData:{aboutMe:{_id}}}= yield select()
-  const userUpsert = yield call(promiseWorker, actionUserUpsert(user, _id))
-  if (userUpsert) {
-    yield call(fullPageAboutUserWorker, { _id })
-   yield call(fullProfilePageWorker)
-  }
-}
-
-export function* userUpdateWatcher() {
-  yield takeEvery("USER_UPDATE", userUpdateWorker)
-}
-
-export const actionSetAvatarTypeSaga = (file) => ({
-  type:"SET_AVATAR", file
-})
-
-function* setAvatarWorker({ file }) {
-  const {myData:{aboutMe:{_id}}}= yield select()
-  const setAvatar = yield call(promiseWorker, actionAvatar(file, _id))
-  console.log('setAvatar', setAvatar)
-  const {avatar} =yield call(promiseWorker,actionGetAvatar(_id))
-  if (setAvatar) {
-    yield call(fullPageAboutUserWorker, { _id })
-    yield put(actionUpdateAvatarType(avatar))
-    // yield call(promiseWorker,actionClearPromiseForName("setAvatar"))
-    // yield call(promiseWorker,actionClearPromiseForName("uploadFile"))
-
-  }
-}
-
-export function* setAvatarWatcher() {
-  yield takeEvery("SET_AVATAR", setAvatarWorker)
-}
-
-//clear user data after log out
-export const actionClearDataLogoutTypeSaga = () => ({
-  type:"CLEAR_ALL_DATA"
-})
-function* clearAllDataWorker() {
-  const logOut = yield put (actionAuthLogout())
-  if (logOut) {
-    history.push('/input')
-    yield all([
-
-       put(actionClearDataUserType()),
-       put(actionClearFeedPostsType()),
-       put(actionClearAboutMeType()),
-       put(actionAllClearPromiseType())
-    ])
-      
-    
-  }
-}
-export function* clearAllDataWatcher() {
-  yield takeEvery("CLEAR_ALL_DATA", clearAllDataWorker)
-}
-//subComment
-function* addSubCommentWorker({ commentId, newResult }) {
-  yield call(promiseWorker, actionAddSubComment(commentId, newResult))
-  console.log('newResult ', newResult)
-  const {
-    promise: {
-      addSubComment: { status },
-    },
-  } = yield select()
-  if (status === 'FULFILLED') {
-    yield call(getSubCommentWorker, {commentId})
-    }
-  }
-
-export function* addSubCommentWatcher() {
-  yield takeEvery("POST_SUB_COMMENT", addSubCommentWorker)
-}
-function* getSubCommentWorker({ commentId }) {
-  const { answers } = yield call(promiseWorker,
-    actionFindSubComment(commentId))
-  if (answers) {
-      yield put(actionAddSubCommentType(commentId, answers))
-  }
-}
-
-export function* getSubCommentWatcher() {
-  yield takeEvery("GET_SUB_COMMENT", getSubCommentWorker)
-}

+ 34 - 0
src/redux/saga/like/index.js

@@ -0,0 +1,34 @@
+import { put, call, takeLeading} from 'redux-saga/effects'; 
+import { actionAddLike,actionDeleteLike,actionFindLikes } from '../../../actions/query/likeQuery';
+import {actionChangeLikeType,actionAddLikePostFeedType} from '../../../actions/types/likeTypes'
+import { promiseWorker } from "../promise";
+
+function* changeLikeWorker({ likeId, postId }) {
+  const changeOneLike = () =>
+    likeId ? actionDeleteLike(likeId, postId) : actionAddLike(postId)
+
+  yield call(promiseWorker, changeOneLike())
+  return yield call(promiseWorker, actionFindLikes(postId))
+}
+
+function* changeLikePostWorker({ likeId, postId }) {
+  const { likes } = yield call(changeLikeWorker, { likeId, postId })
+  if (likes) {
+    yield put(actionChangeLikeType(likes))
+  }
+}
+
+function* changeLikePostFeedWorker({ likeId, postId }) {
+  const { likes } = yield call(changeLikeWorker, { likeId, postId })
+  if (likes) {
+    yield put(actionAddLikePostFeedType(likes))
+  }
+}
+
+export function* changeLikePostWatcher() {
+  yield takeLeading('CHANGE_LIKE_POST', changeLikePostWorker)
+}
+
+export function* changeLikePostFeedWatcher() {
+  yield takeLeading('CHANGE_LIKE_POST_FEED', changeLikePostFeedWorker)
+}

+ 25 - 0
src/redux/saga/logOut/index.js

@@ -0,0 +1,25 @@
+
+import { put, takeEvery,all } from 'redux-saga/effects'; 
+import { actionClearDataUserType } from '../../../actions/types/userTypes'
+import { actionClearFeedPostsType } from '../../../actions/types/feedTypes'
+import { actionAllClearPromiseType } from '../../../actions/types/promiseTypes'
+import { actionClearAboutMeType } from '../../../actions/types/myDataTypes'
+import { actionAuthLogout } from '../../../actions/types/loginTypes'
+import history from '../../../helpers/history';
+  function* clearAllDataWorker() {
+    const logOut = yield put (actionAuthLogout())
+    if (logOut) {
+      history.push('/input')
+      yield all([
+  
+         put(actionClearDataUserType()),
+         put(actionClearFeedPostsType()),
+         put(actionClearAboutMeType()),
+         put(actionAllClearPromiseType())
+      ])
+        
+    }
+  }
+  export function* clearAllDataWatcher() {
+    yield takeEvery("CLEAR_ALL_DATA", clearAllDataWorker)
+  }

+ 13 - 0
src/redux/saga/login/index.js

@@ -0,0 +1,13 @@
+import { promiseWorker } from "../promise";
+import { put, takeEvery,call } from 'redux-saga/effects'; 
+import { actionAuthLogin } from '../../../actions/types/loginTypes';
+import { actionLogin } from "../../../actions/query/loginQuery";
+export function* loginWorker({ login, password }) { 
+    let token = yield call(promiseWorker,actionLogin(login, password)) 
+    if (token) {
+        yield put(actionAuthLogin(token));
+    }
+  }
+  export function* loginWatcher() {
+  yield takeEvery("FULL_LOGIN", loginWorker)
+  }

+ 50 - 0
src/redux/saga/myProfile/index.js

@@ -0,0 +1,50 @@
+import { promiseWorker } from "../promise";
+import { put, takeEvery, call, select } from 'redux-saga/effects'; 
+import { actionProfilePageDataType,actionUpdateAvatarType } from '../../../actions/types/myDataTypes'
+import { actionAboutMe, actionUserUpsert, actionAvatar, actionGetAvatar } from "../../../actions/query/aboutMeQuery";
+import {fullPageAboutUserWorker} from '../userProfile'
+export function* fullProfilePageWorker() {
+    const { auth } = yield select()
+    if (auth?.payload?.sub?.id) {
+      const aboutMe = yield call(promiseWorker, actionAboutMe(auth?.payload?.sub.id))
+      if (aboutMe) {
+        yield put(actionProfilePageDataType(aboutMe))
+      
+      }
+    }
+}
+export function* fullProfilePageWatcher() {
+    yield takeEvery("FULLPROFILE_PAGE", fullProfilePageWorker)
+  }
+  
+function* userUpdateWorker({ user }) {
+    const {myData:{aboutMe:{_id}}}= yield select()
+    const userUpsert = yield call(promiseWorker, actionUserUpsert(user, _id))
+    if (userUpsert) {
+      yield call(fullPageAboutUserWorker, { _id })
+     yield call(fullProfilePageWorker)
+    }
+}
+export function* userUpdateWatcher() {
+  yield takeEvery("USER_UPDATE", userUpdateWorker)
+}
+
+
+
+function* setAvatarWorker({ file }) {
+  const {myData:{aboutMe:{_id}}}= yield select()
+  const setAvatar = yield call(promiseWorker, actionAvatar(file, _id))
+  console.log('setAvatar', setAvatar)
+  const {avatar} =yield call(promiseWorker,actionGetAvatar(_id))
+  if (setAvatar) {
+    yield call(fullPageAboutUserWorker, { _id })
+    yield put(actionUpdateAvatarType(avatar))
+    // yield call(promiseWorker,actionClearPromiseForName("setAvatar"))
+    // yield call(promiseWorker,actionClearPromiseForName("uploadFile"))
+
+  }
+}
+
+export function* setAvatarWatcher() {
+  yield takeEvery("SET_AVATAR", setAvatarWorker)
+}

+ 53 - 0
src/redux/saga/post/index.js

@@ -0,0 +1,53 @@
+import { promiseWorker } from "../promise";
+import { put, takeLeading, takeEvery,call, select } from 'redux-saga/effects'; 
+import {actionAboutUser, actionAllPostsUser, actionPostsCount} from '../../../actions/query/aboutUserQuery'
+import { actionOnePost,actionPostUpsert } from '../../../actions/query/postQuery'
+import {actionPostsType,actionOnePostType} from '../../../actions/types/postTypes'
+import {actionClearPromiseForName} from '../../../actions/types/promiseTypes'
+function* postsWorker({ _id }) {
+    const {
+      userData: { allPosts,countPosts },
+    } = yield select()
+    
+    if (allPosts?.length !== (countPosts ? countPosts : 1)) {
+      const newPosts = yield call(promiseWorker, 
+        actionAllPostsUser(_id, allPosts?.length),
+      )
+      const newPostsCount = yield call(promiseWorker, 
+        actionPostsCount(_id))
+      if (newPosts && newPostsCount) {
+        yield put(actionPostsType(newPosts, newPostsCount))
+      }
+    }
+  }
+  
+  export function* postsWatcher() {
+    yield takeLeading("USER_POSTS_PORTION", postsWorker)
+  }
+  
+
+function* onePostWorker({ _id }) {
+  
+    const onePost = yield call(promiseWorker,actionOnePost(_id))
+    if (onePost)
+    yield put(actionOnePostType(onePost))
+  }
+  export function* onePostWatcher(){
+  yield takeLeading("ONE_POST",onePostWorker)
+  }
+  
+  
+function* editPostWorker({state }) {
+
+const postUpsert = yield call(promiseWorker, actionPostUpsert(state,state?._id))
+
+   
+    if (postUpsert) {
+      yield put(actionClearPromiseForName('postUpsert'))
+      yield put(actionClearPromiseForName('uploadFiles'))
+    }
+    
+  }
+  export function* editPostWatcher() {
+    yield takeEvery("CREATE_EDIT_POST", editPostWorker)
+  }

+ 18 - 0
src/redux/saga/promise/index.js

@@ -0,0 +1,18 @@
+import { put, takeEvery} from 'redux-saga/effects'; 
+import {actionPending,actionFulfilled,actionRejected} from '../../../actions/types/promiseTypes'
+
+export function* promiseWorker(action) { 
+    const {name, promise} = action
+    yield put(actionPending(name))
+    try {
+        let data = yield promise
+        yield put(actionFulfilled(name, data))
+        return data 
+    }
+    catch (error) {
+        yield put(actionRejected(name, error))
+    }
+  }
+  export function* promiseWatcher(){
+    yield takeEvery('PROMISE_START', promiseWorker)
+}

+ 17 - 0
src/redux/saga/register/index.js

@@ -0,0 +1,17 @@
+import { promiseWorker } from "../promise";
+import { put, takeEvery, call } from 'redux-saga/effects'; 
+import { actionLoginTypeSaga } from '../../../actions/typeSaga/loginTypesSaga'
+import actionRegister from "../../../actions/query/registerQuery";
+import  history  from '../../../helpers/history'
+
+function* registerWorker({ login, password }) {
+    let token = yield call(promiseWorker,actionRegister(login, password)) 
+    if (token) {
+      yield put(actionLoginTypeSaga(login, password ))
+      history.push('/feed')
+    }
+  }
+  export function* registerWatcher() {
+  yield takeEvery("REGISTER", registerWorker)
+  
+  }

+ 39 - 0
src/redux/saga/subscribe/index.js

@@ -0,0 +1,39 @@
+
+import {actionChangeSubscribe,actionGetFollowers,actionGetFollowing} from '../../../actions/query/subscribeQuery'
+import { promiseWorker } from "../promise";
+import { put, takeEvery,call,select } from 'redux-saga/effects'; 
+import {actionChangeFollowingType, actionChangeFollowersType} from '../../../actions/types/subscribeTypes'
+function* changeSubscribeWorker({ followId, checkFollowId }) {
+    const { myData: { aboutMe: { _id, following } } } = yield select()
+    console.log('my following', following)
+    console.log('check follow id', checkFollowId)
+    console.log('my id', _id)
+   
+    const oldFollowing = checkFollowId ?
+      {
+        _id,
+        following: [...(following||[]).filter((item) =>
+          item._id !== followId).map(({ _id }) => ({ _id }))]
+      } 
+    : {
+        
+      _id,
+        following: [...(following||[]).map(({ _id }) =>
+          ({ _id })), { _id: followId }]
+      }
+
+    yield call(promiseWorker, actionChangeSubscribe(oldFollowing))
+
+    const updateUserFollowers = yield call(promiseWorker, actionGetFollowers(followId))
+
+    const updateMyFollowing = yield call(promiseWorker, actionGetFollowing(_id))
+
+    if (updateMyFollowing)
+     yield put(actionChangeFollowingType(updateMyFollowing?.following))
+   if (updateUserFollowers)
+      yield put(actionChangeFollowersType(updateUserFollowers?.followers))
+  }
+  export function* changeSubscribeWatcher() {
+    yield takeEvery("CHANGE_SUBSCRIBE", changeSubscribeWorker)
+  }
+  

+ 20 - 0
src/redux/saga/userProfile/index.js

@@ -0,0 +1,20 @@
+import { put, takeLeading, call } from 'redux-saga/effects'; 
+import { actionProfilePageDataUserType } from '../../../actions/types/userTypes';
+import { promiseWorker } from '../promise'
+import {actionUserAllPostsType,actionCountPostsType} from '../../../actions/types/postTypes'
+import {actionAboutUser, actionAllPostsUser, actionPostsCount} from '../../../actions/query/aboutUserQuery'
+export function* fullPageAboutUserWorker({ _id }) {
+  const aboutUser = yield call(promiseWorker, actionAboutUser(_id))
+  const allPosts = yield call(promiseWorker, actionAllPostsUser(_id))
+  const countPosts = yield call(promiseWorker, actionPostsCount(_id))
+
+  if (aboutUser) yield put(actionProfilePageDataUserType(aboutUser))
+
+  if (allPosts) {
+    yield put(actionUserAllPostsType(allPosts))
+  }
+  if (countPosts) yield put(actionCountPostsType(countPosts))
+}
+export function* fullPageAboutUserWatcher() {
+  yield takeLeading('USER_PAGE', fullPageAboutUserWorker)
+}

+ 25 - 0
src/redux/store.js

@@ -0,0 +1,25 @@
+import { createStore, combineReducers, applyMiddleware } from 'redux'
+import { promiseReducer } from './reducers/promiseReducer'
+import { authReducer } from './reducers/authReducer'
+import { myProfileReducer } from './reducers/myProfileReducer'
+import { userProfileReducer } from './reducers/userProfileReducer'
+import { feedReducer } from './reducers/feedReducer'
+import { postReducer } from './reducers/postReducer'
+import { exploreReducer } from './reducers/exploreReducer'
+import createSagaMiddleware from 'redux-saga'
+import rootSaga from './rootSaga'
+const sagaMiddleware = createSagaMiddleware()
+
+export const store = createStore(
+  combineReducers({
+    promise: promiseReducer,
+    auth: authReducer,
+    myData: myProfileReducer,
+    userData: userProfileReducer,
+    feed: feedReducer,
+    post: postReducer,
+    explore: exploreReducer,
+  }),
+  applyMiddleware(sagaMiddleware),
+)
+sagaMiddleware.run(rootSaga)