2021-05-14 08:15:15 +00:00
|
|
|
import { Typography } from "@material-ui/core";
|
2020-11-30 13:19:57 +00:00
|
|
|
import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton";
|
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import Grid from "@saleor/components/Grid";
|
|
|
|
import PageHeader from "@saleor/components/PageHeader";
|
2021-07-21 08:59:52 +00:00
|
|
|
import Savebar from "@saleor/components/Savebar";
|
2020-11-30 13:19:57 +00:00
|
|
|
import { OrderSettingsFragment } from "@saleor/fragments/types/OrderSettingsFragment";
|
2021-08-20 14:36:05 +00:00
|
|
|
import { ShopOrderSettingsFragment } from "@saleor/fragments/types/ShopOrderSettingsFragment";
|
2020-11-30 13:19:57 +00:00
|
|
|
import { SubmitPromise } from "@saleor/hooks/useForm";
|
|
|
|
import { sectionNames } from "@saleor/intl";
|
2021-07-21 08:59:52 +00:00
|
|
|
import { Backlink } from "@saleor/macaw-ui";
|
2020-11-30 13:19:57 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
2021-08-20 14:36:05 +00:00
|
|
|
import OrderFulfillmentSettings from "../OrderFulfillmentSettings";
|
2020-11-30 13:19:57 +00:00
|
|
|
import OrderSettings from "../OrderSettings/OrderSettings";
|
|
|
|
import OrderSettingsForm, { OrderSettingsFormData } from "./form";
|
|
|
|
|
|
|
|
export interface OrderSettingsPageProps {
|
2021-08-20 14:36:05 +00:00
|
|
|
orderSettings: OrderSettingsFragment;
|
|
|
|
shop: ShopOrderSettingsFragment;
|
2020-11-30 13:19:57 +00:00
|
|
|
disabled: boolean;
|
|
|
|
saveButtonBarState: ConfirmButtonTransitionState;
|
|
|
|
onBack: () => void;
|
|
|
|
onSubmit: (data: OrderSettingsFormData) => SubmitPromise;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OrderSettingsPage: React.FC<OrderSettingsPageProps> = props => {
|
2021-08-20 14:36:05 +00:00
|
|
|
const {
|
|
|
|
orderSettings,
|
|
|
|
shop,
|
|
|
|
disabled,
|
|
|
|
saveButtonBarState,
|
|
|
|
onBack,
|
|
|
|
onSubmit
|
|
|
|
} = props;
|
2020-11-30 13:19:57 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
2021-08-20 14:36:05 +00:00
|
|
|
<OrderSettingsForm
|
|
|
|
orderSettings={orderSettings}
|
|
|
|
shop={shop}
|
|
|
|
onSubmit={onSubmit}
|
|
|
|
>
|
2020-11-30 13:19:57 +00:00
|
|
|
{({ data, submit, hasChanged, change }) => (
|
|
|
|
<Container>
|
2021-07-21 08:59:52 +00:00
|
|
|
<Backlink onClick={onBack}>
|
2020-11-30 13:19:57 +00:00
|
|
|
{intl.formatMessage(sectionNames.orders)}
|
2021-07-21 08:59:52 +00:00
|
|
|
</Backlink>
|
2020-11-30 13:19:57 +00:00
|
|
|
<PageHeader
|
|
|
|
title={intl.formatMessage({
|
|
|
|
defaultMessage: "Order settings",
|
|
|
|
description: "header"
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<Grid variant="inverted">
|
|
|
|
<div>
|
|
|
|
<Typography>
|
|
|
|
<FormattedMessage defaultMessage="General Settings" />
|
|
|
|
</Typography>
|
|
|
|
</div>
|
|
|
|
<OrderSettings data={data} disabled={disabled} onChange={change} />
|
2021-08-20 14:36:05 +00:00
|
|
|
<div />
|
|
|
|
<OrderFulfillmentSettings
|
|
|
|
data={data}
|
|
|
|
disabled={disabled}
|
|
|
|
onChange={change}
|
|
|
|
/>
|
2020-11-30 13:19:57 +00:00
|
|
|
</Grid>
|
2021-07-21 08:59:52 +00:00
|
|
|
<Savebar
|
2020-11-30 13:19:57 +00:00
|
|
|
onCancel={onBack}
|
2021-07-21 08:59:52 +00:00
|
|
|
onSubmit={submit}
|
2020-11-30 13:19:57 +00:00
|
|
|
disabled={disabled || !hasChanged}
|
|
|
|
state={saveButtonBarState}
|
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
)}
|
|
|
|
</OrderSettingsForm>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
OrderSettingsPage.displayName = "OrderSettingsPage";
|
|
|
|
export default OrderSettingsPage;
|