Commit 9e4212b9 authored by zarina's avatar zarina 🌊

рефактор кода

parent 1026abcd
...@@ -9,6 +9,7 @@ import Register from "./Register/Register"; ...@@ -9,6 +9,7 @@ import Register from "./Register/Register";
import Login from "./Login/Login"; import Login from "./Login/Login";
import AddProductForm from "./AddProductForm/AddProductForm"; import AddProductForm from "./AddProductForm/AddProductForm";
import {logoutUser} from "../store/actions/usersActions"; import {logoutUser} from "../store/actions/usersActions";
import FullProduct from "./FullProduct/FullProduct";
class App extends Component { class App extends Component {
...@@ -31,6 +32,7 @@ class App extends Component { ...@@ -31,6 +32,7 @@ class App extends Component {
<Route path="/register" exact component={Register} /> <Route path="/register" exact component={Register} />
<Route path="/login" exact component={Login} /> <Route path="/login" exact component={Login} />
<Route path="/products/new" exact component={AddProductForm} /> <Route path="/products/new" exact component={AddProductForm} />
<Route path="/products/:id" exact component={FullProduct} />
</Switch> </Switch>
</Container> </Container>
</main> </main>
......
...@@ -52,7 +52,7 @@ class Register extends Component { ...@@ -52,7 +52,7 @@ class Register extends Component {
label="Display name" label="Display name"
onChange={this.inputChangeHandler} onChange={this.inputChangeHandler}
value={this.state.displayName} value={this.state.displayName}
required={false} required={true}
type="text" type="text"
error={this.getFieldError("displayName")} error={this.getFieldError("displayName")}
/> />
...@@ -61,7 +61,7 @@ class Register extends Component { ...@@ -61,7 +61,7 @@ class Register extends Component {
label="Phone number" label="Phone number"
onChange={this.inputChangeHandler} onChange={this.inputChangeHandler}
value={this.state.phone} value={this.state.phone}
required={false} required={true}
type="text" type="text"
error={this.getFieldError("phone")} error={this.getFieldError("phone")}
/> />
......
...@@ -61,7 +61,6 @@ export const createProduct = product => { ...@@ -61,7 +61,6 @@ export const createProduct = product => {
return (dispatch, getState) => { return (dispatch, getState) => {
const token = getState().users.user.token; const token = getState().users.user.token;
const headers = {Token: token}; const headers = {Token: token};
console.log(product)
return axios.post("/products", product, {headers}) return axios.post("/products", product, {headers})
.then(() => { .then(() => {
dispatch(push('/')); dispatch(push('/'));
...@@ -78,7 +77,6 @@ export const deleteProduct = id => { ...@@ -78,7 +77,6 @@ export const deleteProduct = id => {
return (dispatch, getState) => { return (dispatch, getState) => {
const token = getState().users.user.token; const token = getState().users.user.token;
const headers = {Token: token}; const headers = {Token: token};
console.log(headers)
axios.delete('/products/' + id, {headers}) axios.delete('/products/' + id, {headers})
.then(() => { .then(() => {
dispatch(push('/')); dispatch(push('/'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment