4 Commits 26f7588f0b ... e260885cf2

Author SHA1 Message Date
  Svetlana e260885cf2 merge Sveta 5 years ago
  Svetlana a1765cd5e1 deleteUser, saga 5 years ago
  sveta db93874791 change and logit password 5 years ago
  = 3d5c13feeb added cards page -> card preview proto 5 years ago
30 changed files with 2098 additions and 249 deletions
  1. 1735 119
      package-lock.json
  2. 2 0
      package.json
  3. 16 0
      src/actions/adminActions/index.js
  4. 15 0
      src/actions/cards/index.js
  5. 24 18
      src/components/common/protectedRoute/config.js
  6. 4 4
      src/components/common/protectedRoute/index.js
  7. 6 0
      src/components/common/protectedRoute/validate/index.js
  8. 27 27
      src/components/public-components/auth/signInForm/index.js
  9. 12 12
      src/components/public-components/header/index.js
  10. 22 0
      src/components/user-components/CardsPage/cardPreview/index.js
  11. 52 0
      src/components/user-components/CardsPage/index.js
  12. 29 0
      src/components/user-components/admin-components/createDeleteUser/index.js
  13. 2 5
      src/components/user-components/admin-components/createTestForm/validate/index.js
  14. 2 2
      src/components/user-components/profilePage/LoginFild/index.js
  15. 1 1
      src/components/user-components/profilePage/LoginFild/loginChangeForm/index.js
  16. 1 1
      src/components/user-components/profilePage/PasswordFields/PasswordChangeForm/index.js
  17. 3 3
      src/components/user-components/profilePage/PasswordFields/index.js
  18. 10 10
      src/components/user-components/profilePage/index.js
  19. 10 4
      src/constants/index.js
  20. 35 0
      src/reducers/cards/index.js
  21. 3 3
      src/reducers/index.js
  22. 8 5
      src/reducers/initialState/index.js
  23. 4 8
      src/router.js
  24. 13 15
      src/saga/auth/signIn/index.js
  25. 21 0
      src/saga/cards/getCards/index.js
  26. 8 0
      src/saga/cards/index.js
  27. 3 4
      src/saga/index.js
  28. 4 4
      src/saga/userFields/changeEmail/index.js
  29. 8 4
      src/saga/userFields/changePassword/index.js
  30. 18 0
      src/saga/userFields/createDeleteUser/index.js

File diff suppressed because it is too large
+ 1735 - 119
package-lock.json


+ 2 - 0
package.json

@@ -11,7 +11,9 @@
     "prop-types": "^15.6.2",
     "react": "^16.6.3",
     "react-dom": "^16.6.3",
+    "react-image": "^2.0.0",
     "react-loader-spinner": "^2.3.0",
+    "react-native": "^0.57.8",
     "react-redux": "^6.0.0",
     "react-router-dom": "^4.3.1",
     "react-scripts": "^2.1.3",

+ 16 - 0
src/actions/adminActions/index.js

@@ -0,0 +1,16 @@
+import * as types from '../../constants';
+
+export const userGetRequest = payload => ({
+    type: types.USERS_GET_REQUEST,
+    payload
+})
+
+export const userGetRequestSucces = payload => ({
+    type: types.USERS_GET_REQUEST_SUCCESS,
+    payload
+})
+
+export const userGetRequestFailure = error => ({
+    type: types.USERS_GET_REQUEST_FAILURE,
+    error
+})

+ 15 - 0
src/actions/cards/index.js

@@ -0,0 +1,15 @@
+import * as actionTypes from './../../constants';
+
+export const getCards = () => ({
+    type: actionTypes.GET_CARDS
+})
+
+export const getCardsSuccess = (payload) => ({
+    type: actionTypes.GET_CARDS_SUCCESS,
+    payload
+})
+
+export const getCardsFailure = (error) => ({
+    type: actionTypes.GET_CARDS_FAILURE,
+    error
+})

+ 24 - 18
src/components/common/protectedRoute/config.js

