Browse Source

Add search comments

DeJaVu 2 years ago
parent
commit
a5e2bee69b

+ 18 - 0
package-lock.json

@@ -13331,6 +13331,14 @@
         "prop-types": "^15.7.2"
       }
     },
+    "react-easy-swipe": {
+      "version": "0.0.21",
+      "resolved": "https://registry.npmjs.org/react-easy-swipe/-/react-easy-swipe-0.0.21.tgz",
+      "integrity": "sha512-OeR2jAxdoqUMHIn/nS9fgreI5hSpgGoL5ezdal4+oO7YSSgJR8ga+PkYGJrSrJ9MKlPcQjMQXnketrD7WNmNsg==",
+      "requires": {
+        "prop-types": "^15.5.8"
+      }
+    },
     "react-error-overlay": {
       "version": "6.0.9",
       "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz",
@@ -13364,6 +13372,16 @@
       "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz",
       "integrity": "sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg=="
     },
+    "react-responsive-carousel": {
+      "version": "3.2.21",
+      "resolved": "https://registry.npmjs.org/react-responsive-carousel/-/react-responsive-carousel-3.2.21.tgz",
+      "integrity": "sha512-y2ueGqv/yo6HQJi9IbrJVRJobp4EOrNe6BQOC61CoADg3wUjq0gqAcrtSsLQIRLtbt6nCo7cTPRX4wAkSwdiTA==",
+      "requires": {
+        "classnames": "^2.2.5",
+        "prop-types": "^15.5.8",
+        "react-easy-swipe": "^0.0.21"
+      }
+    },
     "react-router": {
       "version": "5.2.1",
       "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.1.tgz",

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "react-dom": "^17.0.2",
     "react-dropzone": "^11.4.2",
     "react-redux": "^7.2.5",
+    "react-responsive-carousel": "^3.2.21",
     "react-router-dom": "^5.3.0",
     "react-scripts": "4.0.3",
     "redux": "^4.1.1",

+ 7 - 2
src/App.js

@@ -23,6 +23,9 @@ import RoleRoute from './Components/PrivateRoute';
 import ConnectNav from './Components/NaviBar';
 import CProfile from './Components/Profile';
 import CPost from './pages/PostAd';
+import СChange from './pages/EditAd';
+import Profile from './pages/Profile';
+import AdSearch from './pages/Search';
 
 function App() {
   return (
@@ -32,10 +35,12 @@ function App() {
           <ConnectNav />
           <Switch>
             <RoleRoute exact path='/' roles ={['user']} component = {TypeAd}  />
-            <RoleRoute path='/home/:id' roles={['user']} component={TypeAdOne} />
+            <RoleRoute path='/home/:id' roles={['user']} component={TypeAdOne} exact/>
+            <RoleRoute path='/home/edit/:id' roles={['user']} component={СChange} exact/>
             <RoleRoute path='/login' roles={['unknown']} component={ConnectLog}/>
             <RoleRoute path='/sign' roles={['unknown']} component={ConnectSign}/>
-            <RoleRoute path='/profile' roles={['user']} component={CProfile} />
+            <RoleRoute path='/search/' roles={['unknown']} component={AdSearch} />
+            <RoleRoute path='/profile' roles={['user']} component={Profile} />
             <RoleRoute path='/post-ad' roles={['user']} component={CPost} />
             <RoleRoute path='/instruction' roles={['unknown']} component={Instruction} />
             <RoleRoute path='/advertisment' roles={['unknown']} component={Advertisment} />

+ 70 - 3
src/App.scss

@@ -1,4 +1,5 @@
 @import "~bootstrap/scss/bootstrap";
+
 html,body {
     width: 100%;
     max-width: 100%;
@@ -46,6 +47,45 @@ html,body {
     
 }
 
+
+.d1 {
+    background: #002f34;
+
+    form {
+        position: relative;
+        width: 300px;
+
+        input {
+            width: 100%;
+            height: 35px;
+            padding-left: 10px;
+            border: 2px solid #FFF;
+            border-radius: 5px;
+            outline: none;
+            background: #FFF;
+            color: #000;
+        }
+
+        .search {
+          position: absolute; 
+          top: 0;
+          right: 0;
+          width: 35px;
+          height: 35px;
+          border: none;
+          border-radius: 5px;
+          background: #fff;
+          cursor: pointer;
+          img{
+              margin-top: 5px;
+              margin-left: 8px;
+              width: 25px;
+          }
+        }
+    }
+}
+
+
 .divLogin {
     display: flex;
     flex-direction: column;
@@ -123,6 +163,7 @@ html,body {
     background-color: whitesmoke;
     padding: 10px;
     overflow-x: hidden;
+
     img {
         max-width: 200px;
         min-width: 200px;
@@ -137,19 +178,44 @@ html,body {
         color:black;
         font-size: 25px;
     }
+
     a:hover {
         background-color: #002f34;
         color: white;
     }
+
+    .href {
+        margin-top:15px;
+        font-size: 20px;
+    }
 }
 
-.adone {
+.AdPage {
     display: flex;
-    flex-direction: column;
     justify-content: center;
     align-items: center;
+    flex-direction: column;
+    margin: 25px 0;
+    .carousel {
+        width: 50%;
+        margin-bottom: 20px;
+        img {
+            height: 45vh
+        }
+    }
+    .mainInfo {
+        margin-bottom: 20px;
+        padding: 10px;
+        width: 50%;
+        background-color: whitesmoke;
+        display: flex;
+        flex-direction: column;
+        justify-content: flex-start;
+        border-radius: 15px;
+    }
 }
 
+
 .post {
     margin-top: 25px;
     padding: 25px 15px;
@@ -167,7 +233,7 @@ html,body {
 
 .loader {
     position: absolute;
-    top: 40%;
+    top: calc(50% - 80px);
     left: calc(50% - 80px);
     display: flex;
     justify-content: center;
@@ -207,6 +273,7 @@ html,body {
         }
     }
 }
+
 .foter__indent {
     min-height: 150px;
 }

+ 40 - 9
src/Components/AdOne.js

@@ -1,17 +1,48 @@
 import React from "react"; 
-import { Container,Carousel } from "react-bootstrap";
+import { Container } from "react-bootstrap";
+import { Carousel } from 'react-responsive-carousel';
+import nofoto from '../images/placeholder.png'
+import "react-responsive-carousel/lib/styles/carousel.min.css";
 
-export const AdOne=({price, title,description,images}) => {
+export const AdOne=({price, title,description,images,comments,createdAt,owner}) => {
+    function timeConverter(t){
+        let a = new Date(+t);
+        let months = ['Января','Февраля','Марта','Апреля','Мая','Июня','Июля','Августа','Сентября','Октября','Ноября','Декабря'];
+        let year = a.getFullYear();
+        let month = months[a.getMonth()];
+        let date = a.getDate();
+        let hour = a.getHours();
+        let min = a.getMinutes();
+        let sec = a.getSeconds();
+        let time = date + ' ' + month + ' ' + year + ' в ' + hour + ':' + min ;
+        return time;
+      }
     return (
         <Container>
-            <div>
-                <Carousel>
-                    <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images ? images[0]?.url : ''}`} />
+            <div className='AdPage '>
+                <Carousel className='carousel' infiniteLoop useKeyboardArrows showStatus={false} showThumbs={false} >
+                    {images? images.map(image =>  
+                        <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${image.url}`} />
+                    ): <img src={nofoto} />} 
+                    
                 </Carousel>
-                <p>{title}</p>
-                <p>{description}</p>
-                <p>{`${price ? price : "0"} грн.`}</p>
+                <div className='mainInfo'>
+                    <p>{`Опубликовано: ${timeConverter(createdAt)}`}</p>
+                    <b>{title}</b>
+                    <h4>{`${price ? price : "0"} грн.`}</h4>
+                    <p>{description}</p>
+                    <p>{`Владелец: ${owner.login}`}</p>
+                    <p>{`На marketplace c: ${timeConverter(owner.createdAt)}`}</p>
+                </div>
+                <div className='mainInfo'>
+                    {comments ? 
+                        comments.map(comment => {
+                            return (<div><p>{`Коментарии : ${comment.text}`}</p>
+                            <p>{`От: ${comment.owner.login}`}</p></div>)})
+                            : <p>Коментариев нет</p>
+                    }
+                </div>
             </div>
-            </Container>
+        </Container>
     )
 }

+ 6 - 8
src/Components/CAdFeed.js

@@ -18,22 +18,20 @@ export const AdFeed=({_id, price,title,description,images,comments,createdAt}) =
       }
     return (
         <Container>
-            <div className="row ad">
+            <div className="row ad ">
                 <div className="col img">
-                    <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images ? images[0]?.url : nofoto}`} />
+                    {images ?
+                        <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images[0]?.url}`} />
+                        : <img src={nofoto} />
+                    }
                 </div> 
-                <div className="col-6" info>   
+                <div className="col-6 info">   
                     <Link to={ `/home/${_id}`}>{title}</Link>
                     <p>{description}</p>
                 </div>
                 <div className="col price">   
                     <p>{`Цена: ${price ? price : "0"} грн.`}</p>
-                    <p>{`Добавлено: ${timeConverter(createdAt)}`}</p>
                 </div> 
-                <div>
-                    <p>{`Коментарии : ${comments ? comments[0]?.text : 'отсутвуют'}`}</p>
-                    <p>{`От : ${comments ? comments[0].owner.login : '-'}`}</p>
-                </div>   
             </div>
         </Container> 
     )

+ 0 - 1
src/Components/DropZone.js

@@ -13,7 +13,6 @@ export function MyDropzone({onSend}) {
       loading.current = true
     }
     return (
-      
         <div {...getRootProps({className: 'dropzone'})}>
           <input {...getInputProps() }/>
           <p>Нажмите для смены аватарки</p>

+ 7 - 6
src/Components/MyPosts.js

@@ -20,20 +20,21 @@ export const MyFeed=({_id, price, owner,title,description,images,comments,create
         <Container>
             <div className="row ad">
                 <div className="col img">
-                    <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images ? images[0]?.url : nofoto}`} />
+                    {images ? 
+                        <img src = {`http://marketplace.asmer.fs.a-level.com.ua/${images[0]?.url}`} />
+                        : <img src={nofoto} />
+                    }
                 </div> 
                 <div className="col-6" info>   
                     <Link to={ `/home/${_id}`}>{title}</Link>
                     <p>{description}</p>
                 </div>
                 <div className="col price">   
-                    <p>{owner}</p>
                     <p>{`${price ? price : "0"} грн.`}</p>
-                </div> 
+                </div>
                 <div>
-                    <p>{`Коментарии : ${comments ? comments[0]?.text : 'отсутвуют'}`}</p>
-                    <p>{`От : ${comments ? comments[0].owner.login : '-'}`}</p>
-                </div>   
+                <Link className='href' to={`/home/edit/${_id}`}>Редактировать</Link>
+                </div> 
             </div>
         </Container> 
     )

+ 4 - 1
src/Components/NaviBar.js

@@ -4,6 +4,7 @@ import { Navbar, Nav, NavDropdown, Container } from 'react-bootstrap';
 import {Link} from "react-router-dom";
 import { connect } from 'react-redux';
 import CButtonLogout from './Logout';
+import Search from './Search';
 
 export function Navibar({isLogin}){
     return(
@@ -11,11 +12,13 @@ export function Navibar({isLogin}){
         <Navbar className='Navbar'>
             <Container className='header'>
               <Navbar.Brand><Link to="/"><img src={logo} alt={"logo"}/></Link></Navbar.Brand>
+              {isLogin && <Search /> }
               <Navbar.Toggle aria-controls="basic-navbar-nav" />
               <Navbar.Collapse id="basic-navbar-nav">
                 <Nav>
                   {isLogin ? (
-                    <>  
+                    <>
+                      
                       <Nav.Link><Link to='/post-ad'>Добавить товар</Link></Nav.Link>
                       <Nav.Link><Link to='/profile'>Профиль</Link></Nav.Link>
                       <Nav.Link><CButtonLogout /></Nav.Link>

+ 5 - 3
src/Components/Profile.js

@@ -13,14 +13,16 @@ const Profile = ({ userData, postsData, getPosts }) => {
         <CPromiseComponent promiseName='UserInfo'>
             <Container>
                 <div className='d-flex flex-column justify-content-center align-items-center profile'>
-                    <p>{userData?.login}</p>
+                    <h4>{userData?.login}</h4>
                     <img src={userData?.avatar ? userData?.avatar.url : unknown} />
                     <CDrop />
                 </div>
                 <div>
                     <h4>Ваши объявления:</h4>
-                    {Object.keys(postsData).length == 0 && <h6>У вас еще нет обьявлений</h6>}
-                    {postsData?.map(ad => <MyFeed key={ad._id} _id = {ad. _id} price = {ad.price} title = {ad.title} description={ad.description} owner={ad.owner} images={ad.images} comments={ad.comments} />) }
+                    <CPromiseComponent promiseName='MyPosts'>
+                        {postsData && Object.keys(postsData).length == 0 && <h6>У вас еще нет обьявлений</h6>}
+                        {postsData?.map(ad => <MyFeed key={ad._id} _id = {ad. _id} price = {ad.price} title = {ad.title} description={ad.description} owner={ad.owner} images={ad.images} comments={ad.comments} />) }
+                    </CPromiseComponent>
                 </div>
             </Container>
         </CPromiseComponent>

+ 18 - 0
src/Components/Search.js

@@ -0,0 +1,18 @@
+import { useState } from "react"
+import { Link } from "react-router-dom"
+import { actionSearch } from "../actions"
+import loop from '../images/search.svg'
+
+const Search = ({}) => {
+    const [search,setSearch] = useState('')
+    return (
+        <div class="d1">
+            <form>
+                <input type="text" value={search} onChange={e => setSearch(e.target.value)} placeholder="Искать здесь" />
+                <Link to='/search/' className='search'><img src={loop} /></Link>
+            </form>
+        </div>
+    )
+}
+
+export default Search

+ 73 - 6
src/actions/index.js

@@ -54,9 +54,6 @@ export const actionFullLogin = (login, password) => {
           dispatch(actionAuthLogin(result))
           dispatch(actionUserInfo())
       }
-      else {
-        console.log('undefined user')
-      }
   }
 }
 
@@ -109,10 +106,28 @@ export const actionTypeAdOne = (id) =>
                 images {
                   url
                 }
+                comments {
+                  _id text owner {login} answerTo { text owner{ login}}
+                }
+                createdAt
+                owner {login , createdAt}
               }
             }`,{query: JSON.stringify([{_id:id}])}))
 
-export const actionPostAd = (title,description,price) =>
+
+// export const actionComments = (ad) => 
+//             actionPromise('Comments',shopGQL(`
+//             query Comments($query: String){
+//               CommentFind(query: $query){
+//                 _id
+//                 text
+//                 owner {login}
+//                 ad {_id}
+//                 answerTo {text owner{login}}
+//               }
+//             }`,{query: JSON.stringify([{}])}))
+
+export const actionPostAd = (title,description,price,_id) =>
             actionPromise('PostAd',shopGQL(`
             mutation Post($ad: AdInput){
               AdUpsert(ad: $ad) {
@@ -124,7 +139,7 @@ export const actionPostAd = (title,description,price) =>
                     url
                   }
                 }
-              }`,{ad: {title,description,price}}))
+              }`,{ad: {title,description,price,_id}}))
 
 export const actionMyPosts = () =>
     async (dispatch,getState) => {
@@ -197,4 +212,56 @@ export const actionUserInfo = () =>
         }
       }`,{query: JSON.stringify([{_id: userId}])})))
   }
