From 15e4ea4159a3528ed81707df829c6115743b6ba4 Mon Sep 17 00:00:00 2001 From: Eray C Date: Mon, 1 Nov 2021 19:25:36 +0100 Subject: [PATCH] ref: Small changes to temporarily hide errors --- src/Order.jsx | 238 ++++++++++++++++++------------------- src/components/Button.jsx | 2 +- src/views/ChooseBread.jsx | 29 +---- src/views/ChooseMeat.jsx | 5 +- src/views/ChooseSauces.jsx | 17 ++- 5 files changed, 140 insertions(+), 151 deletions(-) diff --git a/src/Order.jsx b/src/Order.jsx index 168393a..3356ebf 100644 --- a/src/Order.jsx +++ b/src/Order.jsx @@ -1,131 +1,131 @@ -import { useState } from "react"; -import * as Data from "./Data"; -import { BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; +// import { useState } from "react"; +// import * as Data from "./data"; +// // import { BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; -export function OrderForm(props) { - const ingredients = { - sauces: [...Data.defaultBreads], - meats: [...Data.defaultMeats], - vegetables: [...Data.defaultVegetables], - sauces: [...Data.defaultSauces], - }; +// export function OrderForm(props) { +// const ingredients = { +// sauces: [...Data.defaultBreads], +// meats: [...Data.defaultMeats], +// vegetables: [...Data.defaultVegetables], +// sauces: [...Data.defaultSauces], +// }; - const [selectedProducts, setSelectedProducts] = useState( - ...Data.defaultOrder - ); +// const [selectedProducts, setSelectedProducts] = useState( +// ...Data.defaultOrder +// ); - const [bread, setBread] = useState(""); - const [meat, setMeat] = useState(""); - const [vegetables, setVegetables] = useState(""); - const [sauces, setSauces] = useState(""); +// const [bread, setBread] = useState(""); +// const [meat, setMeat] = useState(""); +// const [vegetables, setVegetables] = useState(""); +// const [sauces, setSauces] = useState(""); - // const [checkedState, setCheckedState] = useState( - // new Array(ingredients.length).fill(false) - // ); +// // const [checkedState, setCheckedState] = useState( +// // new Array(ingredients.length).fill(false) +// // ); - const { onSubmit } = props; +// const { onSubmit } = props; - // const handleOnChange = (position) => { - // const updatedCheckedState = checkedState.map((item, index) => - // index === position ? true : item - // ); +// // const handleOnChange = (position) => { +// // const updatedCheckedState = checkedState.map((item, index) => +// // index === position ? true : item +// // ); - const handleOnSelected = (productSelected) => { - const updatedSelectedProducts = selectedProducts.map((initialProduct) => - initialProduct === productSelected.name ? productSelected = productSelected.value : false - ); +// const handleOnSelected = (productSelected) => { +// const updatedSelectedProducts = selectedProducts.map((initialProduct) => +// initialProduct === productSelected.name ? productSelected = productSelected.value : false +// ); - setSelectedProducts(updatedSelectedProducts); +// setSelectedProducts(updatedSelectedProducts); - // setCheckedState(updatedCheckedState); - // const Finishedsauces = updatedCheckedState.reduce( - // (sauce, currentState, index) => { - // if (currentState === false) { - // switch (ingredients.vegetables) { - // case "salade": - // setSalade(""); - // break; - // case "tomate": - // setTomate(""); - // break; - // case "oignon": - // setOignon(""); - // break; - // default: - // console.log("aucun changement"); - // } - // } - // if (currentState === true) { - // switch (ingredients[index].categorie) { - // case "pains": - // setPain(ingredients[index].name); - // break; - // case "viandes": - // setViande(ingredients[index].name); - // break; - // case "salade": - // setSalade(ingredients[index].name); - // break; - // case "tomate": - // setTomate(ingredients[index].name); - // break; - // case "oignon": - // setOignon(ingredients[index].name); - // break; - // case "sauces": - // if (sauce.length < 2) { - // setSauces((sauce = [...sauce, " " + ingredients[index].name])); - // } - // return sauce; - // default: - // console.log("aucun changement"); - // } - // return sauce; - // } - // return sauce; - // }, - // ); +// // setCheckedState(updatedCheckedState); +// // const Finishedsauces = updatedCheckedState.reduce( +// // (sauce, currentState, index) => { +// // if (currentState === false) { +// // switch (ingredients.vegetables) { +// // case "salade": +// // setSalade(""); +// // break; +// // case "tomate": +// // setTomate(""); +// // break; +// // case "oignon": +// // setOignon(""); +// // break; +// // default: +// // console.log("aucun changement"); +// // } +// // } +// // if (currentState === true) { +// // switch (ingredients[index].categorie) { +// // case "pains": +// // setPain(ingredients[index].name); +// // break; +// // case "viandes": +// // setViande(ingredients[index].name); +// // break; +// // case "salade": +// // setSalade(ingredients[index].name); +// // break; +// // case "tomate": +// // setTomate(ingredients[index].name); +// // break; +// // case "oignon": +// // setOignon(ingredients[index].name); +// // break; +// // case "sauces": +// // if (sauce.length < 2) { +// // setSauces((sauce = [...sauce, " " + ingredients[index].name])); +// // } +// // return sauce; +// // default: +// // console.log("aucun changement"); +// // } +// // return sauce; +// // } +// // return sauce; +// // }, +// // ); - setSauces(Finishedsauces); - }; +// setSauces(Finishedsauces); +// }; - const handleSubmit = (event) => { - event.preventDefault(); - onSubmit({ pain, viande, salade, tomate, oignon, sauces }); - }; +// const handleSubmit = (event) => { +// event.preventDefault(); +// onSubmit({ pain, viande, salade, tomate, oignon, sauces }); +// }; - return ( - - ); -} -export default OrderForm; +// return ( +// +// ); +// } +// export default OrderForm; diff --git a/src/components/Button.jsx b/src/components/Button.jsx index c377125..f3389a0 100644 --- a/src/components/Button.jsx +++ b/src/components/Button.jsx @@ -22,7 +22,7 @@ export const buttonClassNames = [ export class Button extends React.Component { render() { return ( -
+
Suivant
); diff --git a/src/views/ChooseBread.jsx b/src/views/ChooseBread.jsx index 403de4b..cec86a0 100644 --- a/src/views/ChooseBread.jsx +++ b/src/views/ChooseBread.jsx @@ -1,6 +1,5 @@ import * as React from "react"; -// import { Redirect } from "react-router"; -// import { useState } from "react"; + import "../index.css"; import { IngredientBox } from "../components/IngredientBox"; @@ -8,22 +7,13 @@ import { OrderSummary } from "./OrderSummary"; import { Button } from "../components/Button"; import { defaultBreads } from "../data"; -export class ChooseBread extends React.Component { - constructor(props) { - super(props); - this.state = { ...this.props.order }; - } +// import { selectedProducts } from "../Order"; - onBreadSelection = () => { - const { bread } = this.state; - console.log(bread); - this.setState({ ...this.state, currentOrder: {...this.state.currentOrder, bread: bread.name }}); - }; +export function ChooseBread(props) { - render() { - return ( -
-
+ return ( + ); } -} diff --git a/src/views/ChooseMeat.jsx b/src/views/ChooseMeat.jsx index beb6bb5..bedbee4 100644 --- a/src/views/ChooseMeat.jsx +++ b/src/views/ChooseMeat.jsx @@ -1,14 +1,15 @@ import * as React from "react"; -import { BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; +// import { BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; import "../index.css"; import { IngredientBox } from "../components/IngredientBox"; +import { meat, setMeat } from "../Order"; import { Button } from "../components/Button"; import { defaultMeats } from "../data"; -export function ChooseBread(props) { +export function ChooseMeat(props) { return (
diff --git a/src/views/ChooseSauces.jsx b/src/views/ChooseSauces.jsx index d11e875..8bea8b6 100644 --- a/src/views/ChooseSauces.jsx +++ b/src/views/ChooseSauces.jsx @@ -1,27 +1,32 @@ import * as React from "react"; import "../index.css"; -import { buttonClassNames } from "../components/Button"; - +import { Button, buttonClassNames } from "../components/Button"; import { IngredientBox } from "../components/IngredientBox"; -import { Button } from "../components/Button"; + +// import { selectedProducts, setSelectedProducts } from "../Order"; +// import { sauces, setSauces } from "../Order"; import { defaultSauces } from "../data"; export function ChooseSauces(props) { + return (
+
Des sauces pour donner de la couleur à cette magie ?
+
- {defaultSauces.map((veg) => ( + {defaultSauces.map((s) => (
- +
))}
-
Choisir sans sauce
+ +
Choisir sans sauce