sveta 5 rokov pred
rodič
commit
7925d5eb61
66 zmenil súbory, kde vykonal 630 pridanie a 357 odobranie
  1. 0 1
      src/actions/admin/category/createCategory.js
  2. 0 1
      src/actions/admin/changeTest/changeTest.js
  3. 0 1
      src/actions/admin/changeTest/deleteAnswer.js
  4. 0 1
      src/actions/admin/changeTest/deleteQuestion.js
  5. 0 1
      src/actions/admin/changeTest/deleteTopic.js
  6. 0 1
      src/actions/admin/changeTest/getAnswers.js
  7. 0 1
      src/actions/admin/changeTest/getQuestions.js
  8. 0 1
      src/actions/admin/changeTest/getTopic.js
  9. 0 1
      src/actions/user/changeEmail.js
  10. 0 1
      src/actions/user/changePassword.js
  11. 0 1
      src/actions/user/changelogin.js
  12. 17 0
      src/actions/user/test/checkTest.js
  13. 0 1
      src/actions/user/test/getTopics.js
  14. 17 0
      src/actions/user/test/nextTest.js
  15. 0 1
      src/actions/user/test/testStart.js
  16. 1 1
      src/components/admin/CreateTest/CreateTopic.js
  17. 1 1
      src/components/admin/CreateTest/index.js
  18. 10 7
      src/components/admin/addDeleteCategory/ChangeCategory.js
  19. 2 3
      src/components/admin/addDeleteCategory/CreateCategoryForm/index.js
  20. 1 1
      src/components/admin/addDeleteCategory/DeleteCategory.js
  21. 9 23
      src/components/admin/addDeleteCategory/GetCategory.js
  22. 0 2
      src/components/admin/addDeleteCategory/index.js
  23. 1 7
      src/components/admin/deleteUser/GetUsers.js
  24. 2 6
      src/components/admin/deleteUser/changeUsers.js
  25. 12 15
      src/components/admin/deleteUser/index.js
  26. 0 21
      src/components/admin/getChangeDeleteTest/ChangeQestion.js
  27. 1 8
      src/components/admin/getChangeDeleteTest/GetQuestions.js
  28. 2 41
      src/components/admin/getChangeDeleteTest/GetTest.js
  29. 18 37
      src/components/admin/getChangeDeleteTest/GetTopic.js
  30. 19 42
      src/components/admin/getChangeDeleteTest/OpenModal.js
  31. 112 0
      src/components/admin/getChangeDeleteTest/changeQuestions.js
  32. 8 21
      src/components/admin/getChangeDeleteTest/index.js
  33. 1 1
      src/components/common/formInput.js
  34. 7 8
      src/components/public/Header.js
  35. 63 0
      src/components/user/Categoty.js
  36. 0 2
      src/components/user/ProfilePage/ChangeEmailForm/index.js
  37. 0 2
      src/components/user/ProfilePage/ChangeLoginForm/index.js
  38. 0 2
      src/components/user/ProfilePage/changePassword/index.js
  39. 1 3
      src/components/user/ProfilePage/index.js
  40. 25 0
      src/components/user/Test/ModalSommary.js
  41. 38 8
      src/components/user/Test/getTest.js
  42. 30 20
      src/components/user/Test/index.js
  43. 2 1
      src/configs/routerConfig.js
  44. 11 1
      src/constants/user.js
  45. 0 34
      src/reducers/admin/index.js
  46. 0 1
      src/reducers/admin/test/changeUser.js
  47. 0 1
      src/reducers/admin/test/deleteUsers.js
  48. 3 1
      src/reducers/index.js
  49. 5 0
      src/reducers/initialState.js
  50. 0 1
      src/reducers/user/chageLogin.js
  51. 0 1
      src/reducers/user/changeEmail.js
  52. 0 1
      src/reducers/user/myUser.js
  53. 8 1
      src/reducers/user/startTest.js
  54. 0 1
      src/sagas/admin/category/createCategory.js
  55. 0 1
      src/sagas/admin/category/deleteCategory.js
  56. 0 1
      src/sagas/admin/test/changeTest.js
  57. 0 3
      src/sagas/admin/test/createTest.js
  58. 0 1
      src/sagas/admin/test/getAnswers.js
  59. 0 1
      src/sagas/admin/users/changeUser.js
  60. 0 1
      src/sagas/admin/users/getUser.js
  61. 0 1
      src/sagas/user/myUser.js
  62. 38 0
      src/sagas/user/test/checkTest.js
  63. 5 7
      src/sagas/user/test/index.js
  64. 42 0
      src/sagas/user/test/nextTest.js
  65. 0 1
      src/sagas/user/test/startTest.js
  66. 118 1
      src/styles/style/_styles.scss

+ 0 - 1
src/actions/admin/category/createCategory.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const createCategoryRequest = payload => {
-    console.log(payload,"jjjjjjjjj")
   return{  type: actionTypes.CREATE_CATEGORY_REQUEST,
     payload
 }};

+ 0 - 1
src/actions/admin/changeTest/changeTest.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const changeTestRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.CHANGE_TEST_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/deleteAnswer.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const deleteAnswerRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.DELETE_ANSWER_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/deleteQuestion.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const deleteQuestionRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.DELETE_QUESTION_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/deleteTopic.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const deleteTopicRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.DELETE_TOPIC_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/getAnswers.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const getAnswersRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.GET_ANSWERS_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/getQuestions.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const getQuestionsRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.GET_QUESTIONS_REQUEST,
     payload

+ 0 - 1
src/actions/admin/changeTest/getTopic.js

@@ -1,7 +1,6 @@
 import * as actionTypes from '../../../constants/admin';
 
 export const getTopicRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.GET_TOPIC_REQUEST,
     payload

+ 0 - 1
src/actions/user/changeEmail.js