-  
+
+
+const regexp = (string) => `/${string.split([" "]).join(['|']).trim()}/`
+const toQuery = (queryString, fields = ["title", "description"]) => ({ $or: fields.map(string => ({ [string]: regexp(queryString) }))})
+export const actionSearch = (queryString) => 
+async (dispatch) =>
+  await dispatch(actionPromise('SearchAd',shopGQL(`
+  query AdFind($query: String){
+    AdFind(query: $query) {
+      _id
+      title
+      description
+      price
+      images {
+        url
+      }
+    }
+  }`,{query: JSON.stringify([toQuery(queryString),
+      {
+        sort: [{_id: -1}],
+        limit: [15]
+      }]
+    )}
+  )
+))
+
+// const toRegexp2 = queryString => `/${queryString.split([" "]).join(['|']).trim()}/`
+// const toQuery = (queryString, fields = ["id3.artist", "id3.title", "id3.album"]) => ({ $or: fields.map(x => ({ [x]: toRegexp2(queryString) })) })
+
+// const actionSearch = (queryString) =>
+//     async dispatch => {
+//         let searchData = await dispatch(actionPromise('search', gql(
+//             `query trackFind($query: String) {
+//             TrackFind(query:$query)
+//               {
+//                   originalFileName
+//                   url
+//                   id3 {
+//                           title
+//                           artist
+//                           album
+//                       }
+//               }
+//           }`, {
+//             query: JSON.stringify([toQuery(queryString),
+//             {
+//                 sort: [{ _id: -1 }], //сортировка в обратном хронологическом порядке
+//                 limit: [10],  //100 записей максимум
+//             }])
+//         }
+//         )))
+//         console.log(searchData)
+//     }

