Svetlana %!s(int64=6) %!d(string=hai) anos
pai
achega
03c5a00ed8

+ 1 - 0
debug.log

@@ -0,0 +1 @@
+[0109/234712.714:ERROR:settings.cc(319)] Settings magic is not 1129342067

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 5948 - 3937
package-lock.json


+ 1 - 1
package.json

@@ -14,7 +14,7 @@
     "react-loader-spinner": "^2.3.0",
     "react-redux": "^6.0.0",
     "react-router-dom": "^4.3.1",
-    "react-scripts": "2.1.1",
+    "react-scripts": "^2.1.3",
     "redux": "^4.0.1",
     "redux-form": "^8.0.4",
     "redux-logger": "^3.0.6",

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

@@ -1,9 +1,11 @@
 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
+    ...signOutActions,
+    ...usersGetActions
 }

+ 18 - 0
src/actions/auth/users/users.js

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

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

@@ -11,9 +11,7 @@ export default function validate(values) {
     else if (login.length < 8 || login.length > 20) {
         errors.login = "Invalid login length: login should be from 8 to 20 symbols";
     }
-    else if (!/^[a-z0-9_-]{8,20}$/i.test(login)) {
-        errors.login = "Invalid login, try another one";
-    }
+
     
     if (!password) {
         errors.password = "Required"

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

@@ -1,7 +1,7 @@
 import React, { Component } from 'react';
 import { Link } from "react-router-dom";
 import * as routes from './../../../constants/routes';
-import { UserContext } from './../../../containers/Header';
+import { UserContext } from './../../../containers/header';
 
 export default class header extends Component {
 

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

@@ -15,7 +15,11 @@ class profilePage extends React.Component {
     getUser = () => {
         const randomUserId = Math.ceil(Math.random() * 10);
 
-        axios.get(`http://127.0.0.1:2000/api/users?id=${randomUserId}`)
+        axios.post(`https://quiz.maxcrc.de/api/v1/user`,{
+            "login": 'ddd',
+            "password":"jhgfhgg"
+
+        })
             .then(({ data }) => this.setState({
                 user: data
             }))
@@ -34,7 +38,7 @@ class profilePage extends React.Component {
         return (
             <div className="page page--bottom-only profile-page">
                 <section className="container section section--about">
-                    <h2 className="section__element section__element--header">{user.name}</h2>
+                    <h2 className="section__element section__element--header">{user.login}</h2>
                     <img className="section__element section__element--image" src={user.avatar} alt="avatar" />
                     <div className="sedtion__element section__element--login">
                         <h3>Login</h3>

+ 4 - 0
src/constants/index.js

@@ -12,3 +12,7 @@ export const USER_IS_SIGNED_IN = 'USER_IS_SIGNED_IN';
 export const USER_IS_NOT_SIGNED_IN = 'USER_IS_NOT_SIGNED_IN';
 
 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';

+ 1 - 1
src/containers/auth/SignInPage/index.js

@@ -11,7 +11,7 @@ import SignInForm from './../../../components/public-components/auth/signInForm'
 class SignInPage extends React.Component {
 
     render() {
-        console.log("SignInPage containers props:", this.props);
+        // console.log("SignInPage containers props:", this.props);
         const { signInRequest, user } = this.props;
         return (
             !(user.data)

+ 1 - 1
src/containers/auth/SignUpPage/index.js

@@ -11,7 +11,7 @@ import SignUpForm from './../../../components/public-components/auth/signUpForm'
 class SignUpPage extends React.Component {
 
     render() {
-        console.log("SignInPage containers props:", this.props);
+        // console.log("SignInPage containers props:", this.props);
         const { signUpRequest, user } = this.props;
         return (
             !(user.data)

+ 1 - 1
src/router.js

@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
 
 import * as routes from './constants/routes';
 
-import Header from "./containers/Header";
+import Header from "./containers/header/index";
 import landingPage from './components/public-components/landingPage';
 import Footer from './components/public-components/footer';
 import PrivateRouter from './components/common/privateRouter';

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

@@ -3,10 +3,12 @@ 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);
 }
 
 

+ 6 - 9
src/saga/auth/signIn/index.js

@@ -1,24 +1,21 @@
 import { put, call } from "redux-saga/effects";
 import * as actions from './../../../actions/auth/signIn'
+import axios from 'axios';
 
-import { SIGN_IN_URL } from './../../../constants'
 
 // worker-saga for signing in
 
 export default function* ({ payload: requestBody }) {
     try {
         // console.log('received request body from sign-in worker saga', requestBody);
-        const payload = yield call(() => 
-            fetch(SIGN_IN_URL, {
-                method: 'POST',
-                body: JSON.stringify(requestBody)
-            })
-                .then(res => res.json())
+        const payload = yield call(() =>
+            axios.post(`https://quiz.maxcrc.de/api/v1/user`, {...requestBody})
+                .then(({ data }) => data)
         );
         // console.log("Payload", payload);
         yield put(actions.signInRequestSucces(payload));
     }
-    catch (exception) {
-        yield put(actions.signInRequestFailure(exception.message))
+    catch ({ message }) {
+        yield put(actions.signInRequestFailure(message))
     }
 }

+ 5 - 4
src/saga/auth/signUp/index.js

@@ -1,5 +1,6 @@
 import { put, call } from "redux-saga/effects";
 import * as actions from './../../../actions/auth/signUp'
+import axios from 'axios';
 
 import { SIGN_UP_URL } from '../../../constants'
 
@@ -8,11 +9,11 @@ import { SIGN_UP_URL } from '../../../constants'
 export default function* ({ payload: requestBody }) {
     try {
         const payload = yield call(() => 
-        fetch(SIGN_UP_URL, {
-            method: 'POST',
-            body: JSON.stringify(requestBody)
+        axios.post(`https://quiz.maxcrc.de/api/v1/user`, {
+            ...requestBody
         })
-            .then(res => res.json())
+            .then(({ data }) => data)
+
     );
         yield put(actions.signUpRequestSucces(payload));
     }

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

@@ -0,0 +1,20 @@
+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 {
+        // console.log('received request body from sign-in worker saga', requestBody);
+        const payload = yield call(() =>
+            axios.get(`https://quiz.maxcrc.de/api/v1/user`)
+                .then(({ data }) => data)
+        );
+        // console.log("Payload", payload);
+        yield put(actions.usersGetRequestSucces(payload));
+    }
+    catch ({ message }) {
+        yield put(actions.usersGetRequestFailure(message))
+    }
+}