Svetlana %!s(int64=5) %!d(string=hai) anos
pai
achega
9ec86bb9ff

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

@@ -0,0 +1,16 @@
+import * as types from '../../../constants';
+
+export const createTestRequest = payload => ({
+    type: types.CREATE_TEST_REQUEST,
+    payload
+})
+
+export const createTestRequestSucces = payload => ({
+    type: types.CREATE_TEST_REQUEST_SUCCESS,
+    payload
+})
+
+export const createTestRequestFailure = error => ({
+    type: types.CREATE_TEST_REQUEST_FAILURE,
+    error
+})

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

@@ -2,12 +2,12 @@ import React from 'react';
 import * as routes from './../../../constants/routes';
 import { lazy } from 'react';
 
+const CreateTest = lazy(()=> import('../../user-components/admin-components/createTestForm'))
 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'));
 const SignUpPage =     lazy(() => import('./../../../containers/auth/SignUpPage'));
-const CreateTestForm = lazy(() => import('./../../user-components/admin-components/createTestForm'));
 const ProfilePage =    lazy(() => import('./../../user-components/profilePage'));
 const CategoriesPage = lazy(() => import('./../../user-components/categoriesPage'));
 const CardsPage =      lazy(() => import('./../../user-components/CardsPage'));
@@ -54,6 +54,11 @@ export default [
         access: 'admin-only',
         component: DeleteUsers
     },
