Skip to main content

12.05 Navigation Back And To Next Page

CheckoutSummary.js

CheckoutSummary.js
import React from "react";
import Burger from "../../Burger/Burger";
import Button from "../../UI/Button/Button";
import classes from "./CheckoutSummary.module.css";

const checkoutSummary = (props) => {
return (
<div className={classes.CheckoutSummary}>
<h1>We hope it taste well!</h1>
<div style={{ width: "100%", margin: "auto" }}>
<Burger ingredients={props.ingredients} />
</div>
<Button btnType="Danger" clicked={props.checkoutCancelled}>
CANCEL
</Button>
<Button btnType="Success" clicked={props.checkoutContinued}>
CONTINUE
</Button>
</div>
);
};

export default checkoutSummary;

Checkout.js

Checkout.js
import React, { Component } from "react";
import CheckoutSummary from "../../components/Order/CheckoutSummary/CheckoutSummary";

class Checkout extends Component {
state = {
ingredients: {
salad: 1,
meat: 1,
cheese: 1,
bacon: 1,
},
};

checkoutCancelledHandler = () => {
this.props.history.goBack();
};

checkoutContinuedHandler = () => {
this.props.history.replace("/checkout/contact-data");
};
render() {
return (
<div>
<CheckoutSummary
ingredients={this.state.ingredients}
checkoutCancelled={this.checkoutCancelledHandler}
checkoutContinued={this.checkoutContinuedHandler}
/>
</div>
);
}
}
export default Checkout;