|
|
@ -10,7 +10,8 @@ Orders.getInitialProps = async ({ctx}) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function Orders({orders}){
|
|
|
|
export default function Orders({orders}){
|
|
|
|
const unshippedOrders = orders.filter(order => !order.delivery)
|
|
|
|
const unshippedPreOrders = orders.filter(order => !order.delivery && order.transactions.some(t => t.has_preorder && !t.preorder_ready_to_ship))
|
|
|
|
|
|
|
|
const unshippedAndShippableOrders = orders.filter(order => !order.delivery && !order.transactions.some(t => t.has_preorder && !t.preorder_ready_to_ship))
|
|
|
|
const shippedOrders = orders.filter(order => order.delivery).reverse()
|
|
|
|
const shippedOrders = orders.filter(order => order.delivery).reverse()
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -18,7 +19,7 @@ export default function Orders({orders}){
|
|
|
|
<ActionBar title="Orders" actions={[
|
|
|
|
<ActionBar title="Orders" actions={[
|
|
|
|
{label: 'Add Manual Order', url: `/admin/orders/new`}
|
|
|
|
{label: 'Add Manual Order', url: `/admin/orders/new`}
|
|
|
|
]}/>
|
|
|
|
]}/>
|
|
|
|
<h4>Unsent:</h4>
|
|
|
|
<h4>Unsent (sendable):</h4>
|
|
|
|
<Table
|
|
|
|
<Table
|
|
|
|
columns={[
|
|
|
|
columns={[
|
|
|
|
{name: 'Purchased', extractor: getPurchaseTime},
|
|
|
|
{name: 'Purchased', extractor: getPurchaseTime},
|
|
|
@ -30,7 +31,23 @@ export default function Orders({orders}){
|
|
|
|
<button className="buttonLink" onClick={() => Router.push(`/admin/orders/${row.id}`)}>Details</button>
|
|
|
|
<button className="buttonLink" onClick={() => Router.push(`/admin/orders/${row.id}`)}>Details</button>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
]}
|
|
|
|
rows={unshippedOrders.map(order => ({id: order.uuid, ...order}))}
|
|
|
|
rows={unshippedAndShippableOrders.map(order => ({id: order.uuid, ...order}))}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h4>Unsent (pre-orders):</h4>
|
|
|
|
|
|
|
|
<Table
|
|
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
|
|
{name: 'Purchased', extractor: getPurchaseTime},
|
|
|
|
|
|
|
|
{name: 'Items', extractor: getNumberItems},
|
|
|
|
|
|
|
|
{name: 'Price', extractor: getItemPrice},
|
|
|
|
|
|
|
|
{name: 'Shipping', extractor: getShippingEstimate},
|
|
|
|
|
|
|
|
{name: 'Amount Paid', extractor: getAmountPaid},
|
|
|
|
|
|
|
|
{name: 'Estimated availability', extractor: getPreorderEstimate},
|
|
|
|
|
|
|
|
{name: '', extractor: row =>
|
|
|
|
|
|
|
|
<button className="buttonLink" onClick={() => Router.push(`/admin/orders/${row.id}`)}>Details</button>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
rows={unshippedPreOrders.map(order => ({id: order.uuid, ...order}))}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<h4>Sent:</h4>
|
|
|
|
<h4>Sent:</h4>
|
|
|
@ -88,6 +105,12 @@ function getAmountPaid(order){
|
|
|
|
.reduce((a,b)=>(a+b), 0))
|
|
|
|
.reduce((a,b)=>(a+b), 0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getPreorderEstimate(order) {
|
|
|
|
|
|
|
|
const preorderDates = order.transactions.filter(t => t.has_preorder).map(t => DateTime.fromISO(t.preorder_fulfill_date))
|
|
|
|
|
|
|
|
preorderDates.sort((b, a) => a < b ? -1 : a > b ? 1 : 0)
|
|
|
|
|
|
|
|
return preorderDates[0]?.toLocaleString(DateTime.DATE_FULL)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function parsePaymentTime({payments}){
|
|
|
|
function parsePaymentTime({payments}){
|
|
|
|
for(const payment of payments) {
|
|
|
|
for(const payment of payments) {
|
|
|
|
if(typeof payment.time === 'string')
|
|
|
|
if(typeof payment.time === 'string')
|
|
|
|