UPD: make invoiceDetail as a self-contained compoient
This commit is contained in:
parent
17d9144e7d
commit
c58f27ba99
@ -1,18 +1,22 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const Invoice = (props) => {
|
// re-arrange to make invoice detail a self-contained element
|
||||||
|
const Invoice = ( {invoiceDetails} ) => {
|
||||||
|
let addressInfo = invoiceDetails.purchase_units[0].shipping.address;
|
||||||
|
let address = `${addressInfo.address_line_1} ${addressInfo.admin_area_2}, ${addressInfo.admin_area_1} ${addressInfo.postal_code}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
Date Purchased: {props.date}
|
Date Purchased: {invoiceDetails.create_time}
|
||||||
<br />
|
<br />
|
||||||
Item: {props.itemName}
|
Item: {invoiceDetails.purchase_units[0].description}
|
||||||
<br />
|
<br />
|
||||||
Amount Paid: ${props.itemValue}
|
Amount Paid: ${invoiceDetails.purchase_units[0].amount.value}
|
||||||
<br />
|
<br />
|
||||||
Ship to: {props.buyerName}
|
Ship to: {invoiceDetails.purchase_units[0].shipping.name.full_name}
|
||||||
<br />
|
<br />
|
||||||
Shipping address: {props.streetAddr} {props.city}, {props.state} {props.postalCode}
|
{/* Shipping address: {streetAddr} {city}, {state} {postalCode} */}
|
||||||
|
Shpping address: {address}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ import React, { useState } from "react";
|
|||||||
import "./home.css";
|
import "./home.css";
|
||||||
import { PayPal, Purchase, ShowCase, Home } from '.';
|
import { PayPal, Purchase, ShowCase, Home } from '.';
|
||||||
|
|
||||||
const details = () => {
|
// component
|
||||||
|
const Details = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ShowCase />
|
<ShowCase />
|
||||||
@ -11,12 +12,13 @@ const details = () => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Landing = () => {
|
const Landing = () => {
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showDetails ? details() : <Home goNext={() => setShowDetails(true)} />}
|
{showDetails ? <Details /> : <Home goNext={() => setShowDetails(true)} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -48,18 +48,8 @@ const PayPal = () => {
|
|||||||
</div>
|
</div>
|
||||||
</PayPalScriptProvider>
|
</PayPalScriptProvider>
|
||||||
</div>
|
</div>
|
||||||
{showInvoice &&
|
{/* This is a nice touch */}
|
||||||
<Invoice
|
{showInvoice && <Invoice invoiceDetails={invoiceDetails} />}
|
||||||
date={invoiceDetails.create_time}
|
|
||||||
itemName={invoiceDetails.purchase_units[0].description}
|
|
||||||
itemValue={invoiceDetails.purchase_units[0].amount.value}
|
|
||||||
buyerName={invoiceDetails.purchase_units[0].shipping.name.full_name}
|
|
||||||
streetAddr={invoiceDetails.purchase_units[0].shipping.address.address_line_1}
|
|
||||||
city={invoiceDetails.purchase_units[0].shipping.address.admin_area_2}
|
|
||||||
state={invoiceDetails.purchase_units[0].shipping.address.admin_area_1}
|
|
||||||
postalCode={invoiceDetails.purchase_units[0].shipping.address.postal_code}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user