@@ -1,49 +1,55 @@
+import React from 'react';
 import * as routes from './../../../constants/routes';
 import { lazy } from 'react';
 
-const landingPage = lazy(() => import('./../../public-components/landingPage'));
-const homePage = lazy(() => import('./../../user-components/homePage'));
-const signInPage = lazy(() => import('./../../../containers/auth/SignInPage'));
-const signUpPage = lazy(() => import('./../../../containers/auth/SignUpPage'));
-const createTestForm = lazy(() => import('./../../user-components/admin-components/createTestForm'));
-const profilePage = lazy(() => import('./../../user-components/profilePage'));
-const categoriesPage = lazy(() => import('./../../user-components/categoriesPage'));
-
+const LandingPage =    lazy(() => import('./../../public-components/landingPage'));
+const HomePage =       lazy(() => import('./../../user-components/homePage'));
+const SignInPage =     lazy(() => import('./../../../containers/auth/SignInPage'));
+const SignUpPage =     lazy(() => import('./../../../containers/auth/SignUpPage'));
+const CreateTestForm = lazy(() => import('./../../user-components/admin-components/createTestForm'));
+const ProfilePage =    lazy(() => import('./../../user-components/profilePage'));
+const CategoriesPage = lazy(() => import('./../../user-components/categoriesPage'));
+const CardsPage =      lazy(() => import('./../../user-components/CardsPage'));
+const NotFound =       lazy(() => import('./../../public-components/notFound'));
 
 export default [
     {
         path: routes.LANDING,
         access: 'public',
-        component: landingPage
+        component: LandingPage
     },
     {
         path: routes.SIGN_IN,
         access: 'public',
-        component: signInPage
+        component: SignInPage
     },
     {
         path: routes.SIGN_UP,
         access: 'public',
-        component: signUpPage
+        component: SignUpPage
     },
     {
         path: routes.HOME,
         access: 'user-only',
-        component: homePage
+        component: HomePage
     },
     {
         path: routes.CATEGORIES,
         access: 'user-only',
-        component: categoriesPage
+        component: CategoriesPage
     },
     {
         path: routes.PROFILE,
         access: 'user-only',
-        component: profilePage
+        component: ProfilePage
+    },
+    {
+        path: routes.TESTS,
+        access: 'user-only',
+        component: CardsPage
     },
     {
-        path: routes.CREATE_TEST,
-        access: 'admin-only',
-        component: createTestForm
-    }
+        access: 'public',
+        component: NotFound
+    },
 ]

+ 4 - 4
src/components/common/protectedRoute/index.js

@@ -4,7 +4,7 @@ import { Route, Redirect } from 'react-router-dom';
 import * as routes from './../../../constants/routes';
 import PermissionDenied from './../../public-components/permissionDenied';
 
