2019-06-19 14:40:52 +00:00
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import Grid from "@saleor/components/Grid";
|
|
|
|
import PageHeader from "@saleor/components/PageHeader";
|
2019-10-25 13:31:27 +00:00
|
|
|
import RequirePermissions from "@saleor/components/RequirePermissions";
|
2020-07-07 10:14:12 +00:00
|
|
|
import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment";
|
2019-08-26 21:26:36 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
2021-07-21 08:59:52 +00:00
|
|
|
import { Backlink } from "@saleor/macaw-ui";
|
2019-10-09 12:13:54 +00:00
|
|
|
import { ListActions, PageListProps, UserPermissionProps } from "@saleor/types";
|
|
|
|
import { PermissionEnum, WeightUnitsEnum } from "@saleor/types/globalTypes";
|
2020-05-14 09:30:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
import ShippingWeightUnitForm from "../ShippingWeightUnitForm";
|
|
|
|
import ShippingZonesList from "../ShippingZonesList";
|
|
|
|
|
2019-10-09 12:13:54 +00:00
|
|
|
export interface ShippingZonesListPageProps
|
|
|
|
extends PageListProps,
|
|
|
|
ListActions,
|
|
|
|
UserPermissionProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
defaultWeightUnit: WeightUnitsEnum;
|
|
|
|
shippingZones: ShippingZoneFragment[];
|
|
|
|
onBack: () => void;
|
|
|
|
onRemove: (id: string) => void;
|
|
|
|
onSubmit: (unit: WeightUnitsEnum) => void;
|
|
|
|
}
|
|
|
|
|
2019-11-07 11:34:54 +00:00
|
|
|
const ShippingZonesListPage: React.FC<ShippingZonesListPageProps> = ({
|
2019-10-09 12:13:54 +00:00
|
|
|
defaultWeightUnit,
|
|
|
|
disabled,
|
|
|
|
userPermissions,
|
|
|
|
onBack,
|
|
|
|
onSubmit,
|
|
|
|
...listProps
|
|
|
|
}) => {
|
2019-08-26 21:26:36 +00:00
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
2021-07-21 08:59:52 +00:00
|
|
|
<Backlink onClick={onBack}>
|
2019-08-26 21:26:36 +00:00
|
|
|
{intl.formatMessage(sectionNames.configuration)}
|
2021-07-21 08:59:52 +00:00
|
|
|
</Backlink>
|
2019-08-26 21:26:36 +00:00
|
|
|
<PageHeader
|
|
|
|
title={intl.formatMessage({
|
|
|
|
defaultMessage: "Shipping",
|
|
|
|
description: "header"
|
|
|
|
})}
|
2020-11-23 09:39:24 +00:00
|
|
|
/>
|
2019-08-26 21:26:36 +00:00
|
|
|
<Grid>
|
|
|
|
<div>
|
|
|
|
<ShippingZonesList disabled={disabled} {...listProps} />
|
|
|
|
</div>
|
|
|
|
<div>
|
2019-10-09 12:13:54 +00:00
|
|
|
<RequirePermissions
|
|
|
|
userPermissions={userPermissions}
|
|
|
|
requiredPermissions={[PermissionEnum.MANAGE_SETTINGS]}
|
|
|
|
>
|
|
|
|
<ShippingWeightUnitForm
|
|
|
|
defaultWeightUnit={defaultWeightUnit}
|
|
|
|
disabled={disabled}
|
|
|
|
onSubmit={onSubmit}
|
|
|
|
/>
|
|
|
|
</RequirePermissions>
|
2019-08-26 21:26:36 +00:00
|
|
|
</div>
|
|
|
|
</Grid>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
ShippingZonesListPage.displayName = "ShippingZonesListPage";
|
|
|
|
export default ShippingZonesListPage;
|