You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.5 KiB
JavaScript
35 lines
1.5 KiB
JavaScript
import React from 'react'
|
|
import ActionBar from '~/components/admin/actionBar'
|
|
import {FormController, Input, Button} from '~/components/form'
|
|
import Router from 'next/router'
|
|
|
|
OrderAddress.getInitialProps = async ({ctx}) => {
|
|
const {data: order} = await ctx.axios.get(`/api/orders/${ctx.query.uuid}`)
|
|
return {order}
|
|
}
|
|
|
|
export default function OrderAddress({order}) {
|
|
function afterSave(order) {
|
|
Router.push(`/admin/orders/new/${order.uuid}/payment`)
|
|
}
|
|
|
|
const {address} = order;
|
|
|
|
return (
|
|
<>
|
|
<ActionBar title="Set Address" actions={[
|
|
{label: 'Cancel', url: `/admin/orders`}
|
|
]}/>
|
|
<FormController url={`/api/orders/manual/${order.uuid}/address`} afterSubmit={afterSave}>
|
|
<Input initialValue={address?.name} name="name" validate={value=>value.length > 0}/>
|
|
<Input initialValue={address?.street1} label="Street (line 1)" name="street1" validate={value=>value.length > 0}/>
|
|
<Input initialValue={address?.street2} label="Street (line 2)" name="street2"/>
|
|
<Input initialValue={address?.city} label="City" name="city" validate={value=>value.length > 0}/>
|
|
<Input initialValue={address?.state} label="State / Province" name="state" validate={value=>value.length > 0}/>
|
|
<Input initialValue={address?.zip} label="Postal Code" name="zip" validate={value=>value.length > 0}/>
|
|
<Input initialValue={address?.country} label="Country" name="country" validate={value=>value.length > 0}/>
|
|
<Button type="submit">Save Address</Button>
|
|
</FormController>
|
|
</>
|
|
)
|
|
} |