|
|
|
@ -1,4 +1,7 @@
|
|
|
|
|
import {DateTime} from 'luxon'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
|
|
import styles from './style.module.css'
|
|
|
|
|
|
|
|
|
|
CheckoutComplete.getInitialProps = async function({ctx: {query: {session_id}, axios}}){
|
|
|
|
|
const {data: orders} = await axios.get('/api/orders')
|
|
|
|
@ -9,10 +12,67 @@ CheckoutComplete.getInitialProps = async function({ctx: {query: {session_id}, ax
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function CheckoutComplete({order}){
|
|
|
|
|
const items = order.transactions.map(transaction => transaction.cart.items).flat()
|
|
|
|
|
const latestTransaction = order.transactions.sort(sortTransactions)[0]
|
|
|
|
|
|
|
|
|
|
let email = null
|
|
|
|
|
|
|
|
|
|
if(latestTransaction.payment.stripe)
|
|
|
|
|
email = latestTransaction.payment.stripe.reciept_email
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<pre>
|
|
|
|
|
{JSON.stringify(order, null, 2)}
|
|
|
|
|
</pre>
|
|
|
|
|
<>
|
|
|
|
|
<h2>Order Complete</h2>
|
|
|
|
|
<div className={styles.horizContainer}>
|
|
|
|
|
<div>
|
|
|
|
|
<h3>The following items:</h3>
|
|
|
|
|
<table style={{margin: '0 auto'}}>
|
|
|
|
|
<tbody>
|
|
|
|
|
{items.map(({uuid, count, item}) => (
|
|
|
|
|
<tr key={uuid}>
|
|
|
|
|
<td>{count}x</td>
|
|
|
|
|
<td>{item.name}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h3>Will be shipped to:</h3>
|
|
|
|
|
<p style={{margin: 0}}>{order.address.name}</p>
|
|
|
|
|
<p style={{margin: 0}}>{order.address.street1}</p>
|
|
|
|
|
<p style={{margin: 0}}>{order.address.street2}</p>
|
|
|
|
|
<p style={{margin: 0}}>{order.address.city}, {order.address.state}, {order.address.zip}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{
|
|
|
|
|
email
|
|
|
|
|
? (
|
|
|
|
|
<>
|
|
|
|
|
<p>
|
|
|
|
|
Orders typically are shipped within 3-5 business days of purchase. You
|
|
|
|
|
will receive an email with a tracking number when your order ships.
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
Your tracking number will be sent to: <strong>
|
|
|
|
|
{email}
|
|
|
|
|
</strong>
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
If you do not receive an email within 1 week,
|
|
|
|
|
please <Link href="/contact"><a>contact us</a></Link>. In any
|
|
|
|
|
correspondence please be sure to include your order number
|
|
|
|
|
(#{order.number}).
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
: (
|
|
|
|
|
<p>
|
|
|
|
|
Orders typically are shipped within 3-5 business days of purchase.
|
|
|
|
|
</p>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -35,3 +95,9 @@ function sortOrders(a,b){
|
|
|
|
|
|
|
|
|
|
return timePaidB.diff(timePaidA).as('seconds')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatMoney(money){
|
|
|
|
|
if (money === undefined || money === null) return null;
|
|
|
|
|
|
|
|
|
|
return '$' + (money / 100).toFixed(2)
|
|
|
|
|
}
|
|
|
|
|