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.
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
import Head from 'next/head'
|
|
import {FormController, Input, Button} from '~/components/form'
|
|
import Router from 'next/router'
|
|
|
|
InputAddress.getInitialProps = async function({ctx: {axios}}){
|
|
const {data: {address}} = await axios.get(`/api/orders/current`)
|
|
return {address}
|
|
}
|
|
|
|
export default function InputAddress({address}){
|
|
const afterSave = () => {
|
|
Router.push('/store/checkout')
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>Enter Address | Society of Socks</title>
|
|
</Head>
|
|
<h2>Enter Address</h2>
|
|
<FormController url="/api/orders/current/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}/>
|
|
<Button type="submit">Save Address</Button>
|
|
</FormController>
|
|
</>
|
|
)
|
|
}
|