From 7749d4a594f3501e56424d4875387b3db4219fcc Mon Sep 17 00:00:00 2001 From: Eray C Date: Mon, 1 Nov 2021 15:46:21 +0100 Subject: [PATCH] ref: Convert classes to functions on views --- src/views/ChooseBread.jsx | 1 + src/views/ChooseMeat.jsx | 53 +++++++++++++++------------------- src/views/ChooseSauces.jsx | 45 +++++++++++------------------ src/views/ChooseVegetables.jsx | 48 ++++++++++++++---------------- src/views/OrderSummary.jsx | 33 +++++++++------------ 5 files changed, 76 insertions(+), 104 deletions(-) diff --git a/src/views/ChooseBread.jsx b/src/views/ChooseBread.jsx index 9cdf7b2..403de4b 100644 --- a/src/views/ChooseBread.jsx +++ b/src/views/ChooseBread.jsx @@ -16,6 +16,7 @@ export class ChooseBread extends React.Component { onBreadSelection = () => { const { bread } = this.state; + console.log(bread); this.setState({ ...this.state, currentOrder: {...this.state.currentOrder, bread: bread.name }}); }; diff --git a/src/views/ChooseMeat.jsx b/src/views/ChooseMeat.jsx index cba1c8b..beb6bb5 100644 --- a/src/views/ChooseMeat.jsx +++ b/src/views/ChooseMeat.jsx @@ -1,4 +1,6 @@ import * as React from "react"; +import { BrowserRouter, Route, NavLink, Switch } from "react-router-dom"; + import "../index.css"; import { IngredientBox } from "../components/IngredientBox"; @@ -6,35 +8,26 @@ import { Button } from "../components/Button"; import { defaultMeats } from "../data"; -export class ChooseMeat extends React.Component { - constructor(props) { - super(props); - this.state = { ...this.props.order }; - } - - render() { - return ( -
-
- Passons à la viande... ou au tofu ? -
-
- {defaultMeats.map((meat) => ( - - ))} -
-
-
+export function ChooseBread(props) { + return ( +
+
+ Passons à la viande... ou au tofu ? +
+
+ {defaultMeats.map((meat) => ( + + ))} +
+
+
- ); - } +
+ ); } diff --git a/src/views/ChooseSauces.jsx b/src/views/ChooseSauces.jsx index 8ed5017..d11e875 100644 --- a/src/views/ChooseSauces.jsx +++ b/src/views/ChooseSauces.jsx @@ -8,34 +8,23 @@ import { Button } from "../components/Button"; import { defaultSauces } from "../data"; -export class ChooseSauces extends React.Component { - constructor(props) { - super(props); - this.state = { ...this.props.order }; - } - - render() { - const classNames = [...buttonClassNames, "border-red-1000", "my-5", "font-semibold"] - - return ( -
-
- Des sauces pour donner de la couleur à cette magie ? -
-
- {defaultSauces.map((veg) => ( -
+export function ChooseSauces(props) { + return ( +
+
+ Des sauces pour donner de la couleur à cette magie ? +
+
+ {defaultSauces.map((veg) => ( +
-
- ))} -
-
- Choisir sans sauce -
-
-
+
+ ))} +
+
Choisir sans sauce
+
+
- ); - } +
+ ); } diff --git a/src/views/ChooseVegetables.jsx b/src/views/ChooseVegetables.jsx index 0c3009b..5c26017 100644 --- a/src/views/ChooseVegetables.jsx +++ b/src/views/ChooseVegetables.jsx @@ -8,32 +8,28 @@ import { Button } from "../components/Button"; import { defaultVegetables } from "../data"; -export class ChooseVegetables extends React.Component { - constructor(props) { - super(props); - this.state = { ...this.props.order }; - } +export function ChooseVegetables(props) { + const classNames = [ + ...buttonClassNames, + "border-red-1000", + "my-5", + "font-semibold", + ]; - render() { - const classNames = [...buttonClassNames, "border-red-1000", "my-5", "font-semibold"] - - return ( -
-
- Des crudités pour votre merveille ? -
-
- {defaultVegetables.map((veg) => ( - - ))} -
-
- Je continue sans crudités -
-
-
+ return ( +
+
+ Des crudités pour votre merveille ?
- ); - } +
+ {defaultVegetables.map((veg) => ( + + ))} +
+
Je continue sans crudités
+
+
+
+ ); } diff --git a/src/views/OrderSummary.jsx b/src/views/OrderSummary.jsx index 9c500da..02597fa 100644 --- a/src/views/OrderSummary.jsx +++ b/src/views/OrderSummary.jsx @@ -4,25 +4,18 @@ import "../index.css"; import { Button } from "../components/Button"; -export class OrderSummary extends React.Component { - constructor(props) { - super(props); - this.state = { ...this.props.order } - } - - render() { - return ( -
-
- Récapitulons votre commande... -
-
- {this.state.currentOrder.bread} -
-
-
+export function OrderSummary(props) { + return ( +
+
+ Récapitulons votre commande... +
+
+ {this.state.currentOrder.bread} +
+
+
- ); - } +
+ ); }