6 Achegas e260885cf2 ... d762e9c20f

Autor SHA1 Mensaxe Data
  Maxim d762e9c20f Merged Sveta -> Maxim %!s(int64=6) %!d(string=hai) anos
  Maxim 5fde374c12 Merge branch 'Maxim' into dev %!s(int64=6) %!d(string=hai) anos
  Maxim ec1882a312 auto-auth is done -> logic is moved into router, algo optimised %!s(int64=6) %!d(string=hai) anos
  Maxim d22fac4a37 layout changes -> fixed animation bugs && mobile views %!s(int64=6) %!d(string=hai) anos
  sveta a9775a9cc4 get, delete users %!s(int64=6) %!d(string=hai) anos
  = a2c35db19b page reload redirect fixed via router tocken auth replacement %!s(int64=6) %!d(string=hai) anos
Modificáronse 34 ficheiros con 407 adicións e 173 borrados
  1. 16 0
      src/actions/adminActions/deleteUser/index.js
  2. 5 5
      src/actions/adminActions/index.js
  3. 4 6
      src/actions/auth/users/users.js
  4. 1 2
      src/actions/auth/index.js
  5. 0 34
      src/components/common/input-form.js
  6. 6 0
      src/components/common/protectedRoute/config.js
  7. 27 10
      src/components/common/protectedRoute/index.js
  8. 0 6
      src/components/common/protectedRoute/validate/index.js
  9. 3 0
      src/components/public-components/auth/signUpForm/index.js
  10. 24 22
      src/components/public-components/header/index.js
  11. 43 0
      src/components/user-components/admin-components/createDeleteUser/deleteUser/index.js
  12. 61 0
      src/components/user-components/admin-components/createDeleteUser/formGetUsers/index.js
  13. 36 12
      src/components/user-components/admin-components/createDeleteUser/index.js
  14. 1 1
      src/components/user-components/profilePage/LoginFild/index.js
  15. 5 4
      src/components/user-components/profilePage/index.js
  16. 10 1
      src/constants/index.js
  17. 30 0
      src/reducers/getUser/index.js
  18. 5 1
      src/reducers/index.js
  19. 10 0
      src/reducers/initialState/index.js
  20. 30 0
      src/reducers/users/index.js
  21. 12 22
      src/router.js
  22. 1 2
      src/saga/auth/index.js
  23. 13 13
      src/saga/auth/signIn/index.js
  24. 0 19
      src/saga/auth/users/users.js
  25. 18 0
      src/saga/userFields/deleteUser/index.js
  26. 18 0
      src/saga/userFields/getUser/index.js
  27. 4 4
      src/saga/userFields/createDeleteUser/index.js
  28. 7 2
      src/saga/userFields/index.js
  29. 1 1
      src/state/index.js
  30. 1 0
      src/styles/components/_button.scss
  31. 2 2
      src/styles/components/_header.scss
  32. 8 3
      src/styles/components/_landingPage.scss
  33. 4 0
      src/styles/components/_profilePage.scss
  34. 1 1
      src/styles/components/_signPage.scss

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

@@ -0,0 +1,16 @@
+import * as types from '../../../constants';
+
+export const deleteUserRequest = payload => ({
+    type: types.DELETE_USER_REQUEST,
+    payload
+})
+
+export const deleteUserRequestSucces = payload => ({
+    type: types.DELETE_USER_REQUEST_SUCCESS,
+    payload
+})
+
+export const deleteUserRequestFailure = error => ({
+    type: types.DELETE_USER_REQUEST_FAILURE,
+    error
+})

+ 5 - 5
src/actions/adminActions/index.js

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

+ 4 - 6
src/actions/auth/users/users.js

@@ -1,10 +1,7 @@
 import * as types from '../../../constants';
 
-// all actions for signing up
-
-export const usersGetRequest= payload => ({
+export const usersGetRequest = () => ({
     type: types.USERS_GET_REQUEST,
-    payload
 })
 
 export const usersGetRequestSucces = payload => ({
@@ -13,6 +10,7 @@ export const usersGetRequestSucces = payload => ({
 })
 
 export const usersGetRequestFailure = error => ({
-    type: types.USERS_GET_REQUEST_SUCCESS_FAILURE ,
+    type: types.USERS_GET_REQUEST_FAILURE,
     error
-})
+})
+

+ 1 - 2
src/actions/auth/index.js

@@ -1,11 +1,10 @@
 import * as signInActions from './signIn';
 import * as signUpActions from './signUp';
 import * as signOutActions from './signOut';
-import * as usersGetActions from './signOut';
+
 
 export default {
     ...signInActions,
     ...signUpActions,
     ...signOutActions,
-    ...usersGetActions
 }

+ 0 - 34
src/components/common/input-form.js

@@ -1,34 +0,0 @@
-import React, { Component } from "react";
-import { connect } from "react-redux";
-import { reduxForm, Field, FieldArray } from "redux-form";
-
-const renderField = ({ input, meta: { touched, error }, label, type }) => (
-	<div className="form__input-box">
-		<label className="form__input-lable" htmlFor="origin">
-			{label}
-			<input type={type} {...input} />
-		</label>
-		{touched && error && <span>{error}</span>}
-	</div>
-);
-
-class LoadForm extends Component {
-	
-	render() {
-		const { handleSubmit, title, pristine, submitting } = this.props;
-
-		return (
-			<form onSubmit={handleSubmit(this.submit)} className="form">
-				
-			</form>
-		);
-	}
-}
-
-const mapStateToProps = (state, props) => ({
-});
-
-const component = reduxForm({ })(LoadForm);
-
-export default connect(mapStateToProps)(component);
-

+ 6 - 0
src/components/common/protectedRoute/config.js

@@ -2,6 +2,7 @@ import React from 'react';
 import * as routes from './../../../constants/routes';
 import { lazy } from 'react';
 
+const DeleteUsers = lazy(()=>import('../../user-components/admin-components/createDeleteUser/index'))
 const LandingPage =    lazy(() => import('./../../public-components/landingPage'));
 const HomePage =       lazy(() => import('./../../user-components/homePage'));
 const SignInPage =     lazy(() => import('./../../../containers/auth/SignInPage'));
@@ -48,6 +49,11 @@ export default [
         access: 'user-only',
         component: CardsPage
     },
+    {
+        path: routes.DELETE_USER ,
+        access: 'admin-only',
+        component: DeleteUsers
+    },
     {
         access: 'public',
         component: NotFound

+ 27 - 10
src/components/common/protectedRoute/index.js

@@ -1,34 +1,51 @@
 import React from 'react';
 import { Route, Redirect } from 'react-router-dom';
 
+import token from '../../../utils/token'
+
 import * as routes from './../../../constants/routes';
 import PermissionDenied from './../../public-components/permissionDenied';
 
-export default ({ component: Component, user: {data}, access, ...rest  }) => (
+export default ({ component: Component, user: { data }, tokenAuth, access, ...rest }) => (
     <Route
         {...rest}
         render={props => {
+            let checkedData;
+
+            if (data) {
+                checkedData = data;
+            }
+            else {
+                const storagedUser = JSON.parse(localStorage.getItem(token));
+                if (storagedUser) {
+                    checkedData = storagedUser;
+                    tokenAuth(storagedUser);
+                } 
+                else {
+                    checkedData = null;
+                }
+            }
 
             if (access === 'public') {
                 return <Component {...props} />
             }
-            
-            if ( (access === 'user-only' || access === 'admin-only') && !data ) {
-                return <Redirect to={routes.SIGN_IN}/>
+
+            if ((access === 'user-only' || access === 'admin-only') && !checkedData) {
+                return <Redirect to={routes.SIGN_IN} />
             }
-            
-            if (access === 'user-only' && data) {
+
+            if (access === 'user-only' && checkedData) {
                 return <Component {...props} />
-            }        
+            }
 
             if (access === 'admin-only') {
-                if (data.is_admin) {
+                if (checkedData.is_admin) {
                     return <Component {...props} />
-                } 
+                }
 
                 return <PermissionDenied />
             }
-            
+
         }}
     />
 )

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

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

+ 3 - 0
src/components/public-components/auth/signUpForm/index.js

@@ -30,6 +30,9 @@ class Form extends React.Component {
                 </div>
 
                 <button className="sign-form__link--with-margin link--btn link--btn6s0" disabled={invalid}>Create Account</button>
+
+                <hr className="sign-form__divider" />
+
                 <p className="sign-form__agreement">By clicking this button you actually would donate us your flat !</p>
             </form>
         )

+ 24 - 22
src/components/public-components/header/index.js

@@ -2,13 +2,16 @@ import React, { Component } from 'react';
 import { Link } from "react-router-dom";
 
 import * as routes from './../../../constants/routes';
-import { UserContext } from './../../../containers/header';
 import token from './../../../utils/token';
 
 export default class header extends Component {
 
     state = {
-        togglerClosed: true,
+        togglerClosed: true
+    }
+
+    handleClick = () => {
+        this.setState({ togglerClosed: true })
     }
 
     handleToggle = event => {
@@ -28,54 +31,53 @@ export default class header extends Component {
 
         return (
             <header className="header">
-                <Link to={routes.LANDING}>
+                <Link onClick={this.handleClick} to={routes.LANDING}>
                     <h1 className="header__logo">Test.<span className="header__logo--i-letter">i</span>o</h1>
                 </Link>
                 <hr className="header__logo--divider" />
-                {/* <span className="header__toggle-trigger" onClick={this.handleToggle} >
+                <span className="header__toggle-trigger" onClick={this.handleToggle} >
                     <span />
-                </span> */}
-                <button style={{ position: "absolute", top: '85px', left: 0 }} onClick={this.handleToggle}>HEADER TOGGLE</button>
+                </span>
                 <div className="header__flex-wrapper">
                     <nav className={`header__nav ${toggleStatus}`}>
                         <ul className="header__nav nav__list"  >
                             <li>
-                                <Link className="header__nav nav__list-item" to={routes.HOME}>
+                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.HOME}>
                                     Home
-                </Link>
+                                </Link>
                             </li>
                             <li>
-                                <Link className="header__nav nav__list-item" to={routes.PROFILE}>
+                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.PROFILE}>
                                     Profile
-                </Link>
+                                </Link>
                             </li>
                             <li>
-                                <Link className="header__nav nav__list-item" to={routes.TESTS}>
+                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.TESTS}>
                                     Test
-                </Link>
+                                </Link>
                             </li>
                             <li>
-                                <Link className="header__nav nav__list-item" to={routes.CATEGORIES}>
+                                <Link onClick={this.handleClick} className="header__nav nav__list-item" to={routes.CATEGORIES}>
                                     Categories
-                </Link>
+                                </Link>
                             </li>
                             {
                                 data && data.is_admin && (
                                     <React.Fragment>
                                         <li>
-                                            <Link className="header__nav nav__list-item--admin-only" to={routes.CREATE_TEST}>
+                                            <Link onClick={this.handleClick} 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}>
+                                            <Link onClick={this.handleClick} 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}>
+                                            <Link onClick={this.handleClick} className="header__nav nav__list-item--admin-only" to={routes.DELETE_USER}>
                                                 Delete data
-                            </Link>
+                                            </Link>
                                         </li>
                                     </React.Fragment>
                                 )
@@ -88,8 +90,8 @@ export default class header extends Component {
                             !data
                                 ? (
                                     <React.Fragment>
-                                        <Link className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
-                                        <Link className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
+                                        <Link onClick={this.handleClick} className="header__links--sign-in link--btn link--btn25" to={routes.SIGN_IN}>Sign in</Link>
+                                        <Link onClick={this.handleClick} className="header__links--sign-up link--btn link--btn25" to={routes.SIGN_UP}>Sign up</Link>
                                     </React.Fragment>
                                 )
                                 : (

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

@@ -0,0 +1,43 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { Field, reduxForm } from 'redux-form';
+import { bindActionCreators } from 'redux'
+
+import formInput from '../../../../common/formInput/index';
+import {userGetRequest} from '../../../../../actions/adminActions/getUser';
+import {deleteUserRequest} from '../../../../../actions/adminActions/deleteUser'
+
+
+
+class DeleteUser extends React.Component {
+    onClick =() =>{
+        const { deleteUserRequest, data:{login}} = this.props;
+        console.log(login)
+        deleteUserRequest({
+            login
+        })
+    }
+
+    // handleClick = () => {
+    //     this.setState((prevState) => ({ clicked: !prevState.clicked }));
+    // }
+    render() {
+    const {data} =this.props
+    console.log(data)
+        return (<div>
+                    {data.login}
+                <button onClick ={this.onClick}>
+                    Delete
+                    </button>
+        </div>
+        )
+    }
+}
+
+
+
+
+const mapDispatchToProps = dispatch => bindActionCreators({ deleteUserRequest }, dispatch);
+
+
+export default connect( null,mapDispatchToProps)(DeleteUser)

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

@@ -0,0 +1,61 @@
+import React from 'react';
+import { connect } from 'react-redux';
+import { Field, reduxForm } from 'redux-form';
+import { bindActionCreators } from 'redux'
+
+import formInput from '../../../../common/formInput/index';
+import {userGetRequest} from '../../../../../actions/adminActions/getUser'
+import DeleteUser from '../deleteUser/index'
+
+
+
+class FormGetUsers extends React.Component {
+    submit = ({ login}) => {
+        console.log('handleSubmit->submit', this.props)
+        const { userGetRequest }  = this.props;
+
+        console.log('hghjgjhg',login);
+
+        userGetRequest({
+            login
+        })
+    }
+
+    // handleClick = () => {
+    //     this.setState((prevState) => ({ clicked: !prevState.clicked }));
+    // }
+    render() {
+        const { handleSubmit, getUser:{data} } = this.props
+        const {submit} =this
+        console.log(data)
+        return (<div>
+            <form className="page" onSubmit = {handleSubmit(submit)}>
+                <Field name="login" type="email" placeholder="Enter new login" component={formInput} />
+                <button >Search</button>
+            </form >
+            {
+                data !== null?
+                       ( <div>
+                <DeleteUser data ={data}></DeleteUser>
+                        </div>
+                       ):
+                       <div>dddd</div>
+            }
+        </div>
+        )
+    }
+}
+
+const
+    mapStateToProps = state => ({
+        users: state.users,
+        getUser:state.getUser
+    });
+
+
+const mapDispatchToProps = dispatch => bindActionCreators({userGetRequest }, dispatch);
+
+
+export default connect(mapStateToProps, mapDispatchToProps)(reduxForm({
+    form: "FormGetUsers",
+})(FormGetUsers))

+ 36 - 12
src/components/user-components/admin-components/createDeleteUser/index.js

@@ -1,29 +1,53 @@
 import React from 'react';
 import { connect } from 'react-redux';
 import { Field, reduxForm } from 'redux-form';
+import { bindActionCreators } from 'redux'
 
 import formInput from '../../..//common/formInput';
- submit=()=>{
-     
- }
+import { usersGetRequest } from '../../../../actions/adminActions/getUsers/index'
+import FormGetUsers from './formGetUsers/index'
 
-class createDeleteUser extends React.Component {
 
+class createDeleteUser extends React.Component {
+    componentDidMount() {
+        const { usersGetRequest } = this.props;
+        usersGetRequest();
+    }
     render() {
-        const {  handleSubmit  } = this.props;
+        const { handleSubmit, users:{data} } = this.props;
+        console.log(data)
         return (
-            <form  className="page">
-                <Field name="login"  type="email" placeholder="Enter new login" component={formInput} />
-                <button >Search</button>
-            </form >
+            <div className="page page--bottom-only profile-page">
+                <section className="container section section--about">
+            <FormGetUsers></FormGetUsers>
+        </section>
+        <section className="container section section--about">
+            {data&&data.map(str=>
+            <div className="container section section--about">
+            <ul >
+                <h5>LOGIN</h5>
+                {str.login}
+                </ul>
+            <ul >
+                <h5>PASSWORD</h5>
+            {str.password}
+                </ul>
+                </div>)}
+            </section>
+        </div>
         )
     }
 }
 
+const
+    mapStateToProps = state => ({
+        users: state.users
+    });
+
 
-const mapDispatchToProps = dispatch => bindActionCreators({ userGetRequest }, dispatch);
+const mapDispatchToProps = dispatch => bindActionCreators({ usersGetRequest }, dispatch);
 
 
-export default connect(mapDispatchToProps)(reduxForm({
-    form: "createDeleteUser",   
+export default connect(mapStateToProps, mapDispatchToProps)(reduxForm({
+    form: "createDeleteUser",
 })(createDeleteUser))

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

@@ -37,7 +37,7 @@ export default class ChangeLogin extends React.Component {
                 ?
                 (
                     <React.Fragment>
-                        <div>{children}</div>
+                        <div >{children}</div>
                         <button className="link link--btn right"onClick={handleClick}>Change Email</button>
                     </React.Fragment>
                 )

+ 5 - 4
src/components/user-components/profilePage/index.js

@@ -49,9 +49,9 @@ class profilePage extends React.Component {
 
 
     render() {
-        const { user:{data}, userChangeRequest,passwordChangeRequest } = this.props;
+        const { user:{data},users, userChangeRequest,passwordChangeRequest } = this.props;
 
-        // console.log('User', user);
+        console.log('User', users);
         // console.log('Props', this.props);
         // console.log('State', this.state);
 
@@ -59,7 +59,7 @@ class profilePage extends React.Component {
             <div className="page page--bottom-only profile-page">
                 <section className="container section section--about">
                     {/* <h2 className="section__element section__element--header">{data.login}</h2> */}
-        
+
                     <div className="sedtion__element section__element--login">
                         <h3>Email</h3>
                         {/* <p>{user.login}<button className="link link--btn right" >Change login</button></p> */}
@@ -102,7 +102,8 @@ class profilePage extends React.Component {
 
 const
     mapStateToProps = state => ({
-        user: state.user
+        user: state.user,
+        users:state.users
     });
 
 const mapDispatchToProps = dispatch => bindActionCreators({ userChangeRequest, passwordChangeRequest }, dispatch);

+ 10 - 1
src/constants/index.js

@@ -15,7 +15,7 @@ export const SIGN_OUT = 'SIGN_OUT';
 
 export const USERS_GET_REQUEST = 'USERS_GET_REQUEST';
 export const USERS_GET_REQUEST_SUCCESS = 'USERS_GET_REQUEST_SUCCESS';
-export const USERS_GET_REQUEST_SUCCESS_FAILURE = 'USERS_GET_REQUEST_FAILURE';
+export const USERS_GET_REQUEST_FAILURE = 'USERS_GET_REQUEST_FAILURE';
 
 export const TOKEN_AUTH = 'TOKEN_AUTH';
 
@@ -33,3 +33,12 @@ 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';
+
+export const USER_GET ='http://quiz.maxcrc.de/api/v1/user?'
+export const USER_GET_REQUEST = 'USER_GET_REQUEST';
+export const USER_GET_REQUEST_SUCCESS = 'USER_GET_REQUEST_SUCCESS';
+export const USER_GET_REQUEST_FAILURE = 'USER_GET_REQUEST_FAILURE';
+
+export const DELETE_USER_REQUEST = 'DELETE_USER_REQUEST';
+export const DELETE_USER_REQUEST_SUCCESS = 'DELETE_USER_REQUEST_SUCCESS';
+export const DELETE_USER_REQUEST_FAILURE = 'DELETE_USER_REQUEST_FAILURE';

+ 30 - 0
src/reducers/getUser/index.js

@@ -0,0 +1,30 @@
+import * as types from "../../constants/index";
+import initialState from '../initialState';
+
+export default function getUser(state = initialState.getUser, {type, payload: data, error }) {
+    switch (type) {
+        case types.USER_GET_REQUEST: {
+            return {
+                ...state,
+                isFetching: true
+            }
+        }
+        case types.USER_GET_REQUEST_SUCCESS: {
+            return {
+                ...state,
+                isFetching: false,
+                data
+            }
+        }
+        case types.USER_GET_REQUEST_FAILURE: {
+            return {
+                ...state,
+                isFetching: false,
+                error
+            }
+        }
+        default: {
+            return state
+        }
+    }
+}

+ 5 - 1
src/reducers/index.js

@@ -6,6 +6,8 @@ import user from './user';
 import changeEmail from './userFields/changeEmail/index';
 import changePassword from './userFields/changePassword/index'
 import cards from './cards';
+import users from './users'
+import getUser from './getUser'
 
 import { reducer as form } from 'redux-form';
 
@@ -16,7 +18,9 @@ const combinedReducers = combineReducers({
     user,
     changeEmail,
     changePassword,
-    cards
+    cards,
+    users,
+    getUser
 })
 
 export default combinedReducers;

+ 10 - 0
src/reducers/initialState/index.js

@@ -14,5 +14,15 @@ export default {
         data: null,
         error: null,
         isFetching: null
+    },
+    users: {
+        data: null,
+        error: null,
+        isFetching: null
+    },
+    getUser:{
+        data:null,
+        error: null,
+        isFetching: null
     }
 }

+ 30 - 0
src/reducers/users/index.js

@@ -0,0 +1,30 @@
+import * as types from "../../constants/index";
+import initialState from '../initialState';
+
+export default function getUsers(state = initialState.users, {type, payload: data, error }) {
+    switch (type) {
+        case types.USERS_GET_REQUEST: {
+            return {
+                ...state,
+                isFetching: true
+            }
+        }
+        case types.USERS_GET_REQUEST_SUCCESS: {
+            return {
+                ...state,
+                isFetching: false,
+                data
+            }
+        }
+        case types.USERS_GET_REQUEST_FAILURE: {
+            return {
+                ...state,
+                isFetching: false,
+                error
+            }
+        }
+        default: {
+            return state
+        }
+    }
+}

+ 12 - 22
src/router.js

@@ -16,35 +16,25 @@ import fakeToken from './utils/token'
 import { bindActionCreators } from "redux";
 
 class Router extends React.Component {
-
-    componentDidMount() {
-        const storagedUser = localStorage.getItem(fakeToken);
-        const { tokenAuth } = this.props;
-
-
-        storagedUser && tokenAuth(JSON.parse(storagedUser));
-    }
-
     render() {
-        const { user } = this.props;
-        
-        //map located here because of switch-bag
-        const Router = config.map(route =>
-            <ProtectedRoute
-                path={route.path}
-                component={route.component}
-                access={route.access}
-                user={user}
-                exact
-            />
-        )
+        const { user, tokenAuth } = this.props;
 
         return (
             <div className="app">
                 <Header />
                 <Suspense fallback={<Spinner />}>
                     <Switch>
-                        {Router}
+                        {config.map(route =>
+                            <ProtectedRoute
+                                path={route.path}
+                                component={route.component}
+                                access={route.access}
+                                user={user}
+                                key={route}
+                                tokenAuth={tokenAuth}
+                                exact
+                            />
+                        )}
                     </Switch>
                 </Suspense>
                 <Footer />

+ 1 - 2
src/saga/auth/index.js

@@ -3,12 +3,11 @@ import * as types from "./../../constants"
 
 import signIn from './signIn';
 import signUp from './signUp';
-import getUsers from './users/users';
+
 
 export default function*() {
     yield takeEvery(types.SIGN_IN_REQUEST, signIn);
     yield takeEvery(types.SIGN_UP_REQUEST, signUp);
-    yield takeEvery(types.USERS_GET_REQUEST, getUsers);
 }
 
 

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

@@ -7,18 +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));
+    }
 }

+ 0 - 19
src/saga/auth/users/users.js

@@ -1,19 +0,0 @@
-import { put, call } from "redux-saga/effects";
-import * as actions from './../../../actions/auth/users/users'
-import axios from 'axios';
-
-
-
-export default function* ({ payload: requestBody }) {
-    try {
-        const payload = yield call(() =>
-            axios.get(`https://quiz.maxcrc.de/api/v1/user`)
-                .then(({ data }) => data)
-        );
-        
-        yield put(actions.usersGetRequestSucces(payload));
-    }
-    catch ({ message }) {
-        yield put(actions.usersGetRequestFailure(message))
-    }
-}

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

@@ -0,0 +1,18 @@
+import { put, call } from "redux-saga/effects";
+import * as actions from './../../../actions/adminActions/deleteUser'
+import axios from 'axios';
+import { USER_GET } from '../../../constants/index'
+
+export default function* ({payload:{login}}) {
+    try {
+        console.log("payload inside the saga", login);
+        const payloads = yield call(() =>
+            axios.delete(`${USER_GET}login=${login}`)
+                .then((data) => data)
+        );
+        yield put(actions.deleteUserRequestSucces(payloads));
+    }
+    catch ({ message }) {
+        yield put(actions.deleteUserRequestFailure(message))
+    }
+}

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

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

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

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

+ 7 - 2
src/saga/userFields/index.js

@@ -3,9 +3,14 @@ import * as types from "./../../constants"
 
 import changeEmail from './changeEmail/index';
 import changePassword from "./changePassword";
-
+import getUsers from './getUsers'
+import getUser from './getUser'
+import deleteUser from './deleteUser'
 
 export default function*() {
     yield takeEvery(types.USERS_CHANGE_REQUEST, changeEmail);
-    yield takeEvery(types.PASSWORD_CHANGE_REQUEST, changePassword)
+    yield takeEvery(types.PASSWORD_CHANGE_REQUEST, changePassword);
+    yield takeEvery(types.USERS_GET_REQUEST, getUsers);
+    yield takeEvery(types.USER_GET_REQUEST, getUser);
+    yield takeEvery(types.DELETE_USER_REQUEST, deleteUser);
 }

+ 1 - 1
src/state/index.js

@@ -14,7 +14,7 @@ const logger = createLogger({
 const store = createStore(
     combinedReducers,
     initialState,
-    applyMiddleware(sagaMiddleware)
+    applyMiddleware(sagaMiddleware, logger)
 );
 export default store;
 

+ 1 - 0
src/styles/components/_button.scss

@@ -1,5 +1,6 @@
 .link {
     &--btn {
+        display: inline-block !important;
         text-transform: uppercase;
         font-family: 'Poiret One', cursive;
         font-weight: bold;

+ 2 - 2
src/styles/components/_header.scss

@@ -76,7 +76,7 @@
         }
         &__toggle-trigger {
             position: absolute;
-            top: 70%;
+            top: 65%;
             cursor: pointer;
             left: 0;
             margin-left: 1em;
@@ -145,12 +145,12 @@
         .header__links {
             display: flex;
             justify-content: center;
-
             &--sign-in {
                 margin-right: 1.5vw;
             }
             &--sign-up {
                 margin-left: 1.5vw;
+                margin-right: 0;
             }
         }
     }

+ 8 - 3
src/styles/components/_landingPage.scss

@@ -32,22 +32,27 @@
         justify-content: space-between;
         width: 25%;
         padding: 9vh;
+        @media screen and (max-width: 1125px) {
+            padding: 4vh 7vh;
+        }
     }
     // not correct spelling -> have to ask && change
     &__links {
         border: none;
         box-shadow: 0 0 10px grey;
         background: rgba(232,230, 230, 0.9);
-        padding: 3vh 0;
-        margin: 5px;
         text-transform: uppercase;
+        margin: 5px;
+        padding: 3vh 0;
         font-family: 'Cormorant Infant', serif;
         font-weight: bold;
         font-size: 16px;
         text-align: center;
         width: 20vh;
-            @media screen and (max-width: 1125px) {
+        @media screen and (max-width: 1125px) {
                 width: 100%;
+                margin: 10px 0;
+                padding: 2.5vh 0;
             }
         transition: all 0.6s ease-in-out;
     }

+ 4 - 0
src/styles/components/_profilePage.scss

@@ -8,6 +8,10 @@
         flex-basis: 400px;
         margin: 10px;
         padding: 10px;
+
+        h3{
+            margin: 25px 0
+        }
         &__element {
             &--image {
                 border: 3px solid $color-lightsteelblue;

+ 1 - 1
src/styles/components/_signPage.scss

@@ -22,7 +22,7 @@
             margin: 0 0 35px 0;
         }
         &__password-container {
-            margin: 50px 0;
+            margin: 50px 0 20px 0;
         }
         &__input {
             display: block;