+ 1 - 0
src/images/search.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>

+ 2 - 2
src/pages/AdOne.js

@@ -11,8 +11,8 @@ export const Ad = ({getData,data, match:{params:{id}}}) => {
     if(data){
         return (
             <CPromiseComponent promiseName='AdFindOne'>
-                <div className="adone">
-                    <AdOne key={data._id} price = {data.price} title = {data.title} description={data.description}  images={data.images} />
+                <div>
+                    <AdOne key={data._id} price = {data.price} title = {data.title} description={data.description} owner ={data.owner} images={data.images} createdAt={data.createdAt} comments={data.comments}/>
                 </div>
             </CPromiseComponent>
         )

+ 51 - 0
src/pages/EditAd.js

@@ -0,0 +1,51 @@
+import React ,{useState,useEffect} from "react";
+import { connect } from "react-redux";
+import { actionPostAd, actionTypeAdOne } from "../actions";
+import { Container } from "react-bootstrap";
+import CPromiseComponent from "../Components/PromiseComponent";
+import { Redirect } from "react-router";
+
+
+const Post = ({data,onChange,match:{params:{id}},getData, posted}) => {
+    let [title,setTitle] = useState('')
+    let [description,setDescription] = useState('')
+    let [price,setPrice] = useState(0)
+
+    useEffect(()=>{
+        setTitle(data?.title)
+        setDescription(data?.description)
+        setPrice(data?.price)
+    },[data])
+
+    useEffect(() => 
+        getData(id),[id]
+    )
+    
+    return (
+        <>
+            <CPromiseComponent promiseName='AdFindOne'>
+                <Container >
+                    <div className='d-flex flex-column align-items-start post'>
+                        <label>Введите название</label>
+                        <input value={title} onChange={e => setTitle(e.target.value)} ></input>
+                    </div>
+                    <div className='d-flex flex-column align-items-start post'>
+                        <label>Описание</label>
+                        <textarea rows="5" cols="75" value={description} onChange={e => setDescription(e.target.value)} ></textarea>
+                    </div>
+                    <div className='d-flex flex-column align-items-start post'>
+                        <label>Введите цену</label>
+                        <input type={"number"} value={price} onChange={e => e.target.value>=0 ? setPrice(+e.target.value) : ""} ></input>
+                    </div>
+                    <div className="d-flex flex-column align-items-end post">
+                        <button onClick={()=> onChange(title,description,price,data._id)}>Изменить объявление</button>
+                    </div>
+                </Container>
+            </CPromiseComponent>
+            {posted && <Redirect push to ='/profile'/>} 
+        </>
+    )
+}
+
+const CChange = connect(state => ({data: state.promiseReducer.AdFindOne?.payload?.data?.AdFindOne, posted: state.promiseReducer.PostAd?.payload?.data?.AdUpsert}),{onChange: actionPostAd, getData: actionTypeAdOne})(Post)
+export default CChange

+ 1 - 1
src/pages/Home.js

@@ -14,7 +14,7 @@ export const Home = ({getData,data}) => {
         return (
             <CPromiseComponent promiseName='AdFind'>
                 <div>
-                    {data.map(ad => <AdFeed key={ad._id} _id = {ad. _id} price = {ad.price} title = {ad.title} description={ad.description} owner={ad.owner} images={ad.images} comments={ad.comments} createdAt={ad.createdAt} />)}
+                    {data.map(ad => <AdFeed key={ad._id} _id = {ad. _id} price = {ad.price} title = {ad.title} description={ad.description} owner={ad.owner} images={ad.images} comments={ad.comments} />)}
                 </div>
             </CPromiseComponent>
         )

+ 2 - 1
src/pages/Login.js

@@ -56,11 +56,12 @@ const loginCallback = () => {
                 Не зарегистрированы? <Link to='sign' className='mb-3'>Создать аккаунт</Link>
                 <Button name='Войти' isValid={isLoginValid()} callback={loginCallback} /> 
             </div> 
+                {(loggedIn === null) && <p>Неверный логин или пароль</p>}
                 {show && (!login || !password) && <LoginError />}
         </div>
   )
 }
 
 
-const ConnectLog = connect(state => ({loggedIn: state.authReducer}), {onLogin: actionFullLogin})(LoginForm)
+const ConnectLog = connect(state => ({loggedIn: state.promiseReducer?.login?.payload}), {onLogin: actionFullLogin})(LoginForm)
 export default ConnectLog

+ 8 - 0
src/pages/Profile.js

@@ -0,0 +1,8 @@
+import CProfile from "../Components/Profile"
+const Profile = ({}) => {
+    return (
+        <CProfile />
+    )
+}
+
+export default Profile

+ 20 - 0
src/pages/Search.js

@@ -0,0 +1,20 @@
+import React, {useEffect} from "react";
+import {connect}   from 'react-redux';
+import {AdFeed} from "../Components/CAdFeed";
+import { actionSearch} from "../actions";
+import CPromiseComponent from "../Components/PromiseComponent";
+export const Search = ({getData,data}) => {
+    useEffect(()=>getData(),[])
+    
+        return (
+            <CPromiseComponent promiseName='SearchAd'>
+                <div>
+                    {data?.map(ad => <AdFeed key={ad._id} _id = {ad. _id} price = {ad.price} title = {ad.title} description={ad.description} images={ad.images} />)}
+                </div>
+            </CPromiseComponent>
+        )
+    
+}
+
+const AdSearch = connect(state => ({data: state.promiseReducer.SearchAd?.payload?.data?.AdFind}),{getData: actionSearch})(Search)
+export default AdSearch

+ 5 - 4
src/pages/Sign.js

@@ -9,9 +9,9 @@ import NumberCheckPass from "../Components/RegErrors/numberCheckPass";
 import showPwdImg from '../images/3844476-eye-see-show-view-watch_110339.svg';
 import hidePwdImg from '../images/3844477-disable-eye-inactive-see-show-view-watch_110343.svg';
 import Button from "../Components/Button";
-import { MyDropzone } from "../Components/DropZone";
 
-const Sign = ({onSign,loggedIn}) => {
+
+const Sign = ({onSign,Reg}) => {
     const [login,setLogin] = useState('')
     const [password,setPassword] = useState('')
     const [password2,setPassword2] = useState('')
@@ -72,11 +72,12 @@ const Sign = ({onSign,loggedIn}) => {
                 {show && (!login || password.length<3 || password2.length<3) && <MinPass/>}
                 {show2 && (!password.match(/\d/)) && <NumberCheckPass />}
                 {show3 && (password !== password2) && <ConfirmPass />}
-                {loggedIn && <Redirect push to='/'/>}
+                {(Reg === null) && <p>Данный пользователь уже зарегистрирован</p>}
+                {Reg && <Redirect push to='/'/>}
       </div>
 
     )
 }
 
-const ConnectSign = connect(state=> ({loggedIn:state.authReducer.payload}),{onSign: actionFullRegister})(Sign)
+const ConnectSign = connect(state=> ({Reg:state.promiseReducer.reg?.payload?.data?.createUser}),{onSign: actionFullRegister})(Sign)
 export default ConnectSign