@@ -1,7 +1,6 @@
 import * as actionTypes from './../../constants/user';
 
 export const changeEmailRequest = payload => {
-    console.log('Inside the changeEMAIL action', payload);
     return {
         type: actionTypes.CHANGE_EMAIL_REQUEST,
         payload

+ 0 - 1
src/actions/user/changePassword.js

@@ -1,7 +1,6 @@
 import * as actionTypes from './../../constants/user';
 
 export const changePasswordRequest = payload => {
-    console.log('Inside the changePassword action', payload);
     return {
         type: actionTypes.CHANGE_PASSWORD_REQUEST,
         payload

+ 0 - 1
src/actions/user/changelogin.js

@@ -1,7 +1,6 @@
 import * as actionTypes from './../../constants/user';
 
 export const changeLoginRequest = payload => {
-    console.log('Inside the changeLogin action', payload);
     return {
         type: actionTypes.CHANGE_LOGIN_REQUEST,
         payload

+ 17 - 0
src/actions/user/test/checkTest.js

@@ -0,0 +1,17 @@
+import * as actionTypes from '../../../constants/user';
+
+
+export const checkTestRequest = payload => {
+    return{
+    type: actionTypes.CHECK_TEST_REQUEST,
+    payload
+};
+}
+export const checkTestSuccess = payload => ({
+    type: actionTypes.CHECK_TEST_REQUEST_SUCCESS,
+    payload
+});
+export const checkTestFailure = error => ({
+    type: actionTypes.CHECK_TEST_REQUEST_FAILURE,
+    error
+});

+ 0 - 1
src/actions/user/test/getTopics.js

@@ -2,7 +2,6 @@ import * as actionTypes from '../../../constants/user';
 
 
 export const getTopicTestRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.GET_TOPIC_TEST_REQUEST,
     payload

+ 17 - 0
src/actions/user/test/nextTest.js

@@ -0,0 +1,17 @@
+import * as actionTypes from '../../../constants/user';
+
+
+export const nextTestRequest = payload => {
+    return{
+    type: actionTypes.NEXT_TEST_REQUEST,
+    payload
+};
+}
+export const nextTestSuccess = payload => ({
+    type: actionTypes.NEXT_TEST_REQUEST_SUCCESS,
+    payload
+});
+export const nextTestFailure = error => ({
+    type: actionTypes.NEXT_TEST_REQUEST_FAILURE,
+    error
+});

+ 0 - 1
src/actions/user/test/testStart.js

@@ -2,7 +2,6 @@ import * as actionTypes from '../../../constants/user';
 
 
 export const startTestRequest = payload => {
-    console.log(payload)
     return{
     type: actionTypes.START_TEST_REQUEST,
     payload

+ 1 - 1
src/components/admin/CreateTest/CreateTopic.js

@@ -122,7 +122,7 @@ console.log(this.state)
                                     {
                                         click_2
                                             ?
-                                            <button type="button" onClick={handleSubmit(formSubmitinput)}>Add answer</button>
+                                            <button className= "btn  btn-outline-light bg-stone m-3" type="button" onClick={handleSubmit(formSubmitinput)}>Add answer</button>
                                             :
                                             <React.Fragment>
                                                 <button className= "btn  btn-outline-light bg-stone m-3" type="button " onClick={handleClick_3}>Create answers</button>

+ 1 - 1
src/components/admin/CreateTest/index.js

@@ -37,7 +37,7 @@ class CreateTest extends React.Component {
 
         return (
             <div className=" padding profile-page  d-flex flex-row font-ci">
-                <div className="w-100 m-5 bg-gradient border rounded">
+                <div className=" slideDown w-100 m-5 bg-gradient border rounded">
                     <div className=" m-5 text-center  text-white font-ci font-ci-bold ">
                         <h4 className="text-white font-ci">Select category for creating tests</h4>
                         <select class="custom-select bg-mist bg-mist-op text-white mt-3 mb-3" onChange={onClick} value={categoryId}>

+ 10 - 7
src/components/admin/addDeleteCategory/ChangeCategory.js

@@ -1,6 +1,7 @@
 import React from 'react';
 import { Field, reduxForm } from 'redux-form';
 import formInput from '../../common/formInput'
+import DeleteCategory from './DeleteCategory';
 
 
 
@@ -8,30 +9,32 @@ class ChangeCategory extends React.Component {
 
     submit = ({ name }) => {
         const { actions: { changeCategoryRequest }, categorys: { id } } = this.props;
-        console.log(
         changeCategoryRequest({
             name,
             id
-        }).payload)
+        })
     }
 
     render() {
-        const { handleSubmit, handlers:{changeCategoryClick}} = this.props;
+        const { handleSubmit, handlers:{changeCategoryClick, deleteClick},categorys} = this.props;
         const { submit } = this;
 
         return (
 
-            <form onSubmin={handleSubmit(submit)}>
-                <Field name="name" type="name" placeholder="Change Category" component={formInput} />
-                <button type="button" className="link link--btn right" onClick={
+            <form className="m-2" onSubmin={handleSubmit(submit)}>
+                <Field className="form-control mb-3" name="name" type="name" placeholder="Change Category" component={formInput} />
+                <div className="d-flex">
+                <button className="btn  btn-outline-light bg-stone m-3" type="button" onClick={
                     function () {
                         
                         handleSubmit(submit)();
                     }
                 }
                 >
-                    Search
+                Сhange
                 </button>
+                <DeleteCategory handlers={{deleteClick}} categorys={categorys}></DeleteCategory>
+                </div>
             </form >
 
         )

+ 2 - 3
src/components/admin/addDeleteCategory/CreateCategoryForm/index.js

@@ -16,10 +16,9 @@ class CreateCategoryForm extends React.Component {
         return (
             <form onSubmin={handleSubmit(submit)}>
                 <Field required name="name" type="name" placeholder="Add new Category" component={formInput} />
-                <button
-                    type="button" className="link link--btn right" onClick={() => {
+                <button className="btn  btn-outline-light bg-stone m-3"
+                    type="button"  onClick={() => {
                         handleSubmit(submit)();
-                        handelClick()
                     }
                     }>
                     Add

+ 1 - 1
src/components/admin/addDeleteCategory/DeleteCategory.js

@@ -28,7 +28,7 @@ class DeleteCategory extends React.Component {
 
         return (
             <div>
-                <button type="button" className="link link--btn right" onClick={()=>{
+                <button className="btn  btn-outline-light bg-stone m-3 right" type="button" onClick={()=>{
                     deleteClick()
                     onClick()
                 }

+ 9 - 23
src/components/admin/addDeleteCategory/GetCategory.js

@@ -26,15 +26,6 @@ class GetCategory extends React.Component {
         this.setState({ massCategory: category.data })
     }
 
-    handelClick = () => {
-        const { data, isFlag } = this.props
-        //!this.state.click || !isFlag ? console.log(isFlag) : this.setState({ massCategory: this.state.massCategory.concat(data) })
-        //this.setState((prevState) => ({ click: !prevState.click }));
-        // data && this.setState(prevState => {
-        //     console.log('----- Prev State', prevState);
-        //     this.setState({ massCategory: this.state.massCategory.concat(data) })
-        // })
-    }
     cclics = () => { //cliCKS
         this.setState((prevState) => ({ click: !prevState.click }));
 
@@ -44,24 +35,19 @@ class GetCategory extends React.Component {
         for (let key in massCategory) {
             if (massCategory[key]._id == id) {
                 delete massCategory[key]
-                // console.log('NET' )
             }
             else {
-                // console.log("null")
             }
         }
         this.setState((prevState) => ({ clicked: !prevState.clicked }))
     }
 
     componentWillReceiveProps(nextProps) {
-        console.log(nextProps)
         const { data, isFlag, actions: { changeCategoryRequest }, changeCategory } = nextProps;
         const { massCategory } = this.state;
-        console.log(data)
 
         if (data) {
             this.setState(prevState => {
-                console.log('----- SET STATE INTO DID UPDATE', prevState);
                 this.setState({ massCategory: this.state.massCategory.concat(data) });
                 store.dispatch({
                     type: 'wtfCreate'
@@ -104,9 +90,9 @@ class GetCategory extends React.Component {
 
         return (
             <div>
-            <div className=" padding profile-page  d-flex flex-row font-ci">
-                <div className="w-100 m-5 bg-gradient border rounded">
-                    <div className=" m-5 text-center  text-white font-ci font-ci-bold ">
+            <div className="overflow-hidden padding profile-page  d-flex flex-row font-ci">
+                <div className="slideDown w-100 p-5 bg-gradient border rounded">
+                    <div className=" text-center  text-white font-ci font-ci-bold ">
                     {
                         massCategory !== null
                             ?
@@ -119,7 +105,7 @@ class GetCategory extends React.Component {
 
                             )
                             :
-                            <PropagateLoader />
+                            null
                     }
                     <div>
                         {
@@ -127,7 +113,7 @@ class GetCategory extends React.Component {
                                 ?
                                 <CreateCategoryForm newCategory={newCategory} actions={{ createCategoryRequest }} handlers={{ handelClick }}></CreateCategoryForm>
                                 :
-                                <button type='button' onClick={this.cclics}>Create Category</button>
+                                <button className="btn  btn-outline-light bg-stone m-3" type='button' onClick={this.cclics}>Create Category</button>
                         }
                     </div>
 
@@ -135,10 +121,10 @@ class GetCategory extends React.Component {
                 {
                     clicked
                         ?
-                        <React.Fragment>
-                            <ChangeCategory actions={{ changeCategoryRequest }} categorys={categorys} handlers={{ changeCategoryClick }}></ChangeCategory>
-                            <DeleteCategory categorys={categorys} handlers={{ deleteClick }} ></DeleteCategory>
-                        </React.Fragment>
+                        <div>
+                            <ChangeCategory actions={{ changeCategoryRequest }} categorys={categorys} handlers={{ changeCategoryClick,deleteClick }}></ChangeCategory>
+                            {/* <DeleteCategory categorys={categorys} handlers={{  }} ></DeleteCategory> */}
+                        </div>
                         :
                         null
                 }

+ 0 - 2
src/components/admin/addDeleteCategory/index.js

@@ -25,9 +25,7 @@ class AddDeleteCategory extends React.Component {
 
     render() {
         const { category, createCategoryRequest, getCategoryRequest, changeCategoryRequest, newCategory: { data, isFlag }, changeCategory } = this.props
-        console.log('---- PARENT RENDER CHECKOUT -----', data);
         const { onClick } = this;
-        console.log(category)
 
         return (
             <div>

+ 1 - 7
src/components/admin/deleteUser/GetUsers.js

@@ -1,9 +1,5 @@
 import React from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux'
-import { getUserRequest } from '../../../actions/admin/user/getUser';
-import { changeUserRequest } from '../../../actions/admin/user/changeUser';
-import ChangeUser from './changeUsers';
+
 
 
 
@@ -53,10 +49,8 @@ class GetUser extends React.Component {
 
 
         render() {
-            // const { handelClick } = this
             const { handlers: { handelClick } } = this.props;
             const { arrayUsers } = this.state;
-            // console.log(initialValues, console.log(user))
 
 
             return (

+ 2 - 6
src/components/admin/deleteUser/changeUsers.js

@@ -1,7 +1,5 @@
 import React from 'react';
-import { connect } from 'react-redux';
-import { bindActionCreators } from 'redux'
-import { changeUserRequest } from '../../../actions/admin/user/changeUser';
+
 import formInput from '../../common/formInput';
 import { Field, reduxForm } from 'redux-form';
 import validate from '../../../configs/validate'
@@ -12,7 +10,6 @@ class ChangeUsers extends React.Component {
 
     submit = ({ name, email, newPassword, confirmPassword }) => {
         const { action: { changeUserRequest }, initialValues: { _id } } = this.props
-        console.log(name, email, newPassword, confirmPassword);
         changeUserRequest({
             name,
             email,
@@ -21,8 +18,8 @@ class ChangeUsers extends React.Component {
             _id
         })
     }
+
     deleteUser=()=>{
-        // console.log(this.props)
         const {action:{deleteUsersRequest},initialValues: { _id }}=this.props
         deleteUsersRequest({_id})
         
@@ -33,7 +30,6 @@ class ChangeUsers extends React.Component {
     render() {
         const { initialValues, handleSubmit } = this.props;
         const { submit, deleteUser } = this
-        console.log(initialValues)
 
         return (
             <div>

+ 12 - 15
src/components/admin/deleteUser/index.js

@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
 import { bindActionCreators } from 'redux'
 import { getUserRequest } from '../../../actions/admin/user/getUser';
 import { changeUserRequest } from '../../../actions/admin/user/changeUser';
-import {deleteUsersRequest} from '../../../actions/admin/user/deleteUser'
+import { deleteUsersRequest } from '../../../actions/admin/user/deleteUser'
 import ChangeUser from './changeUsers';
 import GetUser from './GetUsers';
 import PropagateLoader from 'react-spinners/PropagateLoader';
@@ -22,7 +22,6 @@ class DeleteUser extends React.Component {
 
     }
     handelClick = ({ el }) => {
-        console.log(el)
         this.setState({ initialValues: el });
         this.setState((prevState) => ({ flag: !prevState.flag }))
     }
@@ -31,31 +30,29 @@ class DeleteUser extends React.Component {
         const { handelClick } = this
         const { users: { user }, changeUserRequest, changeUser: { data, isFetching }, deleteUsers, deleteUsersRequest } = this.props;
         const { initialValues, flag } = this.state;
-        console.log(initialValues)
-         console.log(user)
 
 
         return (
-            <div className=" profile-page d-flex flex-row font-ci padding ">
-                <div className='w-25 p-3 bg-rgba border rounded'  >
-                    <h4 class="text-center  text-white font-ci font-ci-bold">USERS</h4>
+            <div className="overflow-hidden profile-page d-flex flex-row font-ci padding ">
+                <div className='slideRight w-25 p-3 bg-gradient border rounded'  >
+                    <h4 class=" text-center  text-white font-ci font-ci-bold">USERS</h4>
                     <div class="list-group">
                         {
                             user !== null
-                            ?
-                        <GetUser data={data} deleteUsers={deleteUsers} initialValues={initialValues} user={user} isFetching ={isFetching } handlers={{handelClick}}></GetUser>
-                        :
-                        <PropagateLoader />
+                                ?
+                                <GetUser data={data} deleteUsers={deleteUsers} initialValues={initialValues} user={user} isFetching={isFetching} handlers={{ handelClick }}></GetUser>
+                                :
+                                <PropagateLoader />
                         }
                     </div>
                 </div>
-                <div className='w-75 p-3 bg-rgba ml-3 border rounded'  >
+                <div className='w-75 p-3 bg-gradient ml-3 border rounded slideLeft'  >
 
                     {
                         flag
                             ?
-                                <ChangeUser initialValues={initialValues} action={{ changeUserRequest,deleteUsersRequest }} ></ChangeUser>
-                            : 
+                            <ChangeUser initialValues={initialValues} action={{ changeUserRequest, deleteUsersRequest }} ></ChangeUser>
+                            :
                             null
                     }
                 </div>
@@ -69,7 +66,7 @@ const
     mapStateToProps = state => ({
         users: state.users,
         changeUser: state.changeUser,
-        deleteUsers:state.deleteUsers
+        deleteUsers: state.deleteUsers
     });
 
 const mapDispatchToProps = dispatch => bindActionCreators({ getUserRequest, changeUserRequest, deleteUsersRequest }, dispatch);

+ 0 - 21
src/components/admin/getChangeDeleteTest/ChangeQestion.js

@@ -1,21 +0,0 @@
-// {
-//     arrayTopic.map(el =>
-//         <ul class="list-group d-flex flex-row">
-
-//             <li class="list-group-item col-sm" id={el._id} key={el._id}>{el.name}</li>
-//             <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " onClick={()=>{
-//                 handleClick.bind(null, { el })()
-//                 questionsClick.bind(null, { el })()}
-//                 } type="button"  >
-//                 P
-//             </button>
-//             <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " onClick={deleteClick.bind(null, { el })} type="button"  >
-//                 X
-//             </button>
-//         </ul>
-
-
-//     )
-//                             <GetTest actions={{ getQuestionsRequest, deleteTopicRequest }} data ={data} topicElement={topicElement} handlers={{handleClick}} topic={topic} deleteTopic={deleteTopic} ></GetTest>
-
-// }

+ 1 - 8
src/components/admin/getChangeDeleteTest/GetQuestions.js

@@ -21,12 +21,7 @@ class GetQuestions extends React.Component {
     changeQuestion = (event) => {
         this.setState({questionS:{question:event.target.value}})
     }
-    // handleClick =({el:{_id}})=>{
-    //     const {actions:{getQestionsRequest}} =this.props
-    //     console.log(_id)
-    //     getQestionsRequest({_id})
-
-    // }
+  
     submit =(payload)=>{
 console.log(payload)
     }
@@ -40,12 +35,10 @@ console.log(payload)
     componentWillUpdate(nextState, nextProps) {
         const { deleteQuestion: { isFetching } } = nextState;
         const { arrayQuestion, id } = nextProps;
-        console.log(isFetching, "nextState---------", nextState, "nextProps_________", nextProps)
         if (!isFetching) {
             for (let key in arrayQuestion) {
                 if (arrayQuestion[key]._id == id) {
                     this.setState(prevState => {
-                        console.log("-------TRUE--------")
                         const array = prevState.arrayQuestion.slice()
                         array.splice(key, 1)
                         return {

+ 2 - 41
src/components/admin/getChangeDeleteTest/GetTest.js

@@ -12,51 +12,13 @@ class GetTest extends React.Component {
         this.setState({ arrayCategory: data })
     }
 
-
-    // questionsClick = ({ el: { _id, name } }) => {
-    //     const { actions: { getQuestionsRequest } } = this.props
-    //     console.log(_id)
-    //     getQuestionsRequest({ _id })
-
-    // }
-    // deleteClick = ({ el: { _id } }) => {
-    //     const { actions: { deleteTopicRequest }, deleteTopic } = this.props;
-    //     deleteTopicRequest({ _id })
-    //     console.log(deleteTopic)
-
-    // }
-    // componentWillUpdate(nextState, nextProps) {
-    //     const { deleteTopic: { isFetching }, topicElement: { id } } = nextState;
-    //     const { arrayTopic } = nextProps;
-    //     console.log(isFetching, "nextState---------", nextState, "nextProps_________", nextProps)
-    //     if (!isFetching) {
-    //         for (let key in arrayTopic) {
-    //             if (arrayTopic[key]._id == id) {
-    //                 this.setState(prevState => {
-    //                     console.log("-------TRUE--------")
-    //                     const array = prevState.arrayTopic.slice()
-    //                     array.splice(key, 1)
-    //                     return {
-    //                         arrayTopic: array
-    //                     }
-    //                 })
-    //                 break;
-    //             }
-    //         }
-
-    //     }
-    // }
-
-
     render() {
-        // const { deleteClick, questionsClick } = this
+
         const { handlers:{getQuestionClick} } = this.props;
         const { arrayTopic, topicElement, arrayCategory } = this.state
-        console.log(this.state)
 
         return (
-            <div className=" profile-page w-50 p-4 d-flex flex-row font-ci">
-                <div className="container  h-auto  bg-stone  bg-mist-border">
+                <div className=' slideRight w-45 p-3 bg-gradient border rounded'  >
                     {
                         arrayCategory.map(el =>
 
@@ -68,7 +30,6 @@ class GetTest extends React.Component {
                         )
                     }
                 </div>
-            </div>
         )
     }
 

+ 18 - 37
src/components/admin/getChangeDeleteTest/GetTopic.js

@@ -15,29 +15,15 @@ class GetTest extends React.Component {
     }
 
 
-    // questionsClick = ({ el: { _id, name } }) => {
-    //     const { actions: { getQuestionsRequest } } = this.props
-    //     console.log(_id)
-    //     getQuestionsRequest({ _id })
-
-    // }
-    // deleteClick = ({ el: { _id } }) => {
-    //     const { actions: { deleteTopicRequest }, deleteTopic } = this.props;
-    //     deleteTopicRequest({ _id })
-    //     console.log(deleteTopic)
-
-    // }
     componentWillUpdate(nextState, nextProps) {
-        const { newTopic,deleteTopic, topicId } = nextState;
-        const { arrayTopic:{topic} } = nextProps;
-        console.log( "nextState---------", nextState, "nextProps_________", nextProps)
-        if (newTopic.data !==null) {
+        const { newTopic, deleteTopic, topicId } = nextState;
+        const { arrayTopic: { topic } } = nextProps;
+        if (newTopic.data !== null) {
             for (let key in topic) {
                 if (topic[key]._id == newTopic.data._id) {
                     this.setState(prevState => {
-                        console.log("-------TRUE--------")
                         const array = prevState.arrayTopic.topic.slice()
-                        array.splice(key, 1,newTopic.data)
+                        array.splice(key, 1, newTopic.data)
                         return {
                             arrayTopic: array
                         }
@@ -47,14 +33,12 @@ class GetTest extends React.Component {
             }
 
         }
-        if(!deleteTopic.isFetching){
+        if (!deleteTopic.isFetching) {
             for (let key in topic) {
                 if (topic[key]._id == topicId) {
                     this.setState(prevState => {
-                        console.log("-------TRUE--------", topic[key]._id ===topicId)
                         const array = prevState.arrayTopic.topic.slice()
                         array.splice(key, 1)
-                        console.log(array)
                         return {
                             arrayTopic: array
                         }
@@ -67,25 +51,22 @@ class GetTest extends React.Component {
 
 
     render() {
-        // const { deleteClick, questionsClick } = this
-        const { handlers:{openEditModal} } = this.props;
-        // const { arrayTopic, topicElement, arrayCategory } = this.state
-        const { arrayTopic:{topic} } = this.state
-        console.log(this.state)
+        const { handlers: { openEditModal } } = this.props;
+        const { arrayTopic: { topic } } = this.state
 
         return (
-            <div className=" profile-page w-50 p-4 d-flex flex-row font-ci">
-                <div className="container  h-auto  bg-stone  bg-mist-border">
-                    {
-                        topic&&topic.map(el =>
-                            <div className="btn ">
-                                <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " onClick ={openEditModal.bind(null,{el})} type="button" id={el._id} key={el._id} >
-                                    {el.name}
-                                </button>
-                            </div>)
-                    }
-                </div>
+
+            <div className='slideLeft w-45 p-3 bg-gradient border rounded'  >
+                {
+                    topic && topic.map(el =>
+                        <div className="btn ">
+                            <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " onClick={openEditModal.bind(null, { el })} type="button" id={el._id} key={el._id} >
+                                {el.name}
+                            </button>
+                        </div>)
+                }
             </div>
+
         )
     }
 

+ 19 - 42
src/components/admin/getChangeDeleteTest/OpenModal.js

@@ -1,7 +1,6 @@
 import React, { Component } from "react";
 import { Modal } from "react-bootstrap";
-import { Header } from "react-bootstrap/ModalHeader";
-import { Button } from "react-bootstrap"
+
 import { Field, reduxForm } from 'redux-form';
 import formInput from '../../common/formInput'
 
@@ -13,28 +12,29 @@ class EditModal extends React.Component {
         clicks: false,
         questionId: null
     }
+
     submit = (payload) => {
         const { name, categoryId, description, question, simple, topicId } = payload
         const { answers, questionId } = this.state
-        console.log(name, categoryId, description, question, simple, topicId, answers)
         const { actions: { changeTestRequest } } = this.props;
         changeTestRequest({ questionId, name, categoryId, description, question, simple, topicId, answers })
 
-        // console.log(payload)
     }
+
     changeQuestion = (event) => {
         const { value } = event.target
         const { actions: { getAnswersRequest } } = this.props;
-        console.log(event.target.valus, value)
         getAnswersRequest({ value })
         this.setState((prevState) => ({ clicked: !prevState.clicked, }))
         this.setState({ questionId: value })
 
     }
+
     answersChange = (event) => {
         const { value } = event.target
         this.setState({ clicks: true, answers_id: value })
     }
+
     changeAnswers = (payload) => {
         const { answers_id } = this.state
         const { answer, price, correct } = payload
@@ -48,28 +48,31 @@ class EditModal extends React.Component {
         this.setState({ clicks: false })
 
     }
+
     deleteAnswer = () => {
         const { answers_id } = this.state
         const { actions: { deleteAnswerRequest } } = this.props;
         deleteAnswerRequest({ answers_id })
 
     }
+
     deleteQuestions = () => {
-        const{questionId} =this.state
+        const { questionId } = this.state
         const { actions: { deleteQuestionRequest } } = this.props;
-        deleteQuestionRequest({questionId})
+        deleteQuestionRequest({ questionId })
     }
-    deleteTopic=(payload)=>{
-        const{topicId}=payload
-        const{actions:{deleteTopicRequest}} =this.props;
-        deleteTopicRequest({topicId})
+
+    deleteTopic = (payload) => {
+        const { topicId } = payload
+        const { actions: { deleteTopicRequest } } = this.props;
+        deleteTopicRequest({ topicId })
 
     }
+
     render() {
         const { visible, handleClose: { closeModal }, inputData, editLoads, initialValues, arrayQuestions: { questions, _id }, answers, handlers: { handelClick }, click, handleSubmit } = this.props;
         const { submit, answersChange, changeAnswers, deleteAnswer, deleteQuestions, deleteTopic } = this
         const { clicked, clicks } = this.state
-        console.log(this.state)
         return (
             <Modal show={visible} onHide={closeModal} aria-labelledby="contained-modal-title-vcenter" >
                 < Modal.Header closeButton >
@@ -102,7 +105,7 @@ class EditModal extends React.Component {
                                     <h4 class="text-center  text-white font-ci font-ci-bold">Questions and Simple</h4>
                                     <Field name="question" type="question" component={formInput} />
                                     <Field name="simple" type="checkbox" component={formInput} />
-                                    <button className="btn  btn-outline-light bg-stone m-3" onClick={handleSubmit(deleteQuestions)} >Change Question</button >
+                                    <button className="btn  btn-outline-light bg-stone m-3" onClick={handleSubmit(deleteQuestions)} >Delete Question</button >
                                 </React.Fragment>
                                 : null
                         }
@@ -138,40 +141,14 @@ class EditModal extends React.Component {
                                     </React.Fragment>
                                     : null
                             }
-                            {/* {
-                            answers !== null
-                                ?
-                                answers.map(el =>
-
-
-                                   
-                                        <React.Fragment>
-                                            <li class="list-group-item" key={el._id} id={el._id}>{el.answer}</li>
-                                            <button type="button" onClick={handelClick.bind(null, { el })}>Change</button>
-                                            <button type="button">Delete</button>
-                                        </React.Fragment>
-                                        :
-                                        <React.Fragment>
-                                            <Field name="answer" type="answer" component={formInput} className="form-control mb-3" />
-                                            <Field name="corrent" type="checkbox" component={formInput} />
-                                            <Field name="price" type="price" component={formInput} />
-                                            <button onClick={handelClick.bind(null, { el })}>Change</button>
-                                    <button>Delete</button>
-                </React.Fragment>
-                                )
-                                :
-                                null
-                        } */}
-
-
 
                         </ul>
                     </form>
                 </ Modal.Body >
                 < Modal.Footer>
-                <React.Fragment>
-                <button className="btn  btn-outline-light bg-stone m-3" onClick={handleSubmit(deleteTopic)}>Delete Answer</button>
-                    <button type="submit" >Change</button>
+                    <React.Fragment>
+                        <button className="btn  btn-outline-light bg-stone m-3" onClick={handleSubmit(deleteTopic)}>Delete Answer</button>
+                        <button type="submit" className="btn  btn-outline-light bg-stone m-3" onClick={handleSubmit(submit)} >Change</button>
                     </React.Fragment>
                 </ Modal.Footer >
             </Modal>

+ 112 - 0
src/components/admin/getChangeDeleteTest/changeQuestions.js

@@ -0,0 +1,112 @@
+import React from 'react';
+import { Field, reduxForm } from 'redux-form';
+import formInput from '../../common/formInput';
+
+
+
+
+class GetQuestions extends React.Component {
+    state = {
+        id: null,
+        arrayQuestion: [],
+        question:{
+        names: null
+        }
+    }
+
+    componentWillMount = () => {
+        const { questions } = this.props;
+        console.log(questions)
+        this.setState({ arrayQuestion: questions })
+    }
+
+    changeQuestion = (event) => {
+        this.setState({ question:{names: event.target.value} })
+    }
+
+    // handleClick =({el:{_id}})=>{
+    //     const {actions:{getQestionsRequest}} =this.props
+    //     console.log(_id)
+    //     getQestionsRequest({_id})
+
+    // }
+
+    deleteClick = ({ el: { _id } }) => {
+        this.setState({ id: _id })
+        const { actions: { deleteQuestionRequest } } = this.props;
+        deleteQuestionRequest({ _id })
+    }
+
+    componentWillUpdate(nextState, nextProps) {
+        const { deleteQuestion: { isFetching } } = nextState;
+        const { arrayQuestion, id } = nextProps;
+        console.log(isFetching, "nextState---------", nextState, "nextProps_________", nextProps)
+        if (!isFetching) {
+            for (let key in arrayQuestion) {
+                if (arrayQuestion[key]._id == id) {
+                    this.setState(prevState => {
+                        console.log("-------TRUE--------")
+                        const array = prevState.arrayQuestion.slice()
+                        array.splice(key, 1)
+                        return {
+                            arrayQuestion: array
+                        }
+                    })
+                    break;
+                }
+            }
+
+        }
+    }
+
+    render() {
+        const { handleClick, deleteClick, changeQuestion } = this;
+        const{question}=this.state
+        const { arrayQuestion } = this.state;
+        console.log(this.state)
+
+        return (
+            <div className=" profile-page p-4 d-flex flex-row font-ci">
+                <div className="container w-100 h-auto  bg-stone  bg-mist-border">
+                    <form >
+                        <Field name="name" type="name" component={formInput} />
+                        {
+                            question.names==null
+                        ?
+                        <select class="custom-select bg-mist bg-mist-op text-white mt-3 mb-3" onChange={changeQuestion} value={question} >
+                            <option selected>Open this Category menu</option>
+                            {
+                                arrayQuestion && arrayQuestion.map(el =>
+                                    <React.Fragment>
+                                        <option key={el._id} value={el.question}>{el.question}</option>
+                                        <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " type="button"  >
+                                            P
+                                    </button>
+                                        <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " onClick={deleteClick.bind(null, { el })} type="button"  >
+                                            X
+                                    </button>
+                                    </React.Fragment>
+                                )
+                            }
+                        </select>
+                        :
+                        <Field name="name" type="name" initialize ={this.state.question.names}component={formInput} />
+                        
+                        
+                        }
+                    </form>
+                </div>
+            </div >
+        )
+    }
+
+}
+
+
+export default reduxForm({
+    form: "changeTestForm",
+    enableReinitialize: true
+})(GetQuestions)
+
+
+

+ 8 - 21
src/components/admin/getChangeDeleteTest/index.js

@@ -8,15 +8,14 @@ import { deleteQuestionRequest } from '../../../actions/admin/changeTest/deleteQ
 import { getCategoryRequest } from '../../../actions/admin/category/getCategory';
 import { getAnswersRequest } from '../../../actions/admin/changeTest/getAnswers';
 import { changeTestRequest } from '../../../actions/admin/changeTest/changeTest';
-import {deleteAnswerRequest} from '../../../actions/admin/changeTest/deleteAnswer';
+import { deleteAnswerRequest } from '../../../actions/admin/changeTest/deleteAnswer';
+
 
-import PropagateLoader from 'react-spinners/PropagateLoader';
 
 
 import GetTest from './GetTest';
 import GetTopic from './GetTopic';
 import EditModal from './OpenModal';
-import GetQuestions from './GetQuestions';
 
 
 
@@ -54,13 +53,8 @@ class ChangeTest extends React.Component {
     }
 
     handelClick = ({ el: { answer, correct, price, _id } }) => {
-        // const answers =`answer${_id}`
-        // const corrents =`corrent${_id}`
-        // const prices =`price${_id}`
-        // console.log(answer)
         this.setState({ answer: answer, corrent: correct, price: price });
         this.setState((prevState) => ({ click: !prevState.click }))
-
     }
 
     componentWillMount = () => {
@@ -68,35 +62,28 @@ class ChangeTest extends React.Component {
         getCategoryRequest()
     }
     componentWillReceiveProps(nextProps) {
-        console.log(nextProps)
         const { arrayAnswers: { answers } } = nextProps;
         if (answers !== null) {
             this.setState({ answers: answers })
         }
     }
-    // componentWillUpdate(nextState, nextProps) {
-    //     console.log("-------NEXT STATE---------", nextState, "---------NEXT PROPS---------", nextProps)
 
-    // }
 
     render() {
         const { getQuestionClick, openEditModal, closeModal, handelClick, state } = this;
         const { openModal, questionId, name, topicId, description, answers, click } = this.state
-        // const { topic, deleteQuestionRequest, getQuestionsRequest, arrayQuestions: { questions, isFlag }, deleteTopicRequest, deleteTopic, deleteQuestion } = this.props;
-        // console.log(topic)
         const initialValues = {
             ...state
         }
-        const { category: { data, isFlag },deleteTopic, topic, arrayQuestions, getAnswersRequest,deleteTopicRequest, arrayAnswers, changeTestRequest, newTopic ,deleteAnswerRequest,deleteQuestionRequest} = this.props
-        console.log(this.state)
+        const { category: { data, isFlag }, deleteTopic, topic, arrayQuestions, getAnswersRequest, deleteTopicRequest, arrayAnswers, changeTestRequest, newTopic, deleteAnswerRequest, deleteQuestionRequest } = this.props
 
         return (
-            <div className=" p-5 d-flex flex-row font-ci">
+            <div className=" profile-page  font-ci padding ">
 
                 {
                     !isFlag
                         ?
-                        <PropagateLoader />
+                        null
                         :
                         <React.Fragment>
                             <GetTest data={data} handlers={{ getQuestionClick }}></GetTest>
@@ -105,7 +92,7 @@ class ChangeTest extends React.Component {
                                     ?
                                     <React.Fragment>
                                         <GetTopic handlers={{ openEditModal }} topicId={topicId} deleteTopic={deleteTopic} newTopic={newTopic} topic={topic}></GetTopic>
-                                        <EditModal className="bg-mist"  visible={openModal}  handlers={{ handelClick }} click={click} answers={answers} actions={{ getAnswersRequest,deleteTopicRequest,deleteAnswerRequest,deleteQuestionRequest, changeTestRequest }} arrayQuestions={arrayQuestions} initialValues={initialValues}
+                                        <EditModal className="bg-mist" visible={openModal} handlers={{ handelClick }} click={click} answers={answers} actions={{ getAnswersRequest, deleteTopicRequest, deleteAnswerRequest, deleteQuestionRequest, changeTestRequest }} arrayQuestions={arrayQuestions} initialValues={initialValues}
                                             handleClose={{ closeModal }}></EditModal>
                                     </React.Fragment>
                                     :
@@ -129,10 +116,10 @@ const
         deleteQuestion: state.deleteQuestion,
         category: state.category,
         arrayAnswers: state.arrayAnswers,
-        newTopic:state.newTopic
+        newTopic: state.newTopic
 
     });
 
-const mapDispatchToProps = dispatch => bindActionCreators({ getCategoryRequest,deleteAnswerRequest, getTopicRequest, changeTestRequest, getQuestionsRequest, deleteTopicRequest, deleteQuestionRequest, getAnswersRequest }, dispatch);
+const mapDispatchToProps = dispatch => bindActionCreators({ getCategoryRequest, deleteAnswerRequest, getTopicRequest, changeTestRequest, getQuestionsRequest, deleteTopicRequest, deleteQuestionRequest, getAnswersRequest }, dispatch);
 
 export default connect(mapStateToProps, mapDispatchToProps)(ChangeTest);

+ 1 - 1
src/components/common/formInput.js

@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
 
 export default ({ input, className, placeholder, required, type, meta: { touched, error } }) => (
     <Fragment>
-        <input className={className} placeholder={placeholder} type={type} {...input} required/>
+        <input className={className} placeholder={placeholder} type={type} {...input}/>
         {touched && (error && <p className="text-af pt-2 text-uppercase">⚠ {error}</p>)}
         {required ? <p className="text-af pt-2 text-uppercase">⚠ Reqired</p> : null}
     </Fragment>

+ 7 - 8
src/components/public/Header.js

@@ -39,18 +39,17 @@ class Header extends React.Component {
                         
                         <li class="nav-item dropdown">
 
-                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                Dropdown
+                            <a class="nav-link text-shadow font-ci font-ci-bold" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                Menu Admin
                                 </a>
                             <div class="dropdown-menu" aria-labelledby="navbarDropdown">
-                            <Link to={routes.DELETE_USER} className="nav-link text-secondary">Delete User</Link>
-                                <Link to={routes.CREATE_TEST} className="nav-link text-secondary">Create Test</Link>
-                                <Link to={routes.CHANGE_TEST} className="nav-link text-secondary">Change Test</Link>
+                            <Link to={routes.DELETE_USER} className="nav-link text-secondary text-shadow font-ci">Delete User</Link>
+                                <Link to={routes.CREATE_TEST} className="nav-link text-secondary text-shadow font-ci">Create Test</Link>
+                                <Link to={routes.CHANGE_TEST} className="nav-link text-secondary text-shadow font-ci">Change Test</Link>
                                 
-                                <Link to={routes.CREATE_CATEGORY} className="nav-link text-secondary">Create Category</Link>
+                                <Link to={routes.CREATE_CATEGORY} className="nav-link text-secondary text-shadow font-ci">Create Category</Link>
 
-                                <div class="dropdown-divider"></div>
-                                <a class="nav-link text-secondary" href="#">Something else here</a>
+                                
                             </div>
                         </li>
 

+ 63 - 0
src/components/user/Categoty.js

@@ -0,0 +1,63 @@
+import React from 'react';
+import { Link } from "react-router-dom";
+
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux'
+import { getCategoryRequest } from '../../actions/admin/category/getCategory';
+import * as routes from '../../constants/routes';
+
+
+
+
+class AddDeleteCategory extends React.Component {
+    state = {
+        ckick: false
+    }
+    componentDidMount() {
+        const { getCategoryRequest } = this.props
+        getCategoryRequest()
+    }
+
+
+
+
+    render() {
+        const { category:{data}  } = this.props
+        // console.log(category)
+
+        return (
+                  <div className="slideDown padding profile-page  d-flex flex-row font-ci">
+                <div className="w-100 m-5 bg-gradient border rounded">
+                    <div className=" m-5 text-center  text-white font-ci font-ci-bold ">
+                        {
+                            data !== null
+                                ?
+                                data.map(mass =>
+                                    <div className="btn " key={mass.id}>
+                                        <button class="btn btn-secondary font-ci font-ci-bold text-light bg-mist " type="button" id={mass.id} key={mass.id} >
+                                        <Link  class="font-ci font-ci-bold text-light" to={routes.TESTS}>{mass.name}</Link>
+                                        </button>
+                                    </div>
+
+                                )
+                                :
+                                null
+                        }
+
+                    </div>
+                </div>
+            </div>
+
+        )
+    }
+
+}
+
+const
+    mapStateToProps = state => ({
+        category: state.category,
+    });
+
+const mapDispatchToProps = dispatch => bindActionCreators({getCategoryRequest}, dispatch);
+
+export default connect(mapStateToProps, mapDispatchToProps)(AddDeleteCategory);

+ 0 - 2
src/components/user/ProfilePage/ChangeEmailForm/index.js

@@ -1,5 +1,4 @@
 import React from 'react';
-import { connect } from 'react-redux';
 import { Field, reduxForm } from 'redux-form';
 
 import formInput from '../../../common/formInput';
@@ -8,7 +7,6 @@ class ChangeEmailForm extends React.Component {
 
     submit = ({email}) => {
         const {actions:{changeEmailRequest},data:{_id},token } = this.props
-        console.log(_id, email,token);
 
         changeEmailRequest({
             token,

+ 0 - 2
src/components/user/ProfilePage/ChangeLoginForm/index.js

@@ -8,7 +8,6 @@ class ChangeLoginForm extends React.Component {
 
     submit = ({ name}) => {
         const {actions:{changeLoginRequest},data:{_id},token } = this.props
-        console.log(_id, name,token);
 
         changeLoginRequest({
             token,
@@ -21,7 +20,6 @@ class ChangeLoginForm extends React.Component {
     render() {
         const { children, handleSubmit, actions:{changeLoginRequest}, handlers: {  handleClick }, data, token } = this.props;
         const { submit}=this
-        console.log( data)
         return (
             <form onSubmit={handleSubmit(submit)} >
                 <Field name="name" type="email" placeholder="Enter new login" component={formInput} className="bg-rgba1 border" />

+ 0 - 2
src/components/user/ProfilePage/changePassword/index.js

@@ -8,7 +8,6 @@ class ChangePasswordForm extends React.Component {
 
     submit = ({password, confirmPassword }) => {
         const {actions:{changePasswordRequest},data:{_id},token } = this.props
-        console.log(_id, password, confirmPassword, token);
 
         changePasswordRequest({
             token,
@@ -22,7 +21,6 @@ class ChangePasswordForm extends React.Component {
     render() {
         const { children, handleSubmit, actions:{ changePasswordRequest }, handlers: {  handleClicked }, data, token } = this.props;
         const { submit}=this
-        console.log( data)
         return (
             <form onSubmit={handleSubmit(submit)} >
                 <Field name="password" type="password" placeholder="Password" className ='' component={formInput} className="bg-rgba1 border" />

+ 1 - 3
src/components/user/ProfilePage/index.js

@@ -8,7 +8,6 @@ import {changeLoginRequest} from '../../../actions/user/changelogin';
 import {changeEmailRequest} from '../../../actions/user/changeEmail';
 import {changePasswordRequest } from '../../../actions/user/changePassword';
 import {myUserRequest} from '../../../actions/admin/meUser'
-import store from '../../../state'
 
 class ProfilePage extends React.Component {
     
@@ -33,13 +32,12 @@ class ProfilePage extends React.Component {
     }
 
     render() {
-        console.log(store.getState(), data)
         const { myUser:{data, token}, changeLoginRequest, chageLoginReducer, changeEmailRequest, changeEmailReducer, changePasswordRequest} = this.props;
         const {clicked, klick, click} =this.state;
         const {handleClick, handleClicks, handleClicked} = this;
 
         return (
-            <div className="page page--bottom-only profile-page bg-img d-block w-100 slider-image padding" >
+            <div className="slideDown page page--bottom-only profile-page bg-img d-block w-100 slider-image padding" >
                 <div className="border bg-rgba rounded d-flex  ">
                     <div>
                     <div>

+ 25 - 0
src/components/user/Test/ModalSommary.js

@@ -0,0 +1,25 @@
+import React, { Component } from "react";
+import { Modal } from "react-bootstrap";
+
+
+class ModalSummary extends React.Component {
+
+
+    render() {
+        const{clickModal, summary, handlers:{closeModal}}= this.props
+        return (
+            <Modal show={clickModal} onHide={closeModal} aria-labelledby="contained-modal-title-vcenter" >
+                < Modal.Header closeButton >
+                    < Modal.Title className="text-center  text-white font-ci font-ci-bold" >Summary </ Modal.Title >
+                </ Modal.Header >
+                < Modal.Body >
+                    <h4>{summary}</h4>
+                </ Modal.Body >
+                < Modal.Footer>
+                </ Modal.Footer >
+            </Modal>
+        );
+    }
+}
+
+export default ModalSummary

+ 38 - 8
src/components/user/Test/getTest.js

@@ -1,25 +1,55 @@
 import React, { Component } from "react";
 import { Field, reduxForm } from 'redux-form';
-import formInput from '../../common/formInput'
-
+import formInput from '../../common/formInput';
+import ModalSummary from './ModalSommary'
+import {reset} from 'redux-form';
 class Test extends React.Component {
+    state={
+        answers:[],
+        question:null,
+    }
+
+    submit=()=>{
+        const{sessionId,_id, actions:{checkTestRequest, nextTestRequest, startTestRequest} } =this.props;
+        const {answers, question} = this.state;
+        checkTestRequest({_id})
+        nextTestRequest({_id, sessionId,question, answers})
+        reset("gfhfh")
+        // startTestRequest({_id})
+
+    }
+    handelChange=({el:{_id, question}})=>{
+this.setState((prevState)=>({answers:prevState.answers.concat(_id)}))
+this.setState({question:question})
+    }
 
     render() {
-        const { data: { question } } = this.props
+        const { data, handleSubmit, summary, clickModal, handlers:{closeModal} } = this.props;
+        const{submit}=this
         return (
-            <form >
+            <form onSubmit={handleSubmit(submit)}>
 
-                <h4 className="text-white font-ci">{question.question}</h4>
+                <h4 className="text-white font-ci">{
+                    data.question !==undefined
+                    ?
+                    data.question.question
+                    :null
+                    }</h4>
                 <div className=' d-flex flex-column'>
                     {
-                        question.answersArr.map(el =>
-                            <div>
-                                <Field name="answer" type="checkbox" component={formInput} />
+                        data.question !==undefined
+                        ?
+                        data.question.answersArr.map(el =>
+                            <div key={el._id}>
+                                <Field name={`answer${el.answer}`}  value={el.answer} type="checkbox" onChange={this.handelChange.bind(null,{el})} component={formInput} />
                                 <span className="text-white font-ci">{el.answer}</span>
                                 </div>
                         )
+                        :
+                        <ModalSummary handlers={{closeModal}} summary={summary} clickModal ={clickModal}></ModalSummary>
                     }
                 </div>
+                <button  className="btn  btn-outline-light bg-stone m-3 right">Next</button>
             </form>
         )
     }

+ 30 - 20
src/components/user/Test/index.js

@@ -3,45 +3,56 @@ import { connect } from 'react-redux';
 import { bindActionCreators } from 'redux';
 import {getTopicTestRequest} from '../../../actions/user/test/getTopics'
 import {startTestRequest} from '../../../actions/user/test/testStart';
+import {checkTestRequest} from '../../../actions/user/test/checkTest';
+import {nextTestRequest} from '../../../actions/user/test/nextTest'
 import Test from './getTest';
+
 	
-import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
+
 
 class PassingTests extends React.Component {
     state={
-        topicId:null,
-        sessionId:null
+        _id:null,
+        sessionId:null,
+        summary:null,
+        clickModal:false
     }
 
 componentWillMount(){
     const{getTopicTestRequest} =this.props
     getTopicTestRequest()
 }
+
+closeModal = () => { this.setState((prevState) => ({ clickModal: !prevState.clickModal })) }
 handelClick=({el:{_id}})=>{
-    const{startTestRequest}=this.props
+    const{startTestRequest, checkTestRequest}=this.props
+    checkTestRequest({_id})
     startTestRequest({_id})
-    this.setState({topicId:_id})
+    this.setState({_id:_id})
 }
-componentWillUpdate(nextState, nextProps) {
-    const{startTest:{data}}=nextState
-    // if(data!==null){
-    //     this.setState({sessionId:data.sessionId})
-    // }
-    console.log("____nextState_____",nextState, "_____nextProps___", nextProps)
+componentWillReceiveProps(nextProps) {
+    const{startTest:{data}}=nextProps
+    if(data!==null){
+        this.setState({sessionId:data.sessionId})
+          if(data.finish){
+        this.setState({summary:data.summory,clickModal:true})
+    }
+    }
+
+  
 }
 
 
     render() {
-        const{ handelClick}=this
-        const{topicTest:{topic},startTest:{data}}=this.props;
-        console.log(this.state)
+        const{ handelClick,closeModal}=this
+        const {sessionId,_id, summary, clickModal} =this.state
+        const{topicTest:{topic},startTest:{data}, checkTestRequest, nextTestRequest, startTestRequest}=this.props;
 
 
         return (
-            <ReactCSSTransitionGroup transitionName="anim" transitionAppear={true} transitionAppearTimeout={5000} transitionEnter={false} transitionLeave={false}>
             <div className=" profile-page d-flex flex-row font-ci padding  ">
           
-                <div className='w-25 p-3  border rounded bg-gradient'  >
+                <div className='w-25 p-3  border rounded bg-gradient slideRight'  >
                     {
                         topic!==null
                         ?
@@ -51,11 +62,11 @@ componentWillUpdate(nextState, nextProps) {
                         :null
                     }
                 </div>
-                <div className='w-75 p-3  ml-3 border rounded d-flex flex-row bg-gradient'  >
+                <div className='w-75 p-3  ml-3 border rounded d-flex flex-row bg-gradient slideLeft'  >
                     {
                         data !==null
                         ?
-                        <Test data={data}></Test>
+                        <Test actions={{checkTestRequest, nextTestRequest, startTestRequest}} handlers={{closeModal}} summary={summary} clickModal={clickModal} sessionId={sessionId} _id={_id} data={data}></Test>
                            
                         :
                         null
@@ -65,7 +76,6 @@ componentWillUpdate(nextState, nextProps) {
                 </div>
             </div>
 
-            </ReactCSSTransitionGroup>
 
 
         )
@@ -80,6 +90,6 @@ startTest:state.startTest
 
     });
 
-const mapDispatchToProps = dispatch => bindActionCreators({getTopicTestRequest,startTestRequest }, dispatch);
+const mapDispatchToProps = dispatch => bindActionCreators({getTopicTestRequest,startTestRequest, checkTestRequest, nextTestRequest }, dispatch);
 
 export default connect(mapStateToProps, mapDispatchToProps)(PassingTests);

+ 2 - 1
src/configs/routerConfig.js

@@ -9,6 +9,7 @@ const AddDeleteCategory = lazy(()=> import('../components/admin/addDeleteCategor
 const CreateTest = lazy(()=> import('../components/admin/CreateTest'));
 const ChangeTest = lazy(()=>import('../components/admin/getChangeDeleteTest/index'))
 const PassingTests =lazy(()=>import('../components/user/Test/index'))
+const Category =lazy(()=>import('../components/user/Categoty'))
 
 const SignIn = lazy(() => import('../components/public/SignIn/index'));
 const SignUp = lazy(() => import('../components/public/SignUp/index'));
@@ -40,7 +41,7 @@ export default [
     {
         path: routes.CATEGORIES,
         access: 'user-only',
-        component: () => <div>categories</div>
+        component: Category
     },
     {
         path: routes.PROFILE,

+ 11 - 1
src/constants/user.js

@@ -18,4 +18,14 @@ export const GET_TOPIC_TEST_REQUEST_FAILURE = 'GET_TOPIC_TEST_REQUEST_FAILURE';
 export const START_TEST='https://test-app-a-level.herokuapp.com/statistics/start'
 export const START_TEST_REQUEST = 'START_TEST_REQUEST';
 export const START_TEST_REQUEST_SUCCESS = 'START_TEST_REQUEST_SUCCESS';
-export const START_TEST_REQUEST_FAILURE = 'START_TEST_REQUEST_FAILURE';
+export const START_TEST_REQUEST_FAILURE = 'START_TEST_REQUEST_FAILURE';
+
+export const CHECK_TEST='https://test-app-a-level.herokuapp.com/statistics/check'
+export const CHECK_TEST_REQUEST = 'CHECK_TEST_REQUEST';
+export const CHECK_TEST_REQUEST_SUCCESS = 'CHECK_TEST_REQUEST_SUCCESS';
+export const CHECK_TEST_REQUEST_FAILURE = 'CHECK_TEST_REQUEST_FAILURE';
+
+export const NEXT_TEST='https://test-app-a-level.herokuapp.com/statistics/next'
+export const NEXT_TEST_REQUEST = 'NEXT_TEST_REQUEST';
+export const NEXT_TEST_REQUEST_SUCCESS = 'NEXT_TEST_REQUEST_SUCCESS';
+export const NEXT_TEST_REQUEST_FAILURE = 'NEXT_TEST_REQUEST_FAILURE';

+ 0 - 34
src/reducers/admin/index.js

@@ -1,34 +0,0 @@
-// import * as actionTypes from './../../constants/auth';
-// import initialState from './../initialState';
-
-// export default function createCategoryReducer(state = initialState.categ, {type, payload, error}) {
-//     switch(type) {
-//         case actionTypes.SIGN_UP_REQUEST: {
-//             return {
-//                 ...state,
-//                 isFetching: true
-//             }
-//         }
-        
-//         case actionTypes.SIGN_UP_REQUEST_SUCCESS: {
-//             return {
-//                 ...state,
-//                 isFetching: false,
-//                 isSuccessful: true
-//             }
-//         }
-
-//         case actionTypes.SIGN_UP_REQUEST_FAILURE: {
-//             return {
-//                 ...state,
-//                 isFetching: false,
-//                 isSuccessful: false,
-//                 error
-//             }
-//         }
-
-//         default: {
-//             return state;
-//         }
-//     }
-// }

+ 0 - 1
src/reducers/admin/test/changeUser.js

@@ -4,7 +4,6 @@ import initialState from '../../initialState';
 export default function changeUserReducer(state = initialState.changeUser, {  type, payload }) {
     switch (type) {
         case actionTypes.CHANGE_USERS_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: false,

+ 0 - 1
src/reducers/admin/test/deleteUsers.js

@@ -4,7 +4,6 @@ import initialState from '../../initialState';
 export default function changeEmailReducer(state = initialState.deleteUsers, {  type, payload }) {
     switch (type) {
         case actionTypes.DELETE_USERS_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: false,

+ 3 - 1
src/reducers/index.js

@@ -18,7 +18,8 @@ import newTopic from './admin/test/newTopic';
 import changeCategory from './admin/changeCategory';
 import arrayQuestions from './admin/test/getQuestions';
 
-import topicTest from './user/getTopicTest'
+
+import topicTest from './user/getTopicTest';
 import chageLoginReducer from './user/chageLogin';
 import changeEmailReducer from './user/changeEmail';
 import myUser from './user/myUser'
@@ -27,6 +28,7 @@ import startTest from './user/startTest'
 
 export default combineReducers({
     signIn,
+    signUp,
     chageLoginReducer,
     changeEmailReducer,
     form,

+ 5 - 0
src/reducers/initialState.js

@@ -20,6 +20,11 @@ export default {
         data: null,
         error: null
     },
+    signUp: {
+        isFetching: false,
+        data: null,
+        error: null
+    },
     category: {
         data: null,
         isFetching: false,

+ 0 - 1
src/reducers/user/chageLogin.js

@@ -4,7 +4,6 @@ import initialState from './../initialState';
 export default function chageLoginReducer(state = initialState.changeLogin, {  type, payload }) {
     switch (type) {
         case actionTypes.CHANGE_LOGIN_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: true,

+ 0 - 1
src/reducers/user/changeEmail.js

@@ -4,7 +4,6 @@ import initialState from './../initialState';
 export default function changeEmailReducer(state = initialState.changeEmail, {  type, payload }) {
     switch (type) {
         case actionTypes.CHANGE_EMAIL_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: true,

+ 0 - 1
src/reducers/user/myUser.js

@@ -4,7 +4,6 @@ import initialState from './../initialState';
 export default function myUser(state = initialState.myUser, {  type, payload }) {
     switch (type) {
         case actionTypes.MY_USER_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: true,

+ 8 - 1
src/reducers/user/startTest.js

@@ -4,7 +4,6 @@ import initialState from '../initialState';
 export default function startTest(state = initialState.startTest, {  type, payload }) {
     switch (type) {
         case actionTypes.START_TEST_REQUEST: {
-            console.log(payload)
             return {
                 ...state,
                 isFetching: true,
@@ -19,6 +18,14 @@ export default function startTest(state = initialState.startTest, {  type, paylo
                 data:data
             }
         }
+        case actionTypes.NEXT_TEST_REQUEST_SUCCESS: {
+            const {data} =payload
+            return {
+                ...state,
+                isFetching: false,
+                data:data
+            }
+        }
         case actionTypes.START_TEST_REQUEST_FAILURE: {
             const { error } = payload;
             return {

+ 0 - 1
src/sagas/admin/category/createCategory.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* ({payload:{name}}) {
-    console.log(name)
     try {
         const config = {
             headers: {

+ 0 - 1
src/sagas/admin/category/deleteCategory.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* ({payload:{id}}) {
-    console.log(id, getItem)
     try {
         const config = {
             headers: {

+ 0 - 1
src/sagas/admin/test/changeTest.js

@@ -55,7 +55,6 @@ export default function* ( {payload:{name,categoryId,description,question,simple
 
 
         const answer = yield all(answers.map(el => {
-            console.log(el. price, el.correct, el.answer)
             return call(axios, {
                 url: `${CREATE_ANSVERS}/${el._id}`,
                 method: 'PUT',

+ 0 - 3
src/sagas/admin/test/createTest.js

@@ -9,7 +9,6 @@ const getItem = localStorage.getItem(storageKey);
 
 export default function* ({ payload: { questions, array, simple, _id } }) {
     try {
-        console.log(questions, array, simple, _id)
 
         const headers = {
             "Content-Type": "application/json",
@@ -34,12 +33,10 @@ export default function* ({ payload: { questions, array, simple, _id } }) {
 
 
         const { data: { question } } = questionses;
-        console.log(typeof( question._id))
 
         yield put(createQuestionSuccess(questionses));
 
         const responses = yield all(array.map(el => {
-            console.log(el. price, el.correct, el.answer)
             return call(axios, {
                 url: CREATE_ANSVERS,
                 method: 'POST',

+ 0 - 1
src/sagas/admin/test/getAnswers.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* ({payload:{value}}) {
-    console.log(value)
     try {
          
         const config ={

+ 0 - 1
src/sagas/admin/users/changeUser.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* ({payload:{name, email, newPassword, _id, confirmPassword}}) {
-    console.log(name, newPassword,email, _id)
     try {
         const config = {
             headers: {

+ 0 - 1
src/sagas/admin/users/getUser.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* (payload) {
-    console.log(payload)
     try {
         const config = {
             headers: {

+ 0 - 1
src/sagas/user/myUser.js

@@ -9,7 +9,6 @@ const getItem = localStorage.getItem(storageKey);
 
 
 export default function* (payload) {
-    console.log('User inside the worker-saga',getItem);
     try {
         const config = {
             headers: {

+ 38 - 0
src/sagas/user/test/checkTest.js

@@ -0,0 +1,38 @@
+import { put, call, all } from 'redux-saga/effects';
+import axios from 'axios';
+
+import { CHECK_TEST } from '../../../constants/user';
+import { checkTestSuccess, checkTestFailure } from '../../../actions/user/test/checkTest';
+import storageKey from '../../../utils/storageKey';
+
+const getItem = localStorage.getItem(storageKey);
+
+export default function* ({ payload: { _id } }) {
+    try {
+
+
+        const headers = {
+            "Content-Type": "application/json",
+            "Authorization": `Bearer ${getItem}`
+        }
+
+        const check = yield call(
+            axios, {
+                url: CHECK_TEST,
+                method: 'POST',
+                headers,
+                data: {
+                    topicId:_id
+                }
+
+            }
+        )
+
+
+        yield put(checkTestSuccess(check));
+
+    }
+    catch ({ message }) {
+        yield put(checkTestFailure(message));
+    }
+}

+ 5 - 7
src/sagas/user/test/index.js

@@ -3,14 +3,12 @@ import * as actionTypes from '../../../constants/user';
 
 import { takeEvery } from 'redux-saga/effects';
 import getTopicTest from './getTopicTest';
-import startTest from './startTest'
+import startTest from './startTest';
+import checkTest from './checkTest'
+import nextTest from './nextTest';
 export default function* () {
     yield takeEvery(actionTypes.GET_TOPIC_TEST_REQUEST,getTopicTest);
     yield takeEvery(actionTypes.START_TEST_REQUEST,startTest);
-
-
-
-
-
-
+    yield takeEvery(actionTypes.CHECK_TEST_REQUEST,checkTest);
+    yield takeEvery(actionTypes.NEXT_TEST_REQUEST,nextTest);
 }

+ 42 - 0
src/sagas/user/test/nextTest.js

@@ -0,0 +1,42 @@
+import { put, call, all } from 'redux-saga/effects';
+import axios from 'axios';
+
+import { NEXT_TEST } from '../../../constants/user';
+import { nextTestSuccess, nextTestFailure } from '../../../actions/user/test/nextTest';
+import storageKey from '../../../utils/storageKey';
+
+const getItem = localStorage.getItem(storageKey);
+
+export default function* ( {payload:{sessionId,_id,answers, question} }) {
+    try {
+
+
+        const headers = {
+            "Content-Type": "application/json",
+            "Authorization": `Bearer ${getItem}`
+        }
+
+        const next = yield call(
+            axios, {
+                url: NEXT_TEST,
+                method: 'POST',
+                headers,
+                data: {
+                    topicId:_id,
+                    sessionId:sessionId,
+                    prevQuestion:question,
+                    answers:answers
+                    
+                }
+
+            }
+        )
+
+
+        yield put(nextTestSuccess(next));
+
+    }
+    catch ({ message }) {
+        yield put(nextTestFailure(message));
+    }
+}

+ 0 - 1
src/sagas/user/test/startTest.js

@@ -8,7 +8,6 @@ import storageKey from '../../../utils/storageKey';
 const getItem = localStorage.getItem(storageKey);
 
 export default function* ({ payload: { _id } }) {
-    console.log(_id)
     try {
 
 

+ 118 - 1
src/styles/style/_styles.scss

@@ -5,4 +5,121 @@
 }
 button:active, button:focus {
     outline: none !important;
-  }
+  }
+  .slideRight{
+    animation-name: slideRight;
+    -webkit-animation-name: slideRight; 
+ 
+    animation-duration: 2s; 
+    -webkit-animation-duration: 2s;
+ 
+    animation-timing-function: ease-in-out; 
+    -webkit-animation-timing-function: ease-in-out;     
+ 
+    visibility: visible !important; 
+}
+ 
+@keyframes slideRight {
+    0% {
+        transform: translateX(-150%);
+    }
+    50%{
+        transform: translateX(8%);
+    }
+    65%{
+        transform: translateX(-4%);
+    }
+    80%{
+        transform: translateX(4%);
+    }
+    95%{
+        transform: translateX(-2%);
+    }           
+    100% {
+        transform: translateX(0%);
+    }   
+}
+ 
+@-webkit-keyframes slideRight {
+    0% {
+        -webkit-transform: translateX(-150%);
+    }
+    50%{
+        -webkit-transform: translateX(8%);
+    }
+    65%{
+        -webkit-transform: translateX(-4%);
+    }
+    80%{
+        -webkit-transform: translateX(4%);
+    }
+    95%{
+        -webkit-transform: translateX(-2%);
+    }           
+    100% {
+        -webkit-transform: translateX(0%);
+    }
+}
+.slideLeft{
+    animation-name: slideLeft;
+    -webkit-animation-name: slideLeft;  
+ 
+    animation-duration: 2s; 
+    -webkit-animation-duration: 2s;
+ 
+    animation-timing-function: ease-in-out; 
+    -webkit-animation-timing-function: ease-in-out;     
+ 
+    visibility: visible !important; 
+}
+ 
+@keyframes slideLeft {
+    0% {
+        transform: translateX(150%);
+    }  
+    100% {
+        transform: translateX(0%);
+    }
+}
+ 
+@-webkit-keyframes slideLeft {
+    0% {
+        -webkit-transform: translateX(150%);
+    }
+      
+    100% {
+        -webkit-transform: translateX(0%);
+    }
+}
+.slideDown{
+    animation-name: slideDown;
+    -webkit-animation-name: slideDown;  
+ 
+    animation-duration: 1s; 
+    -webkit-animation-duration: 1s;
+ 
+    animation-timing-function: ease;    
+    -webkit-animation-timing-function: ease;    
+ 
+    visibility: visible !important;                     
+}
+ 
+@keyframes slideDown {
+    0% {
+        transform: translateY(-100%);
+    }
+         
+    100% {
+        transform: translateY(0%);
+    }       
+}
+ 
+@-webkit-keyframes slideDown {
+    0% {
+        -webkit-transform: translateY(-100%);
+    }
+     
+    100% {
+        -webkit-transform: translateY(0%);
+    }   
+}