diff --git a/src/App.js b/src/App.js index 93f43a1..e396fe6 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,7 @@ import React, { Component } from "react"; import { BrowserRouter, Route } from "react-router-dom"; import Home from "./pages/Home"; -// import NewProduct from "./pages/NewProduct"; +import NewProduct from "./pages/NewProduct"; import * as api from "./api"; @@ -228,13 +228,8 @@ class App extends Component { } render() { - const { - cartItems, - products, - isLoading, - hasError, - loadingError, - } = this.state; + const { cartItems, products, isLoading, hasError, loadingError } = + this.state; return ( @@ -258,7 +253,18 @@ class App extends Component { /> )} /> - {/* route path="/new-product" */} + { + return ( + + ); + }} + > ); } diff --git a/src/components/NewProductForm/NewProductForm.js b/src/components/NewProductForm/NewProductForm.js index 053cd5c..64390ab 100644 --- a/src/components/NewProductForm/NewProductForm.js +++ b/src/components/NewProductForm/NewProductForm.js @@ -1,5 +1,5 @@ import React, { Component } from "react"; -// import { Redirect } from "react-router-dom"; +import { Redirect } from "react-router-dom"; import { v4 as uuid } from "uuid"; import { Formik } from "formik"; @@ -35,17 +35,26 @@ function addProductDetails(product) { // eslint-disable-next-line react/prefer-stateless-function class NewProductForm extends Component { - // ... - // state: { - // submitted: false - // } - // ... + constructor(props) { + super(props); + this.state = { + submitted: false, + }; + this.setSubmitted = this.setSubmitted.bind(this); + } + setSubmitted() { + setTimeout(() => { + this.setState({ + submitted: true, + }); + }, 500); + } render() { - // const { submitted } = this.state; + const { submitted } = this.state; const { saveNewProduct } = this.props; return ( - <> + {({ @@ -183,8 +192,8 @@ class NewProductForm extends Component { )} - {/* {submitted && } */} - > + {submitted && } + ); } } diff --git a/src/pages/Home/Home.js b/src/pages/Home/Home.js index 4ffa9d1..30cf456 100644 --- a/src/pages/Home/Home.js +++ b/src/pages/Home/Home.js @@ -20,7 +20,7 @@ function Home({ handleChange, }) { return ( - <> + @@ -72,7 +72,7 @@ function Home({ - > + ); } diff --git a/src/pages/NewProduct/NewProduct.js b/src/pages/NewProduct/NewProduct.js index 8b1dde7..d8ce47e 100644 --- a/src/pages/NewProduct/NewProduct.js +++ b/src/pages/NewProduct/NewProduct.js @@ -1,5 +1,4 @@ import React from "react"; - import AppHeader from "../../components/AppHeader"; import Footer from "../../components/Footer"; import Main from "../../components/Main"; @@ -7,7 +6,7 @@ import NewProductForm from "../../components/NewProductForm"; function NewProduct({ saveNewProduct }) { return ( - <> + @@ -28,7 +27,7 @@ function NewProduct({ saveNewProduct }) { - > + ); }