소스 검색

22.03.2023 23:00

Volddemar4ik 1 년 전
부모
커밋
edcdf53a14
24개의 변경된 파일676개의 추가작업 그리고 290개의 파일을 삭제
  1. 1 1
      js/Project/project/src/App.js
  2. 3 1
      js/Project/project/src/components/auth_reg/index(classic).js
  3. 3 1
      js/Project/project/src/components/auth_reg/index(privateRoute).js
  4. 2 1
      js/Project/project/src/components/auth_reg/login_form.js
  5. 3 1
      js/Project/project/src/components/create_post/index.js
  6. 3 1
      js/Project/project/src/components/create_post/uploaded_files.js
  7. 1 1
      js/Project/project/src/components/feed/aboutMe.js
  8. 1 1
      js/Project/project/src/components/feed/card_feed.js
  9. 1 1
      js/Project/project/src/components/feed/carousel_feed.js
  10. 3 2
      js/Project/project/src/components/feed/index.js
  11. 2 1
      js/Project/project/src/components/feed/test.js
  12. 191 63
      js/Project/project/src/components/post/card_post.js
  13. 43 43
      js/Project/project/src/components/post/carousel_post.js
  14. 31 0
      js/Project/project/src/components/post/comments.js
  15. 3 6
      js/Project/project/src/components/post/index.js
  16. 3 0
      js/Project/project/src/components/post/style.scss
  17. 91 27
      js/Project/project/src/components/redux/action(test).js
  18. 124 133
      js/Project/project/src/components/redux/action.js
  19. 157 0
      js/Project/project/src/components/redux/thunks.js
  20. 3 2
      js/Project/project/src/components/structure/header.js
  21. 3 1
      js/Project/project/src/components/user/gallery(test).js
  22. 1 1
      js/Project/project/src/components/user/gallery.js
  23. 2 1
      js/Project/project/src/components/user/index.js
  24. 1 1
      js/Project/project/src/components/user/userData.js

+ 1 - 1
js/Project/project/src/App.js

@@ -20,7 +20,7 @@ import Search from './components/search';
 import Page404 from './components/404/page404';
 
 // url проекта
-export const url = 'http://hipstagram.node.ed.asmer.org.ua/graphql'
+export const url = 'http://hipstagram.node.ed.asmer.org.ua/'
 
 const history = createHistory()
 

+ 3 - 1
js/Project/project/src/components/auth_reg/index(classic).js

@@ -1,7 +1,9 @@
 import { store } from '../redux';
 import { useState } from "react";
 import { Link, Redirect, useHistory } from "react-router-dom";
-import { actionFullLogin } from "../redux/action";
+// import { actionFullLogin } from "../redux/action";
+import { actionFullLogin } from "../redux/thunks";
+
 
 import { Paper, Box, Typography, Button, Stack, OutlinedInput, IconButton, InputLabel, InputAdornment, FormControl } from "@mui/material";
 

+ 3 - 1
js/Project/project/src/components/auth_reg/index(privateRoute).js

@@ -2,7 +2,9 @@ import React from 'react'
 import { store } from '../redux';
 import { useState } from "react";
 import { Link, Redirect } from "react-router-dom";
-import { actionFullLogin } from "../redux/action";
+// import { actionFullLogin } from "../redux/action";
+import { actionFullLogin } from "../redux/thunks";
+
 
 import { Paper, Box, Typography, Button, Stack, OutlinedInput, IconButton, InputLabel, InputAdornment, FormControl } from "@mui/material";
 

+ 2 - 1
js/Project/project/src/components/auth_reg/login_form.js

@@ -7,7 +7,8 @@ import {
     useHistory,
     useLocation
 } from "react-router-dom";
-import { actionFullLogin, actionFullRegistration } from "../redux/action";
+// import { actionFullLogin, actionFullRegistration } from "../redux/action";
+import { actionFullLogin, actionFullRegistration } from "../redux/thunks";
 
 import {
     Dialog,

+ 3 - 1
js/Project/project/src/components/create_post/index.js

@@ -12,7 +12,9 @@ import Container from '@mui/material/Container';
 import SendRoundedIcon from '@mui/icons-material/SendRounded';
 
 import { StyledDropzone } from './dropzone';
-import { actionFilesUpload, actionCreatePost, actionFullCreatePost } from '../redux/action';
+// import { actionFilesUpload, actionCreatePost, actionFullCreatePost } from '../redux/action';
+import { actionFilesUpload, actionFullCreatePost } from '../redux/thunks';
+import { actionCreatePost } from '../redux/action';
 import HighlightOffRoundedIcon from '@mui/icons-material/HighlightOffRounded';
 import { Dnd } from './dnd';
 import { UploadedFiles } from './uploaded_files';

+ 3 - 1
js/Project/project/src/components/create_post/uploaded_files.js

@@ -1,3 +1,5 @@
+import { url } from "../../App";
+
 import { Box } from "@mui/system"
 import HighlightOffRoundedIcon from '@mui/icons-material/HighlightOffRounded';
 
@@ -9,7 +11,7 @@ export function UploadedFiles({ image, onDelete }) {
         }}>
             <img
                 style={{ maxWidth: '200px', margin: '5px' }}
-                src={`http://hipstagram.node.ed.asmer.org.ua/` + image.url} key={image._id}
+                src={url + image.url} key={image._id}
             />
             <HighlightOffRoundedIcon style={{
                 position: 'absolute',

+ 1 - 1
js/Project/project/src/components/feed/aboutMe.js

@@ -22,7 +22,7 @@ function AboutMe({ aboutMe = {} }) {
                     <Avatar
                         sx={{ width: 50, height: 50 }}
                         alt={aboutMe?.login}
-                        src={url.slice(0, -7) + aboutMe?.avatar?.url}
+                        src={url + aboutMe?.avatar?.url}
                     />
                 }
 

+ 1 - 1
js/Project/project/src/components/feed/card_feed.js

@@ -32,7 +32,7 @@ export function CardFeed({ postData }) {
                     <Avatar
                         sx={{ width: 50, height: 50 }}
                         alt={postData?.owner?.login}
-                        src={url.slice(0, -7) + postData?.owner?.avatar?.url}
+                        src={url + postData?.owner?.avatar?.url}
                     />
                 }
 

+ 1 - 1
js/Project/project/src/components/feed/carousel_feed.js

@@ -17,7 +17,7 @@ function Item(imgUrl) {
 
             <img
                 alt='image'
-                src={imgUrl?.item && (url.slice(0, -7) + imgUrl?.item)}
+                src={imgUrl?.item && (url + imgUrl?.item)}
                 style={{
                     width: '100%'
                 }}

+ 3 - 2
js/Project/project/src/components/feed/index.js

@@ -6,7 +6,8 @@ import { styled } from '@mui/material/styles';
 import { Container } from '@mui/system';
 import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
 
-import { actionAboutMe, actionDownloadFeed } from '../redux/action';
+// import { actionAboutMe, actionDownloadFeed } from '../redux/action';
+import { actionAboutMe, actionDownloadFeed } from '../redux/thunks';
 import { CardFeed } from './card_feed';
 import { CAboutMe } from './aboutMe';
 
@@ -32,6 +33,7 @@ function Feed({ feed, loadFeed }) {
         }
     }), [newPosts])
 