+    {
+        path: routes.CREATE_TEST ,
+        access: 'admin-only',
+        component: CreateTest
+    },
     {
         access: 'public',
         component: NotFound

+ 48 - 0
src/components/user-components/admin-components/createTestForm/createTestForms/index.js

@@ -0,0 +1,48 @@
+import React from 'react';
+import { reduxForm, Field } from 'redux-form';
+import validate from '../validate';
+import formInput from './../../../../common/formInput'
+
+class CreateTestForm extends React.Component {
+    sendRequest(values) {
+        console.log('sendRequest createTestForm page values:', values);
+    }
+
+    render() {
+        const { handleSubmit } = this.props;
+
+        return (
+            <form className="page" onSubmit={handleSubmit(this.sendRequest)}>
+                <h2>Make a title-page for your test!</h2>
+
+                <div className="title-page__block">
+                    <p className="titles">Title</p>
+                    <Field
+                        className="title-page__block"
+                        name="title"
+                        type="input"
+                        placeholder=""
+                        component={formInput}
+                    />
+                </div>
+
+                <div className="title-page__block">
+                    <p className="titles">Description</p>
+                    <Field name="description" type="input" placeholder="" className="" component={formInput} />
+                </div>
+
+                <div className="title-page__block">
+                    <p className="titles">Cover image</p>
+                    <Field name="cover" type="file" placeholder="" className="" component="textarea" />
+                </div>
+
+                <button className="">Create card</button>
+            </form>
+        )
+    }   
+}
+
+export default reduxForm({
+    form: "createTest",
+    validate
+})(CreateTestForm)

+ 8 - 29
src/components/user-components/admin-components/createTestForm/index.js

@@ -1,9 +1,11 @@
 import React from 'react';
 import { reduxForm, Field } from 'redux-form';
 import validate from './validate';
-import formInput from './../../../common/formInput'
+import formInput from './../../../common/formInput';
+import CreateTestForm from './createTestForms'
 
-class Form extends React.Component {
+
+class CreateTest extends React.Component {
     sendRequest(values) {
         console.log('sendRequest createTestForm page values:', values);
     }
@@ -12,32 +14,9 @@ class Form extends React.Component {
         const { handleSubmit } = this.props;
 
         return (
-            <form className="page" onSubmit={handleSubmit(this.sendRequest)}>
-                <h2>Make a title-page for your test!</h2>
-
-                <div className="title-page__block">
-                    <p className="titles">Title</p>
-                    <Field
-                        className="title-page__block"
-                        name="title"
-                        type="input"
-                        placeholder=""
-                        component={formInput}
-                    />
-                </div>
-
-                <div className="title-page__block">
-                    <p className="titles">Description</p>
-                    <Field name="description" type="input" placeholder="" className="" component={formInput} />
-                </div>
-
-                <div className="title-page__block">
-                    <p className="titles">Cover image</p>
-                    <Field name="cover" type="file" placeholder="" className="" component="textarea" />
-                </div>
-
-                <button className="">Create card</button>
-            </form>
+            <div className = "page">
+                <CreateTestForm></CreateTestForm>
+            </div>
         )
     }   
 }
@@ -45,4 +24,4 @@ class Form extends React.Component {
 export default reduxForm({
     form: "createTest",
     validate
-})(Form)
+})(CreateTest)

+ 24 - 7
src/components/user-components/profilePage/index.js

@@ -11,8 +11,19 @@ import ChangeLogin from './LoginFild';
 import ChangePassword from './PasswordFields'
 
 // redux-connected container
+const user = {
+    "data": {
+        "_id": "5c48461c40ca670017ba5974",
+        "name": "Debil",
+        "email": "superus@lol.com",
+        "password": "$2a$10$qoxrQ2Sp3BDTLa9Xdc0ZPuLVHamipMQRWxeWxw1RwthICnbPoFLvC",
+        "profilePhoto": "",
+        "role": 0
+    },
+    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjNDg0NjFjNDBjYTY3MDAxN2JhNTk3NCIsInJvbGUiOjAsImlhdCI6MTU0ODI1NTczMiwiZXhwIjoxNTQ4MzQyMTMyfQ.RAIiCLjBJ2u1VEQWy1oUgPjHj0dZRG27l0J3c8FDss0"
+}
 
-class profilePage extends React.Component {
+class ProfilePage extends React.Component {
 
     state = {
         files: null,
@@ -49,21 +60,26 @@ class profilePage extends React.Component {
 
 
     render() {
-        const { user:{data},users, userChangeRequest,passwordChangeRequest } = this.props;
-
-        // console.log('User', users);
+        const { users, userChangeRequest,passwordChangeRequest } = this.props;
+        const {data} = user
+        console.log('User', data);
         // console.log('Props', this.props);
         // console.log('State', this.state);
 
         return (
             <div className="page page--bottom-only profile-page">
                 <section className="container section section--about">
+                    <img src =" https://cdn.iconscout.com/icon/free/png-256/avatar-373-456325.png" ></img>
                     {/* <h2 className="section__element section__element--header">{data.login}</h2> */}
-
+                    <section className="container section section--about">
+                    <div className="sedtion__element section__element--login">
+                        <h3>Name</h3>
+                        <p>{data.name}</p>
+                    </div>
                     <div className="sedtion__element section__element--login">
                         <h3>Email</h3>
                         {/* <p>{user.login}<button className="link link--btn right" >Change login</button></p> */}
-                        <ChangeLogin className="link link--btn right" data={data} actions={{ userChangeRequest }}>{data.login}</ChangeLogin>
+                        <ChangeLogin className="link link--btn right" data={data} actions={{ userChangeRequest }}>{data.email}</ChangeLogin>
                     </div>
                     <div className="section__element section__element--">
                         <h3>Password</h3>
@@ -73,6 +89,7 @@ class profilePage extends React.Component {
                         <h3>Status</h3>
                         <p>{data.description}</p>
                     </div>
+                    </section>
                 </section>
                 <section className="container section section--stats">
                     <div className="section__element section__element--">
@@ -108,5 +125,5 @@ const
 
 const mapDispatchToProps = dispatch => bindActionCreators({ userChangeRequest, passwordChangeRequest }, dispatch);
 
-export default connect(mapStateToProps, mapDispatchToProps)(profilePage);
+export default connect(mapStateToProps, mapDispatchToProps)(ProfilePage);
 

+ 5 - 1
src/constants/index.js

@@ -41,4 +41,8 @@ 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';
+export const DELETE_USER_REQUEST_FAILURE = 'DELETE_USER_REQUEST_FAILURE';
+
+export const CREATE_TEST_REQUEST = 'CREATE_TEST_REQUEST';
+export const CREATE_TEST_REQUEST_SUCCESS = 'CREATE_TEST_REQUEST_SUCCESS';
+export const CREATE_TEST_REQUEST_FAILURE = 'CREATE_TEST_REQUEST_FAILURE';

+ 0 - 0
src/saga/admin/createTest/quiz/index.js