Browse Source

Update route

LenDoc 2 years ago
parent
commit
852555f83a
4 changed files with 15 additions and 12 deletions
  1. 13 10
      src/App.js
  2. 1 1
      src/components/User.js
  3. 0 0
      src/components/WorkApp.js
  4. 1 1
      src/reducers/index.js

+ 13 - 10
src/App.js

@@ -62,17 +62,17 @@ const Main = ({ _id }) => {
       //   actionClearDataUserType() 
    <Switch>
       <Route path='/login'
-            component={CLoginForm} exact  />
-          {/* <Route path='/input'
-            component={InputForm} /> */}
+            component={CLoginForm}  />
+          <Route path='/input'
+            component={InputForm} />
             <Route path='/register'
             component={CRegisterForm}   />
-            <CProtectedRoute
+            {/* <CProtectedRoute
             roles={['anon']}
             fallback="/input"
             path="/*"
             component={InputForm}
-          />
+          /> */}
           {/* <Redirect from='/*' to='/input' /> */}
        </Switch >  
           // }  
@@ -85,12 +85,12 @@ const Main = ({ _id }) => {
     <Route path="/edit/post/:_id" component={CPostEditor}   />
     <Route path="/post/:_id" component={CPost}   />
     <Route path="/feed" component={CPostForFeed}   />
-    <CProtectedRoute
+    {/* <CProtectedRoute
             roles={['user']}
             fallback="/feed"
             path="/*"
             component={CPostForFeed}
-          />
+          /> */}
 
 </Switch>
     )
@@ -134,9 +134,12 @@ function App() {
 
   if (store.getState().auth?.token) {
     history.push('/feed')
+    store.dispatch(actionRemoveDataUser())
+    // store.dispatch(actionClearUserData())
+    store.dispatch(actionClearDataUserType())
     console.log('токен', store.getState().auth?.payload?.sub?.id)
     store.dispatch(actionFullProfilePage(store.getState().auth?.payload?.sub?.id))
-    store.dispatch(actionFullProfilePageUser(store.getState().auth?.payload?.sub?.id))
+    store.dispatch(actionFullProfilePageUser(store.getState().auth.payload.sub?.id))
     localStorage.authToken = store.getState().auth?.token;
   }else {
     history.push('/input')
@@ -145,13 +148,13 @@ function App() {
     store.dispatch(actionClearDataUserType())
   }
 
-  store.getState().auth.payload?.sub?.id ? <Redirect to="/"/> : <Redirect to="/input"/>
+  // store.getState().auth.payload?.sub?.id ? <Redirect to="/"/> : <Redirect to="/input"/>
   return (
     <Router history={history}>
       <Provider store={store}>
         <div className="App">
           <Divider />
-          <OldMain />
+          <CMain />
 {/*          
           <CProtectedRoute
             roles={['anon']}

+ 1 - 1
src/components/User.js

@@ -262,7 +262,7 @@ const Subscribe = ({
 
 export const CPageAboutUser = connect(
   (state) => ({
-    my_Id: state.auth.payload.sub.id || '',
+    my_Id: state.auth.payload.sub.id,
     aboutUser: state.profilePage?.aboutUser,
     aboutUserFollowers: state.profilePage?.aboutUser?.followers,
     aboutUserFollowing: state.profilePage?.aboutUser?.following,

+ 0 - 0
src/components/WorkApp.js


+ 1 - 1
src/reducers/index.js

@@ -66,7 +66,7 @@ export const actionProfilePageData = (id) => ({ type: 'DATA_PROFILE', id })
   export const actionFullProfilePage = (_id) =>
   async dispatch => {
     const aboutMe = await dispatch(actionAboutMe(_id))
-    console.log('aboutMe ', aboutMe)
+    console.log('попало ли в запрос на єбоут ми ', aboutMe)
     // const allPostsMe = await dispatch(actionAllPosts(_id))
     if (aboutMe) {
       await dispatch(actionProfilePageDataType(aboutMe))