+    // чекер дна страницы
     window.onscroll = async function feedScroll() {
         if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
             const downloadedPosts = await dispatch(actionDownloadFeed(feed.length))
@@ -46,7 +48,6 @@ function Feed({ feed, loadFeed }) {
     // console.log('posts: ', posts)
 
 
-
     useEffect(() => { loadFeed() }, [])
 
     return (

+ 2 - 1
js/Project/project/src/components/feed/test.js

@@ -10,7 +10,8 @@ import { styled } from '@mui/material/styles';
 import { Container } from '@mui/system';
 import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
 
-import { actionAboutMe, actionDownloadFeed } from '../redux/action';
+// import { actionAboutMe, actionDownloadFeed } from '../redux/action';
+import { actionAboutMe, actionDownloadFeed } from '../redux/thunks';
 import { CardFeed } from './card_feed';
 import { CAboutMe } from './aboutMe';
 

+ 191 - 63
js/Project/project/src/components/post/card_post.js

@@ -1,113 +1,218 @@
 import { url } from "../../App";
-import { Link } from "react-router-dom";
+import { useHistory } from "react-router-dom";
 
-import { Card, CardHeader, CardContent, CardActions, Avatar, IconButton, Typography, Box, Divider, TextField } from '@mui/material'
-import { FavoriteBorderRounded, Send, ChatBubbleOutline, TurnedInNot, AccountCircle } from '@mui/icons-material/'
-import Grid from '@mui/material/Unstable_Grid2';
+import './style.scss'
 
+import {
+    Card,
+    CardHeader,
+    CardContent,
+    CardActions,
+    Avatar,
+    IconButton,
+    Typography,
+    Box,
+    Divider,
+    TextField
+} from '@mui/material'
+import {
+    FavoriteBorderRounded,
+    Send,
+    ChatBubbleOutline,
+    TurnedInNot,
+    AccountCircle
+} from '@mui/icons-material/'
+import Grid from '@mui/material/Unstable_Grid2';
 
+import Comments from "./comments";
 
 
 export function CardPost({ postData }) {
-    // console.log('test: ', postData)
+    console.log('postData: ', postData)
+
+    const history = useHistory()
 
     // дата поста
     const dateofPost = new Date(+postData.createdAt)
     const months = ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']
-    const dateofPostParse = `${dateofPost.getDate() < 10 ? '0' + dateofPost.getDate() : dateofPost.getDate()} ${months[dateofPost.getMonth()]} ${dateofPost.getFullYear()}  ${dateofPost.getHours()}:${dateofPost.getMinutes() < 10 ? '0' + dateofPost.getMinutes() : dateofPost.getMinutes()}`
-
+    const dateofPostParse = `${dateofPost.getDate() < 10 ? '0' + dateofPost.getDate() : dateofPost.getDate()} 
+    ${months[dateofPost.getMonth()]} 
+    ${dateofPost.getFullYear()}
+    ${dateofPost.getHours()}:${dateofPost.getMinutes() < 10 ? '0' + dateofPost.getMinutes() : dateofPost.getMinutes()}`
 
 
+    function toAccount() {
+        history.push(`/user/${postData?.owner?._id}`)
+    }
 
 
     return (
-        <Card className="tututu" sx={{
-            display: 'flex',
-            flexDirection: 'column',
-            minHeight: '80vh',
-            borderRadius: 0
-        }}>
+        <Card
+            sx={{
+                display: 'flex',
+                flexDirection: 'column',
+                minHeight: '80vh',
+                borderRadius: 0
+            }}
+        >
             <CardHeader
                 avatar={
                     <Avatar
-                        alt=""
-                        src={(url.slice(0, -7) + postData?.owner?.avatar?.url)}
-                        sx={{ width: 50, height: 50 }}
-                        style={{ margin: '5px', border: '3px solid black', borderRadius: '50%', flexShrink: '0', overflow: 'hidden' }}
+                        alt={postData?.owner?.login}
+
+                        src={(url + postData?.owner?.avatar?.url)}
+
+                        sx={{
+                            width: 50,
+                            height: 50
+                        }}
                     />
                 }
+
                 title={
-                    <Link
-                        to={`/user/${postData?.owner?._id}`}>
+                    <Typography
+                        sx={{
+                            cursor: 'pointer'
+                        }}
+
+                        onClick={toAccount}
+                    >
                         {postData?.owner?.login}
-                    </Link>
+                    </Typography>
                 }
+
                 subheader={dateofPostParse}
             />
 
             <Divider />
 
-            <CardActions sx={{
-                flex: '1 1 auto',
-                alignItems: 'flex-start'
-            }}>
-                <CardContent>
-                    <Grid container spacing={1}>
-                        <Grid xs={3}>
-                            {/* <Item> */}
-                            <Avatar
-                                alt=""
-                                src={(url.slice(0, -7) + postData?.owner?.avatar?.url)}
-                                sx={{ width: 50, height: 50 }}
-                                style={{ margin: '5px', border: '3px solid black', borderRadius: '50%', flexShrink: '0', overflow: 'hidden' }}
-                            />
-                            {/* </Item> */}
-                        </Grid>
-                        <Grid xs={9}>
-                            {/* <Item> */}
-                            <Typography variant="subtitle2" color="text.secondary">
-                                {postData.title}
-                            </Typography>
-                            <Typography variant="body2" color="text.secondary">
-                                {postData.text}
-                            </Typography>
-                            {/* </Item> */}
-                        </Grid>
+            <CardContent
+                className='post-comments'
+
+                sx={{
+                    flex: '0 0 450px',
+                    overflowY: 'auto'
+                }}
+            >
+                <Grid
+                    container
+
+                    spacing={2}
+
+                    sx={{
+                        marginBottom: '20px'
+                    }}
+                >
+                    <Grid
+                        xs={2}
+
+                        sx={{
+                            flex: '0 0 45px'
+                        }}
+                    >
+                        <Avatar
+                            alt={postData?.owner?.login}
+
+                            src={(url + postData?.owner?.avatar?.url)}
+
+                            sx={{
+                                width: 40,
+                                height: 40
+                            }}
+                        />
                     </Grid>
-                </CardContent>
-            </CardActions>
+
+                    <Grid
+                        xs={10}
+                    >
+                        <Typography
+                            variant="subtitle2"
+
+                            color="text.secondary"
+                        >
+                            {postData?.owner?.login} {postData?.title}
+                        </Typography>
+
+                        <Typography
+                            variant="body2"
+
+                            color="text.secondary"
+                        >
+                            {postData?.text}
+                        </Typography>
+                    </Grid>
+                </Grid>
+
+                <Grid>
+                    <Comments />
+                </Grid>
+            </CardContent>
 
             <Divider />
 
             <CardActions disableSpacing>
-                <Box sx={{ flexGrow: 1 }}>
-                    <Grid container>
+                <Box
+                    sx={{
+                        flexGrow: 1
+                    }}>
+                    <Grid
+                        container
+                    >
                         <Grid
                             xs={12}
+
                             container
+
                             justifyContent="space-between"
+
                             alignItems="center"
-                            flexDirection={{ xs: 'column', sm: 'row' }}
-                            sx={{ fontSize: '12px' }}
+
+                            flexDirection={{
+                                xs: 'column',
+                                sm: 'row'
+                            }}
+
+                            sx={{
+                                fontSize: '12px'
+                            }}
                         >
-                            <Grid container columnSpacing={1} sx={{ order: { xs: 2, sm: 1 } }}>
+                            <Grid
+                                container
+
+                                columnSpacing={1}
+
+                                sx={{
+                                    order: { xs: 2, sm: 1 }
+                                }}
+                            >
                                 <Grid>
-                                    <IconButton aria-label="add to favorites">
+                                    <IconButton
+                                        aria-label="add to favorites"
+                                    >
                                         <FavoriteBorderRounded />
                                     </IconButton>
                                 </Grid>
+
                                 <Grid>
                                     <IconButton>
                                         <ChatBubbleOutline />
                                     </IconButton>
                                 </Grid>
+
                                 <Grid>
-                                    <IconButton aria-label="share">
+                                    <IconButton
+                                        aria-label="share"
+                                    >
                                         <Send />
                                     </IconButton>
                                 </Grid>
                             </Grid>
-                            <Grid sx={{ order: { xs: 1, sm: 2 } }}>
+
+                            <Grid
+                                sx={{
+                                    order: { xs: 1, sm: 2 }
+                                }}
+                            >
                                 <IconButton>
                                     <TurnedInNot />
                                 </IconButton>
@@ -117,7 +222,6 @@ export function CardPost({ postData }) {
                 </Box>
             </CardActions>
 
-
             <CardContent>
                 Нравится: {postData.likesCount ? postData.likesCount : '0'}
                 {/* Нравится: {postData.likesCount || '0'} // сработает или нет - проверить */}
@@ -126,14 +230,38 @@ export function CardPost({ postData }) {
             <Divider />
 
             <CardActions>
-                <Box sx={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between' }}>
-                    <AccountCircle sx={{ color: 'action.active', mr: 1, my: 0.5 }} />
-                    <TextField id="input-with-sx" label="Add comment..." variant="standard" />
-                    <Send sx={{ color: 'action.active', mr: 1, my: 0.5 }} />
-                </Box>
+                <Box
+                    sx={{
+                        display: 'flex',
+                        alignItems: 'flex-end',
+                        justifyContent: 'space-between'
+                    }}
+                >
+                    <AccountCircle
+                        sx={{
+                            color: 'action.active',
+                            mr: 1,
+                            my: 0.5
+                        }}
+                    />
 
-            </CardActions>
+                    <TextField
+                        id="input-with-sx"
+
+                        label="Add comment..."
 
+                        variant="standard"
+                    />
+
+                    <Send
+                        sx={{
+                            color: 'action.active',
+                            mr: 1,
+                            my: 0.5
+                        }}
+                    />
+                </Box>
+            </CardActions>
         </Card>
     )
 }

+ 43 - 43
js/Project/project/src/components/post/carousel_post.js

@@ -1,51 +1,51 @@
 import Carousel from 'react-material-ui-carousel'
+import { Box } from '@mui/system';
 
-// айтемы для каждой картинки
-function Item(props) {
-    return (
-        <div className="tut-kartinka" style={{
-            display: 'flex',
-            justifyContent: 'center'
-        }}>
-            <img alt='alt' src={props.item.url} style={{
-                maxWidth: '100%',
-                maxHeight: '100%'
-            }} />
-        </div>
-    )
-}
+import { url } from '../../App';
 
-// сама карусель - ее нужно вынеси в отдельный контенйре
-export function MyCarouselPost(props) {
-
-    let items = [
-        {
-            url: "/images/image4.jpeg"
-        },
-        {
-            url: "/images/image.jpeg"
-        },
-        {
-            url: "/images/image2.jpeg"
-        },
-
-    ]
-
-    return (
-        <Carousel autoPlay={false} cycleNavigation={false} animation={"slide"} indicatorContainerProps={{
-            style: {
-                marginTop: '-50px',
-                zIndex: 999,
-                position: 'inherit'
-            }
+// карусель
+export function MyCarouselPost({ postImages }) {
+    // console.log('postImages: ', postImages)
+
+    return (postImages &&
+        <Carousel
+            autoPlay={false}
+            cycleNavigation={false}
+            animation={"slide"}
+            indicatorContainerProps={{
+                style: {
+                    marginTop: '-50px',
+                    zIndex: 999,
+                    position: 'inherit'
+                }
+            }}
+            className='karusel'
 
-        }} className='tut-blok-kartinki' sx={{
-            width: '100%'
-        }}>
+            sx={{
+                width: '100%',
+            }}
+
+        >
             {
-                items.map((item, i) =>
-                    <Item key={i} item={item}
-                    />)
+                postImages.map(item =>
+                    <Box
+                        sx={{
+                            paddingTop: '100%',
+                            backgroundSize: 'contain',
+                            backgroundColor: 'black',
+                            backgroundImage: `url(/images/noPhoto.png)`,
+                            backgroundRepeat: 'no-repeat',
+                            backgroundPosition: 'center',
+
+                        }}
+
+                        key={item?.url}
+
+                        style={item?.url &&
+                            { backgroundImage: `url(${url + item.url})` }
+                        }
+                    />
+                )
             }
         </Carousel >
     )

+ 31 - 0
js/Project/project/src/components/post/comments.js

@@ -0,0 +1,31 @@
+import { Card, CardHeader, CardContent, CardActions, Avatar, IconButton, Typography, Box, Divider, TextField } from '@mui/material'
+
+
+function Comments() {
+    return (
+        <Typography>
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+            тут будут комментарии
+
+        </Typography>
+    )
+}
+
+
+export default Comments

+ 3 - 6
js/Project/project/src/components/post/index.js

@@ -2,14 +2,12 @@ import { useEffect } from 'react';
 import { useParams } from 'react-router-dom';
 import { connect } from 'react-redux';
 
-import { actionFindPostOne } from '../redux/action';
 import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
-import { Paper, Box, Card, CardHeader, Avatar } from '@mui/material';
+import { Paper, Box } from '@mui/material';
 import { styled } from '@mui/material/styles';
 
+import { actionFindPostOne } from '../redux/action';
 import { MyCarouselPost } from './carousel_post';
-
-import { url } from '../../App';
 import { CardPost } from './card_post';
 
 
@@ -20,7 +18,6 @@ const Item = styled(Paper)(() => ({
 
 
 function Comments({ post = {}, loadPost }) {
-    // console.log('start')
     // console.log('post: ', post)
 
     const { postId } = useParams()
@@ -40,7 +37,7 @@ function Comments({ post = {}, loadPost }) {
                         display: 'flex',
                         alignItems: 'center'
                     }}>
-                        <MyCarouselPost />
+                        <MyCarouselPost postImages={post?.images} />
                     </Item>
                 </Grid2>
                 <Grid2 xs={4}>

+ 3 - 0
js/Project/project/src/components/post/style.scss

@@ -0,0 +1,3 @@
+.post-comments::-webkit-scrollbar {
+    width: 0;
+}

+ 91 - 27
js/Project/project/src/components/redux/action(test).js

@@ -37,31 +37,32 @@ function getGql(endpoint) {
 
 const gql = getGql(url)
 
-// // акшоны для promiseReducer
-export const actionPending = nameOfPromise => ({ nameOfPromise, type: 'PROMISE', status: 'PENDING' })
-export const actionFulfilled = (nameOfPromise, payload) => ({ nameOfPromise, type: 'PROMISE', status: 'FULFILLED', payload })
-export const actionRejected = (nameOfPromise, error) => ({ nameOfPromise, type: 'PROMISE', status: 'REJECTED', error })
+// акшоны для promiseReducer
+export const actionPending = (type, nameOfPromise) => ({ nameOfPromise, type, status: 'PENDING' })
+export const actionFulfilled = (type, nameOfPromise, payload) => ({ nameOfPromise, type: type, status: 'FULFILLED', payload })
+export const actionRejected = (type, nameOfPromise, error) => ({ nameOfPromise, type: type, status: 'REJECTED', error })
 
-export const actionPromise = (nameOfPromise, promise) =>
+export const actionPromise = (type, nameOfPromise, promise) =>
   async dispatch => {
-    dispatch(actionPending(nameOfPromise)) //сигнализируем redux, что промис начался
+    dispatch(actionPending(type, nameOfPromise)) //сигнализируем redux, что промис начался
     try {
       const payload = await promise //ожидаем промиса
-      dispatch(actionFulfilled(nameOfPromise, payload)) //сигнализируем redux, что промис успешно выполнен
+      dispatch(actionFulfilled(type, nameOfPromise, payload)) //сигнализируем redux, что промис успешно выполнен
       return payload //в месте запуска store.dispatch с этим thunk можно так же получить результат промиса
     }
     catch (error) {
-      dispatch(actionRejected(nameOfPromise, error)) //в случае ошибки - сигнализируем redux, что промис несложился
+      dispatch(actionRejected(type, nameOfPromise, error)) //в случае ошибки - сигнализируем redux, что промис несложился
     }
   }
 
 
 
+
 // =============================================================
 // Запросы на бек
 
 // Запрос на регистрацию пользователя
-export const actionRegistration = (login, password) => actionPromise('Registration', gql(`mutation Registration($login:String!, $password:String!) {
+export const actionRegistration = (login, password) => actionPromise('PROMISE', 'Registration', gql(`mutation Registration($login:String!, $password:String!) {
    createUser(login:$login, password:$password) {
     _id login
   }
@@ -75,7 +76,7 @@ export const actionRegistration = (login, password) => actionPromise('Registrati
 
 
 // Запрос на логинизацию пользователя
-export const actionLogin = (login, password) => actionPromise('Login', gql(`query Login($login: String!, $password: String!) {
+export const actionLogin = (login, password) => actionPromise('PROMISE', 'Login', gql(`query Login($login: String!, $password: String!) {
 login(login: $login, password: $password)
 }`, {
   login,
@@ -94,7 +95,7 @@ export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })
 
 
 //  запрос на изменение пароля юзера
-export const actionPassChange = (loginChange, passwordChange, passwordNew) => actionPromise('PassChange', gql(`mutation PasswordChange($loginChange: String!, $passwordChange: String!, $passwordNew: String!) {
+export const actionPassChange = (loginChange, passwordChange, passwordNew) => actionPromise('PROMISE', 'PassChange', gql(`mutation PasswordChange($loginChange: String!, $passwordChange: String!, $passwordNew: String!) {
   changePassword(
     login: $loginChange, password: $passwordChange, newPassword: $passwordNew
   ) {
@@ -111,7 +112,7 @@ export const actionPassChange = (loginChange, passwordChange, passwordNew) => ac
 
 
 // запрос на поиск конкретного поста
-export const actionFindPostOne = _id => actionPromise('PostFindOne', gql(`query OnePostFind ($postOne: String){
+export const actionFindPostOne = _id => actionPromise('PROMISE', 'PostFindOne', gql(`query OnePostFind ($postOne: String){
   PostFindOne (query: $postOne) {
     _id createdAt title text likesCount
     images {
@@ -142,7 +143,7 @@ export const actionFindPostOne = _id => actionPromise('PostFindOne', gql(`query
 }))
 
 // запрос на поиск конкретного юзера(folowwing - это те, на кого я подписан. followers - те, кто на меня подписан)
-// export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise(promiseName, gql(`query OneUserFind ($userOne: String) {
+// export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise('PROMISE', promiseName, gql(`query OneUserFind ($userOne: String) {
 //     UserFindOne(query: $userOne) {
 //       _id createdAt login nick
 //       avatar {
@@ -161,7 +162,7 @@ export const actionFindPostOne = _id => actionPromise('PostFindOne', gql(`query
 
 
 
-export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise(promiseName, gql(`query OneUserFind ($userOne: String) {
+export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise('PROMISE', promiseName, gql(`query OneUserFind ($userOne: String) {
     UserFindOne(query: $userOne) {
       _id createdAt login nick 
       avatar {
@@ -181,7 +182,7 @@ export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPro
 
 
 // запрос на поиск всех постов на беке (нигде не должен использоваться)
-export const actionfindPosts = () => actionPromise('PostsFind', gql(`query AllPostsFind ($allPosts: String){
+export const actionfindPosts = () => actionPromise('PROMISE', 'PostsFind', gql(`query AllPostsFind ($allPosts: String){
   PostFind(query: $allPosts){
     _id createdAt title text likesCount
     images {
@@ -199,7 +200,27 @@ export const actionfindPosts = () => actionPromise('PostsFind', gql(`query AllPo
 
 
 // Запрос на поиск ленты постов для юзера
-export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed') => actionPromise(promiseName, gql(`query FeedFindOne ($feedOne: String){
+// export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed') => actionPromise('PROMISE', promiseName, gql(`query FeedFindOne ($feedOne: String){
+// 	PostFind(query: $feedOne){
+//             _id createdAt title text likesCount owner{
+//               _id login avatar{
+//                 url
+//               }
+//             }
+//             comments {
+//               _id
+//             }
+//     images{
+//       url
+//     }
+//     	}
+//     }`, {
+//   // вот тут прописал limit - количество постов, которые отображаются в ленте
+//   feedOne: JSON.stringify([{ ___owner: { $in: arr } }, { sort: [{ _id: sortOne }], limit: [limitOne] }])
+// }))
+
+//================= вот это тоже нужно будет удалить после тестов =====================
+export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed', skipOne = 0) => actionPromise('FEED', promiseName, gql(`query FeedFindOne ($feedOne: String){
 	PostFind(query: $feedOne){
             _id createdAt title text likesCount owner{
               _id login avatar{
@@ -215,7 +236,7 @@ export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed')
     	}
     }`, {
   // вот тут прописал limit - количество постов, которые отображаются в ленте
-  feedOne: JSON.stringify([{ ___owner: { $in: arr } }, { sort: [{ _id: sortOne }], limit: [limitOne] }])
+  feedOne: JSON.stringify([{ ___owner: { $in: arr } }, { sort: [{ _id: sortOne }], limit: [limitOne], skip: [skipOne] }])
 }))
 
 
@@ -224,9 +245,28 @@ export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed')
 
 
 
+// запрос ленты с пропуском определенного количества постов.комментов
+// export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseName = 'Feed') => actionPromise('FEED', promiseName, gql(`query FeedFindOne ($feedOne: String){
+// 	PostFind(query: $feedOne){
+//             _id createdAt title text likesCount owner{
+//               _id login avatar{
+//                 url
+//               }
+//             }
+//             comments {
+//               _id
+//             }
+//     images{
+//       url
+//     }
+//     	}
+//     }`, {
+//   // вот тут прописал limit - количество постов, которые отображаются в ленте
+//   feedOne: JSON.stringify([{ ___owner: { $in: arr } }, { sort: [{ _id: sortOne }], skip: [skipOne], limit: [limitOne] }])
+// }))
 
-// запрос ленты с п/ропуском определенного количества постов.комментов
-export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseName = 'Feed') => actionPromise(promiseName, gql(`query FeedFindOne ($feedOne: String){
+// ====================== и это удалить после теста ====================
+export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseName = 'Feed') => actionPromise('FEED', promiseName, gql(`query FeedFindOne ($feedOne: String){
 	PostFind(query: $feedOne){
             _id createdAt title text likesCount owner{
               _id login avatar{
@@ -256,9 +296,8 @@ export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseNa
 
 
 
-
 // запрос на подсчет количества постов юзера
-export const actionPostsCount = (id, promiseName) => actionPromise(promiseName, gql(`query PostsCount ($postsCount: String){
+export const actionPostsCount = (id, promiseName) => actionPromise('PROMISE', promiseName, gql(`query PostsCount ($postsCount: String){
   PostCount(query: $postsCount)
 }`, {
   postsCount: JSON.stringify([{ ___owner: id }])
@@ -322,11 +361,17 @@ export const actionFullLogout = () =>
 
 
 // Thunk для страницы юзера (диспатчим запрос на юзера и на ленту его постов)
-export const actionFullUserFindOne = (id) =>
+export const actionFullUserFindOne = _id =>
   async dispatch => {
-    const test = await dispatch(actionFindUserOne(id, 'UserFind'))
-    console.log('test: ', test)
-    dispatch(actionFeedFindOne([id], -1, 100, 'UserFeed'))
+
+    // запрашиваем информацию о пользователе
+    await dispatch(actionFindUserOne(_id, 'UserFindOne'))
+
+    // парсим счетчик, сколько постов у юзера
+    dispatch(actionPostsCount(_id, 'UserPostsCount'))
+
+    // запрашиваем список постов для юзера
+    dispatch(actionFeedFindOne([_id], -1, 100, 'UserFeed'))
   }
 
 
@@ -359,6 +404,25 @@ export const actionAboutMe = () =>
 
 
 
+// ================= на удаление (начало)=====================
+
+export const actionDownloadFeed = (skip) =>
+  async (dispatch, getState) => {
+
+    console.log('скипаем: ', skip)
+    const followingList = (getState()?.promise?.AboutMe?.payload?.following).map(user => user._id)
+
+    if (followingList) {
+      const result = await dispatch(actionFeedFindOne(followingList, -1, 10, 'AddFeed', skip))
+
+      return result
+    }
+  }
+
+
+// ================= на удаление(конец) =====================
+
+
 
 // запрос на загрузку картинок на бек
 function fileUpload(file) {
@@ -380,7 +444,7 @@ function filesUpload(files) {
   return Promise.all(files.map(fileUpload))
 }
 
-export const actionFilesUpload = (files) => actionPromise('FilesUpload',
+export const actionFilesUpload = (files) => actionPromise('PROMISE', 'FilesUpload',
   filesUpload(files)
 )
 
@@ -391,7 +455,7 @@ export const actionFilesUpload = (files) => actionPromise('FilesUpload',
 
 
 // запрос на создание поста
-export const actionCreatePost = (params) => actionPromise('CreatePost', gql(
+export const actionCreatePost = (params) => actionPromise('PROMISE', 'CreatePost', gql(
   `mutation CreatePost($createNewPost: PostInput){
   PostUpsert(post: $createNewPost){
     _id

+ 124 - 133
js/Project/project/src/components/redux/action.js

@@ -1,7 +1,3 @@
-import { store } from "."
-import { useGetState } from 'react-redux';
-import { useHistory } from "react-router-dom";
-
 const url = 'http://hipstagram.node.ed.asmer.org.ua/graphql'
 
 // функция getGql
@@ -58,10 +54,15 @@ export const actionPromise = (type, nameOfPromise, promise) =>
 
 
 
-// =============================================================
-// Запросы на бек
+// акшон для логинизации в authReduser
+export const actionAuthLogin = token => ({ type: 'AUTH_LOGIN', token })
+
+// акшон для раззлогинивания в authReduser
+export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })
+
+
 
-// Запрос на регистрацию пользователя
+// Запрос на регистрацию юзера
 export const actionRegistration = (login, password) => actionPromise('PROMISE', 'Registration', gql(`mutation Registration($login:String!, $password:String!) {
    createUser(login:$login, password:$password) {
     _id login
@@ -69,13 +70,11 @@ export const actionRegistration = (login, password) => actionPromise('PROMISE',
 }`, {
   login,
   password
-})
-
-)
+}))
 
 
 
-// Запрос на логинизацию пользователя
+// Запрос на логинизацию юзера
 export const actionLogin = (login, password) => actionPromise('PROMISE', 'Login', gql(`query Login($login: String!, $password: String!) {
 login(login: $login, password: $password)
 }`, {
@@ -85,16 +84,7 @@ login(login: $login, password: $password)
 
 
 
-
-// акшон для логинизации в authReduser
-const actionAuthLogin = token => ({ type: 'AUTH_LOGIN', token })
-// акшон для раззлогинивания
-export const actionAuthLogout = () => ({ type: 'AUTH_LOGOUT' })
-
-
-
-
-//  запрос на изменение пароля юзера
+// Запрос на изменение пароля юзера
 export const actionPassChange = (loginChange, passwordChange, passwordNew) => actionPromise('PROMISE', 'PassChange', gql(`mutation PasswordChange($loginChange: String!, $passwordChange: String!, $passwordNew: String!) {
   changePassword(
     login: $loginChange, password: $passwordChange, newPassword: $passwordNew
@@ -110,8 +100,7 @@ export const actionPassChange = (loginChange, passwordChange, passwordNew) => ac
 
 
 
-
-// запрос на поиск конкретного поста
+// Запрос на поиск конкретного поста
 export const actionFindPostOne = _id => actionPromise('PROMISE', 'PostFindOne', gql(`query OnePostFind ($postOne: String){
   PostFindOne (query: $postOne) {
     _id createdAt title text likesCount
@@ -142,6 +131,8 @@ export const actionFindPostOne = _id => actionPromise('PROMISE', 'PostFindOne',
   postOne: JSON.stringify([{ _id }])
 }))
 
+
+
 // запрос на поиск конкретного юзера(folowwing - это те, на кого я подписан. followers - те, кто на меня подписан)
 // export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise('PROMISE', promiseName, gql(`query OneUserFind ($userOne: String) {
 //     UserFindOne(query: $userOne) {
@@ -159,9 +150,6 @@ export const actionFindPostOne = _id => actionPromise('PROMISE', 'PostFindOne',
 //   }`, {
 //   userOne: JSON.stringify([{ _id }])
 // }))
-
-
-
 export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPromise('PROMISE', promiseName, gql(`query OneUserFind ($userOne: String) {
     UserFindOne(query: $userOne) {
       _id createdAt login nick 
@@ -181,7 +169,7 @@ export const actionFindUserOne = (_id, promiseName = 'UserFindOne') => actionPro
 
 
 
-// запрос на поиск всех постов на беке (нигде не должен использоваться)
+// Запрос на поиск всех постов на беке (нигде не должен использоваться)
 export const actionfindPosts = () => actionPromise('PROMISE', 'PostsFind', gql(`query AllPostsFind ($allPosts: String){
   PostFind(query: $allPosts){
     _id createdAt title text likesCount
@@ -241,11 +229,7 @@ export const actionFeedFindOne = (arr, sortOne, limitOne, promiseName = 'Feed',
 
 
 
-
-
-
-
-// запрос ленты с пропуском определенного количества постов.комментов
+// Запрос ленты с пропуском определенного количества постов/комментов
 // export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseName = 'Feed') => actionPromise('FEED', promiseName, gql(`query FeedFindOne ($feedOne: String){
 // 	PostFind(query: $feedOne){
 //             _id createdAt title text likesCount owner{
@@ -287,6 +271,29 @@ export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseNa
 
 
 
+// Запрос на подсчет количества постов юзера
+export const actionPostsCount = (id, promiseName) => actionPromise('PROMISE', promiseName, gql(`query PostsCount ($postsCount: String){
+  PostCount(query: $postsCount)
+}`, {
+  postsCount: JSON.stringify([{ ___owner: id }])
+}))
+
+
+
+// Запрос на создание поста
+export const actionCreatePost = params => actionPromise('PROMISE', 'CreatePost', gql(
+  `mutation CreatePost($createNewPost: PostInput){
+  PostUpsert(post: $createNewPost){
+    _id
+  }
+}`, {
+  createNewPost: params
+}))
+
+
+
+
+
 
 
 
@@ -296,14 +303,7 @@ export const actionFeedFindOneSkip = (arr, sortOne, skipOne, limitOne, promiseNa
 
 
 
-// запрос на подсчет количества постов юзера
-export const actionPostsCount = (id, promiseName) => actionPromise('PROMISE', promiseName, gql(`query PostsCount ($postsCount: String){
-  PostCount(query: $postsCount)
-}`, {
-  postsCount: JSON.stringify([{ ___owner: id }])
-})
 
-)
 
 
 
@@ -312,20 +312,20 @@ export const actionPostsCount = (id, promiseName) => actionPromise('PROMISE', pr
 // Thunk-и
 
 // Thunk логин и последующую логинизацию в authReduser
-export const actionFullLogin = (login, password) =>
-  async dispatch => {
+// export const actionFullLogin = (login, password) =>
+//   async dispatch => {
 
-    const token = await dispatch(actionLogin(login, password))
+//     const token = await dispatch(actionLogin(login, password))
 
-    if (token !== null) {
-      if (typeof (token) === 'string') {
-        dispatch(actionAuthLogin(token))
-        localStorage.authToken = token
-      }
-    }
+//     if (token !== null) {
+//       if (typeof (token) === 'string') {
+//         dispatch(actionAuthLogin(token))
+//         localStorage.authToken = token
+//       }
+//     }
 
-    return token
-  }
+//     return token
+//   }
 
 
 
@@ -333,46 +333,46 @@ export const actionFullLogin = (login, password) =>
 
 
 // Thunk на регистрацию и последующую логинизацию
-export const actionFullRegistration = (login, password) =>
-  async dispatch => {
+// export const actionFullRegistration = (login, password) =>
+//   async dispatch => {
 
-    const token = await dispatch(actionRegistration(login, password))
+//     const token = await dispatch(actionRegistration(login, password))
 
-    if (token !== null) {
-      dispatch(actionFullLogin(login, password))
-    }
+//     if (token !== null) {
+//       dispatch(actionFullLogin(login, password))
+//     }
 
-    return token
-  }
+//     return token
+//   }
 
 
 
 
 
 // Thunk разлогина и последующей полной очистки localStorage
-export const actionFullLogout = () =>
-  async dispatch => {
-    await dispatch(actionAuthLogout())
-    return {}
-  }
+// export const actionFullLogout = () =>
+//   async dispatch => {
+//     await dispatch(actionAuthLogout())
+//     return {}
+//   }
 
 
 
 
 
 // Thunk для страницы юзера (диспатчим запрос на юзера и на ленту его постов)
-export const actionFullUserFindOne = _id =>
-  async dispatch => {
+// export const actionFullUserFindOne = _id =>
+//   async dispatch => {
 
-    // запрашиваем информацию о пользователе
-    await dispatch(actionFindUserOne(_id, 'UserFindOne'))
+//     // запрашиваем информацию о пользователе
+//     await dispatch(actionFindUserOne(_id, 'UserFindOne'))
 
-    // парсим счетчик, сколько постов у юзера
-    dispatch(actionPostsCount(_id, 'UserPostsCount'))
+//     // парсим счетчик, сколько постов у юзера
+//     dispatch(actionPostsCount(_id, 'UserPostsCount'))
 
-    // запрашиваем список постов для юзера
-    dispatch(actionFeedFindOne([_id], -1, 100, 'UserFeed'))
-  }
+//     // запрашиваем список постов для юзера
+//     dispatch(actionFeedFindOne([_id], -1, 100, 'UserFeed'))
+//   }
 
 
 
@@ -380,44 +380,44 @@ export const actionFullUserFindOne = _id =>
 
 
 // запрос AboutMe для главной страницы (лента моих постов и мои данные)
-export const actionAboutMe = () =>
-  async (dispatch, getState) => {
-    const myId = getState()?.auth?.payload?.sub?.id
+// export const actionAboutMe = () =>
+//   async (dispatch, getState) => {
+//     const myId = getState()?.auth?.payload?.sub?.id
 
-    // диспатчим запрос AboutMe (о себе)
-    const userData = await dispatch(actionFindUserOne(myId, 'AboutMe'))
+//     // диспатчим запрос AboutMe (о себе)
+//     const userData = await dispatch(actionFindUserOne(myId, 'AboutMe'))
 
-    // парсим счетчик, сколько постов у меня
-    dispatch(actionPostsCount(myId, 'MyPostsCount'))
+//     // парсим счетчик, сколько постов у меня
+//     dispatch(actionPostsCount(myId, 'MyPostsCount'))
 
-    let followingList = []
-    // проверяем, есть ли вообще подписчики и если да, парсим их
-    if (userData?.following) {
-      // получаем id всех подписок
-      followingList = (userData.following).map(user => user?._id)
-    }
+//     let followingList = []
+//     // проверяем, есть ли вообще подписчики и если да, парсим их
+//     if (userData?.following) {
+//       // получаем id всех подписок
+//       followingList = (userData.following).map(user => user?._id)
+//     }
 
-    // запрашиваем формирование ленты моих постов (первый параметр - список id, второй - это сортировка постов от новых)
-    dispatch(actionFeedFindOne(followingList, -1, 10, 'MyFeed'))
-  }
+//     // запрашиваем формирование ленты моих постов (первый параметр - список id, второй - это сортировка постов от новых)
+//     dispatch(actionFeedFindOne(followingList, -1, 10, 'MyFeed'))
+//   }
 
 
 
 
 // ================= на удаление (начало)=====================
 
-export const actionDownloadFeed = (skip) =>
-  async (dispatch, getState) => {
+// export const actionDownloadFeed = (skip) =>
+//   async (dispatch, getState) => {
 
-    console.log('скипаем: ', skip)
-    const followingList = (getState()?.promise?.AboutMe?.payload?.following).map(user => user._id)
+//     console.log('скипаем: ', skip)
+//     const followingList = (getState()?.promise?.AboutMe?.payload?.following).map(user => user._id)
 
-    if (followingList) {
-      const result = await dispatch(actionFeedFindOne(followingList, -1, 10, 'AddFeed', skip))
+//     if (followingList) {
+//       const result = await dispatch(actionFeedFindOne(followingList, -1, 10, 'AddFeed', skip))
 
-      return result
-    }
-  }
+//       return result
+//     }
+//   }
 
 
 // ================= на удаление(конец) =====================
@@ -425,28 +425,28 @@ export const actionDownloadFeed = (skip) =>
 
 
 // запрос на загрузку картинок на бек
-function fileUpload(file) {
-  const formData = new FormData()
-  formData.append('photo', file)
+// function fileUpload(file) {
+//   const formData = new FormData()
+//   formData.append('photo', file)
 
-  return (
-    fetch('http://hipstagram.node.ed.asmer.org.ua/upload', {
-      method: 'POST',
-      headers: {
-        Authorization: 'Bearer ' + localStorage.authToken
-      },
-      body: formData
-    }).then(res => res.json())
-  )
-}
+//   return (
+//     fetch('http://hipstagram.node.ed.asmer.org.ua/upload', {
+//       method: 'POST',
+//       headers: {
+//         Authorization: 'Bearer ' + localStorage.authToken
+//       },
+//       body: formData
+//     }).then(res => res.json())
+//   )
+// }
 
-function filesUpload(files) {
-  return Promise.all(files.map(fileUpload))
-}
+// function filesUpload(files) {
+//   return Promise.all(files.map(fileUpload))
+// }
 
-export const actionFilesUpload = (files) => actionPromise('PROMISE', 'FilesUpload',
-  filesUpload(files)
-)
+// export const actionFilesUpload = (files) => actionPromise('PROMISE', 'FilesUpload',
+//   filesUpload(files)
+// )
 
 
 
@@ -454,15 +454,6 @@ export const actionFilesUpload = (files) => actionPromise('PROMISE', 'FilesUploa
 
 
 
-// запрос на создание поста
-export const actionCreatePost = (params) => actionPromise('PROMISE', 'CreatePost', gql(
-  `mutation CreatePost($createNewPost: PostInput){
-  PostUpsert(post: $createNewPost){
-    _id
-  }
-}`, {
-  createNewPost: params
-}))
 
 
 
@@ -473,15 +464,15 @@ export const actionCreatePost = (params) => actionPromise('PROMISE', 'CreatePost
 
 
 // санк для создания поста и последующего перехода на его страницу
-export const actionFullCreatePost = (params) =>
-  async dispatch => {
-    const newPost = await dispatch(actionCreatePost(params))
-    // console.log('Тут нужный резульата: ', newPost)
+// export const actionFullCreatePost = (params) =>
+//   async dispatch => {
+//     const newPost = await dispatch(actionCreatePost(params))
+//     // console.log('Тут нужный резульата: ', newPost)
 
-    if (newPost) {
-      dispatch(actionFindPostOne(newPost._id))
-    }
-  }
+//     if (newPost) {
+//       dispatch(actionFindPostOne(newPost._id))
+//     }
+//   }
 
 
 

+ 157 - 0
js/Project/project/src/components/redux/thunks.js

@@ -0,0 +1,157 @@
+import { url } from "../../App"
+
+import {
+    actionPromise,
+    actionLogin,
+    actionAuthLogin,
+    actionRegistration,
+    actionAuthLogout,
+    actionFindUserOne,
+    actionPostsCount,
+    actionFeedFindOne,
+    actionCreatePost,
+    actionFindPostOne
+} from "./action"
+
+
+
+// Логин и последующая логинизация в authReduser
+export const actionFullLogin = (login, password) =>
+    async dispatch => {
+
+        const token = await dispatch(actionLogin(login, password))
+
+        if (token !== null) {
+            if (typeof (token) === 'string') {
+                dispatch(actionAuthLogin(token))
+                localStorage.authToken = token
+            }
+        }
+
+        return token
+    }
+
+
+
+// Регистрация и последующая логинизация
+export const actionFullRegistration = (login, password) =>
+    async dispatch => {
+
+        const token = await dispatch(actionRegistration(login, password))
+
+        if (token !== null) {
+            dispatch(actionFullLogin(login, password))
+        }
+
+        return token
+    }
+
+
+
+// Разлогин и последующая полна очистка localStorage
+export const actionFullLogout = () =>
+    async dispatch => {
+        await dispatch(actionAuthLogout())
+        return {}
+    }
+
+
+
+// Запрос юзера (данные о пользователе + количество его постов + все его посты(100 шт))
+export const actionFullUserFindOne = _id =>
+    async dispatch => {
+
+        // запрашиваем информацию о пользователе
+        await dispatch(actionFindUserOne(_id, 'UserFindOne'))
+
+        // парсим счетчик, сколько постов у юзера
+        dispatch(actionPostsCount(_id, 'UserPostsCount'))
+
+        // запрашиваем список постов для юзера
+        dispatch(actionFeedFindOne([_id], -1, 100, 'UserFeed'))
+    }
+
+
+
+// Запрос AboutMe для главной
+export const actionAboutMe = () =>
+    async (dispatch, getState) => {
+        const myId = getState()?.auth?.payload?.sub?.id
+
+        // диспатчим запрос AboutMe (о себе)
+        const userData = await dispatch(actionFindUserOne(myId, 'AboutMe'))
+
+        // парсим счетчик, сколько постов у меня
+        dispatch(actionPostsCount(myId, 'MyPostsCount'))
+
+        let followingList = []
+        // проверяем, есть ли вообще подписчики и если да, парсим их
+        if (userData?.following) {
+            // получаем id всех подписок
+            followingList = (userData.following).map(user => user?._id)
+        }
+
+        // запрашиваем формирование ленты моих постов (первый параметр - список id, второй - это сортировка постов от новых)
+        dispatch(actionFeedFindOne(followingList, -1, 10, 'MyFeed'))
+    }
+
+
+
+// ================= на удаление (начало)=====================
+// Запрос на догрузку ленты постов
+export const actionDownloadFeed = (skip) =>
+    async (dispatch, getState) => {
+
+        console.log('скипаем: ', skip)
+        const followingList = (getState()?.promise?.AboutMe?.payload?.following).map(user => user._id)
+
+        if (followingList) {
+            const result = await dispatch(actionFeedFindOne(followingList, -1, 10, 'AddFeed', skip))
+
+            return result
+        }
+    }
+// ================= на удаление(конец) =====================
+
+
+
+// запрос на загрузку картинок на бек
+function fileUpload(file) {
+    const formData = new FormData()
+    formData.append('photo', file)
+
+    return (
+        fetch((url + 'upload'), {
+            method: 'POST',
+            headers: {
+                Authorization: 'Bearer ' + localStorage.authToken
+            },
+            body: formData
+        }).then(res => res.json())
+    )
+}
+
+function filesUpload(files) {
+    return Promise.all(files.map(fileUpload))
+}
+
+export const actionFilesUpload = files => actionPromise('PROMISE', 'FilesUpload',
+    filesUpload(files)
+)
+
+
+
+// Создание поста и последующий переход на него
+export const actionFullCreatePost = (params) =>
+    async dispatch => {
+        const newPost = await dispatch(actionCreatePost(params))
+
+        if (newPost) {
+            dispatch(actionFindPostOne(newPost._id))
+        }
+    }
+
+
+
+
+

+ 3 - 2
js/Project/project/src/components/structure/header.js

@@ -5,7 +5,8 @@ import { connect, useSelector } from 'react-redux';
 
 import { AppBar, Box, Toolbar, Typography, Menu, Container, Avatar, Tooltip, MenuItem, IconButton, Stack } from '@mui/material'
 import { Instagram, AddAPhotoRounded, Search } from '@mui/icons-material';
-import { actionFullLogout } from '../redux/action';
+// import { actionFullLogout } from '../redux/action';
+import { actionFullLogout } from '../redux/thunks';
 
 import { url } from '../../App';
 
@@ -74,7 +75,7 @@ function UserMenu() {
                     >
                         <Avatar
                             alt={user?.login}
-                            src={url.slice(0, -7) + userData?.avatar?.url}
+                            src={url + userData?.avatar?.url}
                         />
                     </IconButton>
                 </Tooltip>

+ 3 - 1
js/Project/project/src/components/user/gallery(test).js

@@ -8,7 +8,9 @@ import { Box } from '@mui/system';
 import AutoAwesomeMotionRoundedIcon from '@mui/icons-material/AutoAwesomeMotionRounded';
 import { useParams } from 'react-router';
 import { connect } from 'react-redux';
-import { actionFullUserFindOne } from '../redux/action';
+// import { actionFullUserFindOne } from '../redux/action';
+import { actionFullUserFindOne } from '../redux/thunks';
+
 
 function StandardImageList({ userGallery = [], loadUserGallery }) {
     // console.log('userGallery: ', userGallery)

+ 1 - 1
js/Project/project/src/components/user/gallery.js

@@ -60,7 +60,7 @@ export default function StandardImageList({ images }) {
 
                         style={item?.images && (
                             item?.images[0]?.url &&
-                            { backgroundImage: `url(${url.slice(0, -7) + item?.images[0]?.url})` }
+                            { backgroundImage: `url(${url + item?.images[0]?.url})` }
                         )}
 
                         onClick={() => {

+ 2 - 1
js/Project/project/src/components/user/index.js

@@ -7,7 +7,8 @@ import { store } from '../redux';
 import { Box, Container, Divider } from '@mui/material';
 
 import BasicCard from './userData';
-import { actionFindUserOne, actionFullUserFindOne } from '../redux/action';
+// import { actionFindUserOne, actionFullUserFindOne } from '../redux/action';
+import { actionFindUserOne, actionFullUserFindOne } from '../redux/thunks';
 
 import { StandardImageList, СStandardImageList } from './gallery';
 

+ 1 - 1
js/Project/project/src/components/user/userData.js

@@ -11,7 +11,7 @@ import { url } from "../../App"
 
 // блок пользовательских данных
 export default function BasicCard({ userData }) {
-    const urlAvatar = url.slice(0, -7) + userData?.avatar?.url
+    const urlAvatar = url + userData?.avatar?.url
 
     // определяем количество постов пользоваеля
     const userPostsCount = useSelector(state => state?.promise?.UserPostsCount?.payload)