-export default ({ component: Component, user, access, ...rest  }) => (
+export default ({ component: Component, user: {data}, access, ...rest  }) => (
     <Route
         {...rest}
         render={props => {
@@ -13,16 +13,16 @@ export default ({ component: Component, user, access, ...rest  }) => (
                 return <Component {...props} />
             }
             
-            if ( (access === 'user-only' || access === 'admin-only') && !user.data ) {
+            if ( (access === 'user-only' || access === 'admin-only') && !data ) {
                 return <Redirect to={routes.SIGN_IN}/>
             }
             
-            if (access === 'user-only' && user.data) {
+            if (access === 'user-only' && data) {
                 return <Component {...props} />
             }        
 
             if (access === 'admin-only') {
-                if (user.isAdmin) {
+                if (data.is_admin) {
                     return <Component {...props} />
                 } 
 

+ 6 - 0
src/components/common/protectedRoute/validate/index.js

@@ -0,0 +1,6 @@
+export default function validate(values) {
+    const {} = values;
+    const errors = {}
+
+    return errors;
+}

+ 27 - 27
src/components/public-components/auth/signInForm/index.js

@@ -8,34 +8,34 @@ import { Link } from 'react-router-dom'
 import * as routes from './../../../../constants/routes'
 
 class Form extends React.Component {
-    sendRequest = values => {
-        const { actions: { signInRequest } } = this.props;
-        signInRequest(values);
-    }
-
-    render() {
-        const { invalid, handleSubmit, submitting, requestError } = this.props;
-
-        return (
-            <form className="sign-form" onSubmit={handleSubmit(this.sendRequest)}>
-                <h2 className="sign-form__header">Sign In</h2>
-                
-                {requestError && <p className="error-line error-line--warn error-line--no-margin">{requestError}</p>}
-
-                <Field className="sign-form__input sign-form__input--text" placeholder="Login" name="login" component={formInput} type="text" />
-                <Field className="sign-form__input sign-form__input--password" placeholder="Password" name="password" component={formInput} type="password" />
-                
-                <button className="link--btn link--btn60" disabled={invalid || submitting}>Sign In</button>
-                
-                <p className="sign-form__link--forgot-password"><Link className="link--inline" to={routes.PASSWORD_FORGET}>Forgot password ?</Link></p>
-                <hr className="sign-form__divider" />
-                <p className="sign-form__link--sign-up">Still ain't got an account? <Link className="link--inline" to={routes.SIGN_UP}>Sign up</Link> first!</p>
-            </form>
-        )
-    }
+  sendRequest = values => {
+    const { actions: { signInRequest } } = this.props;
+    signInRequest(values);
+  }
+
+  render() {
+    const { invalid, handleSubmit, submitting, requestError } = this.props;
+
+    return (
+      <form className="sign-form" onSubmit={handleSubmit(this.sendRequest)}>
+        <h2 className="sign-form__header">Sign In</h2>
+
+        {requestError && <p className="error-line error-line--warn error-line--no-margin">{requestError}</p>}
+
+        <Field className="sign-form__input sign-form__input--text" placeholder="Login" name="login" component={formInput} type="text" />
+        <Field className="sign-form__input sign-form__input--password" placeholder="Password" name="password" component={formInput} type="password" />
+
+        <button className="link--btn link--btn60" disabled={invalid || submitting}>Sign In</button>
+
+        <p className="sign-form__link--forgot-password"><Link className="link--inline" to={routes.PASSWORD_FORGET}>Forgot password ?</Link></p>
+        <hr className="sign-form__divider" />
+        <p className="sign-form__link--sign-up">Still ain't got an account? <Link className="link--inline" to={routes.SIGN_UP}>Sign up</Link> first!</p>
+      </form>
+    )
+  }
 }
 
 export default reduxForm({
-    form: "signIn",
-    validate
+  form: "signIn",
+  validate
 })(Form)

+ 12 - 12
src/components/public-components/header/index.js

@@ -23,8 +23,8 @@ export default class header extends Component {
 
     render() {
         const { togglerClosed } = this.state;
-        const { user } = this.props;
-        const toggleStatus = togglerClosed ? "toggle-status--closed" : "toggle-status--opened"
+        const { user: { data } } = this.props;
+        const toggleStatus = togglerClosed ? "toggle-status--closed" : "toggle-status--opened";
 
         return (
             <header className="header">
@@ -42,40 +42,40 @@ export default class header extends Component {
                             <li>
                                 <Link className="header__nav nav__list-item" to={routes.HOME}>
                                     Home
-                                </Link>
+                </Link>
                             </li>
                             <li>
                                 <Link className="header__nav nav__list-item" to={routes.PROFILE}>
                                     Profile
-                                </Link>
+                </Link>
                             </li>
                             <li>
                                 <Link className="header__nav nav__list-item" to={routes.TESTS}>
                                     Test
-                                </Link>
+                </Link>
                             </li>
                             <li>
                                 <Link className="header__nav nav__list-item" to={routes.CATEGORIES}>
                                     Categories
-                                </Link>
+                </Link>
                             </li>
                             {
-                                user && user.isAdmin && (
+                                data && data.is_admin && (
                                     <React.Fragment>
                                         <li>
                                             <Link className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
                                                 Create test
-                                            </Link>
+                            </Link>
                                         </li>
                                         <li>
                                             <Link className="header__nav nav__list-item--admin-only" to={routes.CREATE_CATEGORY}>
                                                 Create category
-                                            </Link>
+                            </Link>
                                         </li>
                                         <li>
                                             <Link className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
-                                                Delete user
-                                            </Link>
+                                                Delete data
+                            </Link>
                                         </li>
                                     </React.Fragment>
                                 )
@@ -85,7 +85,7 @@ export default class header extends Component {
 
                     <div className="header__links">
                         {
-                            !user.data
+                            !data
                                 ? (
                                     <React.Fragment>
                                         <Link className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>

+ 22 - 0
src/components/user-components/CardsPage/cardPreview/index.js

@@ -0,0 +1,22 @@
+import React from 'react';
+
+const styles = {
+    img: {
+        display: 'inline-block'
+    },
+    h3: {
+        marginTop: 0
+    },
+    p: {
+
+    }
+}
+
+const CardPreview = ({ description, title, cover }) => (
+    <div className=''>
+        <img src={cover} style={styles.img}/>
+        <h3 style={styles.h3}>{title}</h3>
+    </div>  
+)
+
+export default CardPreview;

+ 52 - 0
src/components/user-components/CardsPage/index.js

@@ -0,0 +1,52 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+
+import { getCards } from './../../../actions/cards'
+
+import CardPreview from './cardPreview';
+import Spinner from './../../common/spinner';
+
+
+class CardsPage extends React.Component {
+    componentDidMount() {
+        const { getCards } = this.props;
+        getCards();
+    }
+
+    render() {
+        const { cards: { isFetching, data, error }, getCards } = this.props;
+        console.log('Pasha lox', isFetching, data, error);
+        console.log('PROPS', this.props);
+
+        return (
+            isFetching
+                ?
+                <Spinner />
+                : data
+                    ?
+                    <div className='page' >
+                        {data.map(card => (
+                            <CardPreview
+                                title={card.name}
+                                cover={card.image}
+                                action={null}
+                            />))}
+                    </div >
+                    : error
+                        ?
+                        <div className='page' >
+                            Error handler
+                        </div >
+                        :
+                        null
+        )
+    }
+}
+
+const mapStateToProps = state => ({
+    cards: state.cards
+});
+const mapDispatchToProps = dispatch => bindActionCreators({ getCards }, dispatch);
+
+export default connect(mapStateToProps, mapDispatchToProps)(CardsPage);

+ 29 - 0
src/components/user-components/admin-components/createDeleteUser/index.js

@@ -0,0 +1,29 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { Field, reduxForm } from 'redux-form';
+
+import formInput from '../../..//common/formInput';
+ submit=()=>{
+     
+ }
+
+class createDeleteUser extends React.Component {
+
+    render() {
+        const {  handleSubmit  } = this.props;
+        return (
+            <form  className="page">
+                <Field name="login"  type="email" placeholder="Enter new login" component={formInput} />
+                <button >Search</button>
+            </form >
+        )
+    }
+}
+
+
+const mapDispatchToProps = dispatch => bindActionCreators({ userGetRequest }, dispatch);
+
+
+export default connect(mapDispatchToProps)(reduxForm({
+    form: "createDeleteUser",   
+})(createDeleteUser))

+ 2 - 5
src/components/user-components/admin-components/createTestForm/validate/index.js

@@ -1,6 +1,3 @@
-export default function validate(values) {
-    const {} = values;
-    const errors = {}
-
-    return errors;
+export default () => {
+  
 }

+ 2 - 2
src/components/user-components/profilePage/LoginFild/index.js

@@ -13,7 +13,7 @@ export default class ChangeLogin extends React.Component {
 
     submit = ({ login }) => {
         console.log('handleSubmit->submit', this.props)
-        const { actions: { userChangeRequest }, user: { data: { id } } } = this.props;
+        const { actions: { userChangeRequest },  data: { id }  } = this.props;
 
         console.log('id', id);
 
@@ -38,7 +38,7 @@ export default class ChangeLogin extends React.Component {
                 (
                     <React.Fragment>
                         <div>{children}</div>
-                        <button onClick={handleClick}>Change Email</button>
+                        <button className="link link--btn right"onClick={handleClick}>Change Email</button>
                     </React.Fragment>
                 )
                 : (

+ 1 - 1
src/components/user-components/profilePage/LoginFild/loginChangeForm/index.js

@@ -13,7 +13,7 @@ class ChangeLoginForm extends React.Component {
             <form onSubmit={handleSubmit(submit)} >
                 <Field name="login" type="email" placeholder="Enter new login" component={formInput} />
                 <button
-                    type="button"
+                    type="button" className="link link--btn right"
                     onClick={
                         function() {
                             handleClick();

+ 1 - 1
src/components/user-components/profilePage/PasswordFields/PasswordChangeForm/index.js

@@ -13,7 +13,7 @@ class ChangePasswordForm extends React.Component {
             <form onSubmit={handleSubmit(submit)} >
                 <Field name="passwordConfirmation" type="password" placeholder="Enter password" component={formInput} />
                 <Field name="password" type="password" placeholder="Enter new password" component={formInput} />
-                <button onClick={handleClick}>Change</button>
+                <button className="link link--btn right" onClick={function(){handleSubmit(submit)}}>Change</button>
             </form >
         )
     }

+ 3 - 3
src/components/user-components/profilePage/PasswordFields/index.js

@@ -7,12 +7,12 @@ import ChangePasswordForm from './PasswordChangeForm'
 export default class ChangePassword extends React.Component {
 
     state = {
-        clicked: false,
+        clicked: false
     }
     
     submit = ({ password }) => {
         console.log('handleSubmit->submit', this.props)
-        const { actions: { passwordChangeRequest }, user: { data: { id } } } = this.props;
+        const { actions: { passwordChangeRequest },  data: { id } }  = this.props;
 
         console.log('id', id);
 
@@ -37,7 +37,7 @@ export default class ChangePassword extends React.Component {
                 (
                     <React.Fragment>
                         <div>{children}</div>
-                        <button onClick={handleClick}>Change password</button>
+                        <button className="link link--btn right" onClick={handleClick}>Change password</button>
                     </React.Fragment>
                     
                 )

+ 10 - 10
src/components/user-components/profilePage/index.js

@@ -1,4 +1,5 @@
 import React from 'react';
+import { AppRegistry, View, Image } from 'react';
 import { connect } from 'react-redux';
 import { bindActionCreators } from 'redux'
 // import {} from './../../../actions'
@@ -48,7 +49,7 @@ class profilePage extends React.Component {
 
 
     render() {
-        const { user, userChangeRequest } = this.props;
+        const { user:{data}, userChangeRequest,passwordChangeRequest } = this.props;
 
         // console.log('User', user);
         // console.log('Props', this.props);
@@ -57,33 +58,32 @@ class profilePage extends React.Component {
         return (
             <div className="page page--bottom-only profile-page">
                 <section className="container section section--about">
-                    <button onClick={this.lol}>adlkasjdakl</button>
-                    <h2 className="section__element section__element--header">{user.login}</h2>
-                    <img className="section__element section__element--image" src={user.avatar} alt="avatar" />
+                    {/* <h2 className="section__element section__element--header">{data.login}</h2> */}
+        
                     <div className="sedtion__element section__element--login">
-                        <h3>Login</h3>
+                        <h3>Email</h3>
                         {/* <p>{user.login}<button className="link link--btn right" >Change login</button></p> */}
-                        <ChangeLogin className="link link--btn right" user={user} actions={{ userChangeRequest }}>{user.login}</ChangeLogin>
+                        <ChangeLogin className="link link--btn right" data={data} actions={{ userChangeRequest }}>{data.login}</ChangeLogin>
                     </div>
                     <div className="section__element section__element--">
                         <h3>Password</h3>
-                        <ChangePassword className="link link--btn right" user={user} actions={{ passwordChangeRequest }}>{user.password}</ChangePassword>
+                        <ChangePassword className="link link--btn right" data={data} actions={{ passwordChangeRequest }}>{data.password}</ChangePassword>
                     </div>
                     <div className="section__element section__element--">
                         <h3>Status</h3>
-                        <p>{user.description}</p>
+                        <p>{data.description}</p>
                     </div>
                 </section>
                 <section className="container section section--stats">
                     <div className="section__element section__element--">
                         <h3>Member Since</h3>
-                        <p>{new Date(user.createdAt).toLocaleString()}</p>
+                        <p>{new Date(data.createdAt).toLocaleString()}</p>
                     </div>
                     <div className="section__element section__element--comments">
                         <h3>Last comments</h3>
                         <p className="comments-block">
                             {
-                                user.comments && user.comments
+                                data.comments && data.comments
                                     .slice(0, 60)
                                     .map(el =>
                                         <p>

+ 10 - 4
src/constants/index.js

@@ -1,9 +1,9 @@
-export const SIGN_IN_URL = 'https://quiz.maxcrc.de/api/v1/user?';
+export const SIGN_IN_URL = 'http://quiz.maxcrc.de/api/v1/user?';
 export const SIGN_IN_REQUEST = 'SIGN_IN_REQUEST';
 export const SIGN_IN_REQUEST_SUCCESS = 'SIGN_IN_REQUEST_SUCCESS';
 export const SIGN_IN_REQUEST_FAILURE = 'SIGN_IN_REQUEST_FAILURE';
 
-export const SIGN_UP_URL = 'https://quiz.maxcrc.de/api/v1/user';
+export const SIGN_UP_URL = 'http://quiz.maxcrc.de/api/v1/user';
 export const SIGN_UP_REQUEST = 'SIGN_UP_REQUEST';
 export const SIGN_UP_REQUEST_SUCCESS = 'SIGN_UP_REQUEST_SUCCESS';
 export const SIGN_UP_REQUEST_FAILURE = 'SIGN_UP_REQUEST_FAILURE';
@@ -19,11 +19,17 @@ export const USERS_GET_REQUEST_SUCCESS_FAILURE = 'USERS_GET_REQUEST_FAILURE';
 
 export const TOKEN_AUTH = 'TOKEN_AUTH';
 
-export const USERS_CHANGE_URL = 'https://quiz.maxcrc.de/api/v1/user/';
+export const USERS_CHANGE_URL = 'http://quiz.maxcrc.de/api/v1/user/';
 export const USERS_CHANGE_REQUEST = 'USERS_CHANGE_REQUEST';
 export const USERS_CHANGE_REQUEST_SUCCESS = 'USERS_CHANGE_REQUEST_SUCCESS';
 export const USERS_CHANGE_REQUEST_FAILURE = 'USERS_CHANGE_REQUEST_FAILURE';
 
 export const PASSWORD_CHANGE_REQUEST = 'PASSWORD_CHANGE_REQUEST';
 export const PASSWORD_CHANGE_REQUEST_SUCCESS = 'PASSWORD_CHANGE_REQUEST_SUCCESS';
-export const PASSWORD_CHANGE_REQUEST_FAILURE = 'PASSWORD_CHANGE_REQUEST_FAILURE';
+export const PASSWORD_CHANGE_REQUEST_FAILURE = 'PASSWORD_CHANGE_REQUEST_FAILURE';
+
+export const GET_CARDS_URL = 'https://quiz.maxcrc.de/api/v1/quiz';
+
+export const GET_CARDS = 'GET_CARD';
+export const GET_CARDS_SUCCESS = 'GET_CARDS_SUCCESS';
+export const GET_CARDS_FAILURE = 'GET_CARDS_FAILURE';

+ 35 - 0
src/reducers/cards/index.js

@@ -0,0 +1,35 @@
+import * as actionTypes from './../../constants';
+import initialState from './../initialState';
+
+export default function cards(state = initialState.cards, { type, payload: data, error }) {
+    switch (type) {
+        case actionTypes.GET_CARDS: {
+            return {
+                ...state,
+                isFetching: true,
+                data: null,
+                error: null
+            }
+        }
+        case actionTypes.GET_CARDS_SUCCESS: {
+            return {
+                ...state,
+                isFetching: false,
+                data,
+                error: null
+            }
+        }
+        case actionTypes.GET_CARDS_FAILURE: {
+            return {
+                ...state,
+                isFetching: false,
+                data: null,
+                error
+            }
+        }
+        default: {
+            return state
+        }
+    }
+
+}

+ 3 - 3
src/reducers/index.js

@@ -2,11 +2,10 @@
 // для создания store 
 import { combineReducers } from 'redux';
 
-
 import user from './user';
-
 import changeEmail from './userFields/changeEmail/index';
 import changePassword from './userFields/changePassword/index'
+import cards from './cards';
 
 import { reducer as form } from 'redux-form';
 
@@ -16,7 +15,8 @@ const combinedReducers = combineReducers({
     form,
     user,
     changeEmail,
-    changePassword
+    changePassword,
+    cards
 })
 
 export default combinedReducers;

+ 8 - 5
src/reducers/initialState/index.js

@@ -2,14 +2,17 @@ export default {
     user: {       
         data: null,
         error: null,
-        isFetching: null,
-        isAdmin: null
     },
     changeEmail: {
         login: null
-    },
-    
+    },  
     changePassword: {
-        password: null
+        password: null,
+        isFetching: null
+    },
+    cards: {
+        data: null,
+        error: null,
+        isFetching: null
     }
 }

+ 4 - 8
src/router.js

@@ -15,8 +15,6 @@ import config from './components/common/protectedRoute/config';
 import fakeToken from './utils/token'
 import { bindActionCreators } from "redux";
 
-const notFound = lazy(() => import('./components/public-components/notFound'));
-
 class Router extends React.Component {
 
     componentDidMount() {
@@ -29,10 +27,9 @@ class Router extends React.Component {
 
     render() {
         const { user } = this.props;
-
+        
         //map located here because of switch-bag
-
-        const protectedRoutes = config.map(route =>
+        const Router = config.map(route =>
             <ProtectedRoute
                 path={route.path}
                 component={route.component}
@@ -40,15 +37,14 @@ class Router extends React.Component {
                 user={user}
                 exact
             />
-        );
+        )
 
         return (
             <div className="app">
                 <Header />
                 <Suspense fallback={<Spinner />}>
                     <Switch>
-                        {protectedRoutes}
-                        <Route component={notFound} />
+                        {Router}
                     </Switch>
                 </Suspense>
                 <Footer />

+ 13 - 15
src/saga/auth/signIn/index.js

@@ -7,20 +7,18 @@ import token from '../../../utils/token'
 // worker-saga for signing in
 
 export default function* ({ payload: { login, password } }) {
-    try {
-        const payload = yield call(() =>
-            axios.get(`${SIGN_IN_URL}login=${login}&password=${password}`)
-                .then(({ data: [payload] }) => payload)
-        );
+  try {
+    const payload = yield call(() =>
+      axios.get(`${SIGN_IN_URL}login=${login}&password=${password}`)
+        .then(({ data: [payload] }) => payload)
+    );
 
-        yield call(() => { if (!payload) throw (new Error("No such email or password")) })
-
-        yield put(actions.signInRequestSucces(payload));
-        yield call(() => localStorage.setItem(token, JSON.stringify(payload)));
-    }
-    catch ({ message }) {
-        yield put(actions.signInRequestFailure(message))
-        yield call(() => localStorage.removeItem(token));
-
-    }
+    yield call(() => { if (!payload) throw (new Error("No such email or password")) });
+    yield put(actions.signInRequestSucces(payload));
+    yield call(() => localStorage.setItem(token, JSON.stringify(payload)));
+  }
+  catch ({ message }) {
+    yield put(actions.signInRequestFailure(message));
+    yield call(() => localStorage.removeItem(token));
+  }
 }

+ 21 - 0
src/saga/cards/getCards/index.js

@@ -0,0 +1,21 @@
+import { put, call } from "redux-saga/effects";
+import * as actions from '../../../actions/cards';
+import axios from 'axios';
+
+import { GET_CARDS_URL } from './../../../constants/index'
+
+// worker-saga for getting cards
+
+export default function* () {
+    try {
+        const payload = yield call(() =>
+            axios.get(GET_CARDS_URL)
+                .then(({ data }) => data)
+        );
+
+        yield put(actions.getCardsSuccess(payload));
+    }
+    catch ({ message }) {
+        yield put(actions.getCardsFailure(message))
+    }
+}

+ 8 - 0
src/saga/cards/index.js

@@ -0,0 +1,8 @@
+import { takeEvery } from "redux-saga/effects";
+
+import getCards from './getCards';
+import { GET_CARDS } from "./../../constants"
+
+export default function*() {
+    yield takeEvery(GET_CARDS, getCards);
+}

+ 3 - 4
src/saga/index.js

@@ -1,13 +1,12 @@
 import { fork } from "redux-saga/effects";
 import auth from './auth'
 import userFields from './userFields/index';
-import changePassworde from './userFields/index'
-
+import cards from './cards';
 
 export default function*() {
     yield [
         fork(auth),
         fork(userFields),
-        fork(changePassworde)
-    ];
+        fork(cards)
+    ]
 }

+ 4 - 4
src/saga/userFields/changeEmail/index.js

@@ -3,14 +3,14 @@ import * as actions from './../../../actions/userFields/changeEmail'
 import axios from 'axios';
 import { USERS_CHANGE_URL } from '../../../constants/index'
 
-export default function* ({payload}) {
+export default function* ({payload:{id, login}}) {
     try {
-        console.log("payload inside the saga", payload);
+        console.log("payload inside the saga", id);
         const payloads = yield call(() =>
-            axios.put(`${USERS_CHANGE_URL}${payload.id}`, payload.login)
+            axios.put(`${USERS_CHANGE_URL}${id}`, {body:{login}})
                 .then(({ data }) => data)
         );
-        yield put(actions.userChangeRequestSucces(payload));
+        yield put(actions.userChangeRequestSucces(payloads));
     }
     catch ({ message }) {
         yield put(actions.userChangeRequestFailure(message))

+ 8 - 4
src/saga/userFields/changePassword/index.js

@@ -3,12 +3,16 @@ import * as actions from './../../../actions/userFields/changePassword'
 import axios from 'axios';
 import { USERS_CHANGE_URL } from '../../../constants/index'
 
-export default function* ({payload}) {
+export default function* ({payload:{id , password}}) {
     try {
-        console.log("payload inside the saga", payload);
+        console.log("payload inside the saga", password);
         const payloads = yield call(() =>
-            axios.put(`${USERS_CHANGE_URL}${payload.id}`, payload.password)
-                .then(({ data }) => data)
+            fetch(`${USERS_CHANGE_URL}${id}`, {
+            method:"PUT",
+            body:JSON.stringify({password})
+            }
+            )
+                .then(({ data }) => data.json)
         );
         yield put(actions.passwordChangeRequestSucces(payloads));
     }

+ 18 - 0
src/saga/userFields/createDeleteUser/index.js

@@ -0,0 +1,18 @@
+import { put, call } from "redux-saga/effects";
+import * as actions from './../../../actions/adminActions/index'
+import axios from 'axios';
+import { SIGN_UP_URL } from '../../../constants/index'
+
+export default function* (payload) {
+    try {
+        console.log("payload inside the saga", payload);
+        const payloads = yield call(() =>
+            axios.get(SIGN_UP_URL)
+                .then(({ data }) => data)
+        );
+        yield put(actions.userGetRequestSucces(payloads));
+    }
+    catch ({ message }) {
+        yield put(actions.userGetRequestFailure(message))
+    }
+}