Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Last active July 24, 2017 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhysforyou/85109c0e4c4b7d0602deab70da79cb35 to your computer and use it in GitHub Desktop.
Save rhysforyou/85109c0e4c4b7d0602deab70da79cb35 to your computer and use it in GitHub Desktop.
// @flow
import React from 'react';
import Form from 'components/drafts/form';
import Heading from 'components/heading/heading';
import Button from 'components/button/button';
import DetailsFormSection from './details';
import PartyFormSection from './party';
import WeightsFormSection from './weights';
import FreightFormSection from './freight';
import { formWrapper, boxWrapper, viewHeading } from 'styles/layout.css';
type Props = {
draft: string,
updateDraft?: (name: string, field: string | string[], value: any) => any,
commitDraft: () => any,
showWeightsSection: boolean,
title: string,
submitAction: string
};
const OrderForm = ({
draft,
updateDraft,
commitDraft,
showWeightsSection,
title,
submitAction
}: Props) =>
<section>
<header className={viewHeading}>
<Heading title={title} />
</header>
<Form id="order-form" className={formWrapper} onSubmit={commitDraft}>
<div className={boxWrapper}>
<DetailsFormSection draft={draft} updateDraft={updateDraft} />
<PartyFormSection
draft={draft}
updateDraft={updateDraft}
title="Origin"
party="origin"
/>
<PartyFormSection
draft={draft}
updateDraft={updateDraft}
title="Destination"
party="destination"
/>
{showWeightsSection &&
<WeightsFormSection draft={draft} updateDraft={updateDraft} />}
<FreightFormSection draft={draft} updateDraft={updateDraft} />
<Button type="create" size="large">
{submitAction}
</Button>
</div>
</Form>
</section>;
export default OrderForm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment