Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add shipping zone details components

dominik-zeglenba9c4b616b5a
diff --git a/saleor/static/dashboard-next/components/Money/Money.tsx b/saleor/static/dashboard-next/components/Money/Money.tsx
index 98a63b7d3b..62ba7aaaae 100644
--- a/saleor/static/dashboard-next/components/Money/Money.tsx
+++ b/saleor/static/dashboard-next/components/Money/Money.tsx
@@ -2,12 +2,12 @@ import * as React from "react";
import { LocaleConsumer } from "../Locale";
-export interface Money {
+export interface IMoney {
amount: number;
currency: string;
}
export interface MoneyProps {
- money: Money;
+ money: IMoney;
}
export const Money: React.StatelessComponent<MoneyProps> = ({ money }) => (
diff --git a/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx b/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx
new file mode 100644
index 0000000000..d695f47617
--- /dev/null
+++ b/saleor/static/dashboard-next/components/MoneyRange/MoneyRange.tsx
@@ -0,0 +1,50 @@
+import * as React from "react";
+
+import i18n from "../../i18n";
+import { LocaleConsumer } from "../Locale";
+import IMoney from "../Money";
+
+export interface MoneyRangeProps {
+ from?: IMoney;
+ to?: IMoney;
+}
+
+export const MoneyRange: React.StatelessComponent<MoneyRangeProps> = ({
+ from,
+ to
+}) => (
+ <LocaleConsumer>
+ {locale =>
+ from && to
+ ? i18n.t("{{ fromMoney }} - {{ toMoney }}", {
+ context: "money",
+ fromMoney: from.amount.toLocaleString(locale, {
+ currency: from.currency,
+ style: "currency"
+ }),
+ toMoney: to.amount.toLocaleString(locale, {
+ currency: to.currency,
+ style: "currency"
+ })
+ })
+ : from && !to
+ ? i18n.t("from {{ money }}", {
+ context: "money",
+ money: from.amount.toLocaleString(locale, {
+ currency: from.currency,
+ style: "currency"
+ })
+ })
+ : i18n.t("to {{ money }}", {
+ context: "money",
+ money: to.amount.toLocaleString(locale, {
+ currency: to.currency,
+ style: "currency"
+ })
+ })
+ }
+ </LocaleConsumer>
+);
+
+MoneyRange.displayName = "MoneyRange";
+export default MoneyRange;
diff --git a/saleor/static/dashboard-next/components/MoneyRange/index.ts b/saleor/static/dashboard-next/components/MoneyRange/index.ts
new file mode 100644
index 0000000000..131c9f9a56
--- /dev/null
+++ b/saleor/static/dashboard-next/components/MoneyRange/index.ts
@@ -0,0 +1,2 @@
+export { default } from './MoneyRange';
+export * from './MoneyRange';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/components/Weight/Weight.tsx b/saleor/static/dashboard-next/components/Weight/Weight.tsx
new file mode 100644
index 0000000000..35defbf0b5
--- /dev/null
+++ b/saleor/static/dashboard-next/components/Weight/Weight.tsx
@@ -0,0 +1,18 @@
+import * as React from "react";
+import i18n from "../../i18n";
+
+export interface Weight {
+ unit: string;
+ value: number;
+}
+export interface WeightProps {
+ weight: Weight;
+}
+
+const Weight: React.StatelessComponent<WeightProps> = ({ weight }) =>
+ i18n.t("{{ value }} {{ unit }}", {
+ context: "weight",
+ ...weight
+ });
+Weight.displayName = "Weight";
+export default Weight;
diff --git a/saleor/static/dashboard-next/components/Weight/index.ts b/saleor/static/dashboard-next/components/Weight/index.ts
new file mode 100644
index 0000000000..1a73fcf9a1
--- /dev/null
+++ b/saleor/static/dashboard-next/components/Weight/index.ts
@@ -0,0 +1,2 @@
+export { default } from './Weight';
+export * from './Weight';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx b/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx
new file mode 100644
index 0000000000..71d41d4da8
--- /dev/null
+++ b/saleor/static/dashboard-next/components/WeightRange/WeightRange.tsx
@@ -0,0 +1,33 @@
+import * as React from "react";
+
+import i18n from "../../i18n";
+import { Weight } from "../Weight";
+
+export interface WeightRangeProps {
+ from?: Weight;
+ to?: Weight;
+}
+
+const WeightRange: React.StatelessComponent<WeightRangeProps> = ({
+ from,
+ to
+}) =>
+ from && to
+ ? i18n.t("{{ fromValue }} {{ fromUnit }} - {{ toValue }} {{ toUnit }}", {
+ context: "weight",
+ fromUnit: from.unit,
+ fromValue: from.value,
+ toUnit: to.unit,
+ toValue: to.value
+ })
+ : from && !to
+ ? i18n.t("from {{ value }} {{ unit }}", {
+ context: "weight",
+ ...from
+ })
+ : i18n.t("to {{ value }} {{ unit }}", {
+ context: "weight",
+ ...to
+ });
+WeightRange.displayName = "WeightRange";
+export default WeightRange;
diff --git a/saleor/static/dashboard-next/components/WeightRange/index.ts b/saleor/static/dashboard-next/components/WeightRange/index.ts
new file mode 100644
index 0000000000..b07752efe1
--- /dev/null
+++ b/saleor/static/dashboard-next/components/WeightRange/index.ts
@@ -0,0 +1,2 @@
+export { default } from './WeightRange';
+export * from './WeightRange';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx b/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
new file mode 100644
index 0000000000..ae2e5d3549
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx
@@ -0,0 +1,116 @@
+import * as React from "react";
+
+import CardSpacer from "../../../components/CardSpacer";
+import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton";
+import Container from "../../../components/Container";
+import CountryList from "../../../components/CountryList";
+import Form from "../../../components/Form";
+import Grid from "../../../components/Grid";
+import PageHeader from "../../../components/PageHeader";
+import SaveButtonBar from "../../../components/SaveButtonBar";
+import i18n from "../../../i18n";
+import { maybe } from "../../../misc";
+import { ShippingMethodTypeEnum } from "../../../types/globalTypes";
+import { ShippingZoneDetailsFragment } from "../../types/ShippingZoneDetailsFragment";
+import ShippingZoneInfo from "../ShippingZoneInfo";
+import ShippingZoneRates from "../ShippingZoneRates";
+
+export interface FormData {
+ name: string;
+}
+
+export interface ShippingZoneDetailsPageProps {
+ disabled: boolean;
+ saveButtonBarState: ConfirmButtonTransitionState;
+ shippingZone: ShippingZoneDetailsFragment;
+ onBack: () => void;
+ onCountryAdd: () => void;
+ onCountryRemove: (code: string) => void;
+ onDelete: () => void;
+ onPriceRateAdd: () => void;
+ onPriceRateEdit: () => void;
+ onRateRemove: () => void;
+ onSubmit: (data: FormData) => void;
+ onWeightRateAdd: () => void;
+ onWeightRateEdit: () => void;
+}
+
+const ShippingZoneDetailsPage: React.StatelessComponent<
+ ShippingZoneDetailsPageProps
+> = ({
+ disabled,
+ onBack,
+ onCountryAdd,
+ onCountryRemove,
+ onDelete,
+ onPriceRateAdd,
+ onPriceRateEdit,
+ onRateRemove,
+ onSubmit,
+ onWeightRateAdd,
+ onWeightRateEdit,
+ saveButtonBarState,
+ shippingZone
+}) => {
+ const initialForm: FormData = {
+ name: maybe(() => shippingZone.name, "")
+ };
+ return (
+ <Form initial={initialForm} onSubmit={onSubmit}>
+ {({ change, data, hasChanged, submit }) => (
+ <Container width="md">
+ <PageHeader title={maybe(() => shippingZone.name)} onBack={onBack} />
+ <Grid>
+ <div>
+ <ShippingZoneInfo data={data} onChange={change} />
+ <CardSpacer />
+ <CountryList
+ countries={maybe(() => shippingZone.countries)}
+ disabled={disabled}
+ emptyText={i18n.t("Placeholder")}
+ onCountryAssign={onCountryAdd}
+ onCountryUnassign={onCountryRemove}
+ title={i18n.t("Countries")}
+ />
+ <CardSpacer />
+ <ShippingZoneRates
+ disabled={disabled}
+ onRateAdd={onPriceRateAdd}
+ onRateEdit={onPriceRateEdit}
+ onRateRemove={onRateRemove}
+ rates={maybe(() =>
+ shippingZone.shippingMethods.filter(
+ method => method.type === ShippingMethodTypeEnum.PRICE
+ )
+ )}
+ variant="price"
+ />
+ <CardSpacer />
+ <ShippingZoneRates
+ disabled={disabled}
+ onRateAdd={onWeightRateAdd}
+ onRateEdit={onWeightRateEdit}
+ onRateRemove={onRateRemove}
+ rates={maybe(() =>
+ shippingZone.shippingMethods.filter(
+ method => method.type === ShippingMethodTypeEnum.WEIGHT
+ )
+ )}
+ variant="weight"
+ />
+ </div>
+ </Grid>
+ <SaveButtonBar
+ disabled={disabled || !hasChanged}
+ onCancel={onBack}
+ onDelete={onDelete}
+ onSave={submit}
+ state={saveButtonBarState}
+ />
+ </Container>
+ )}
+ </Form>
+ );
+};
+ShippingZoneDetailsPage.displayName = "ShippingZoneDetailsPage";
+export default ShippingZoneDetailsPage;
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/index.ts b/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/index.ts
new file mode 100644
index 0000000000..1bfd26b13b
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneDetailsPage/index.ts
@@ -0,0 +1,2 @@
+export { default } from './ShippingZoneDetailsPage';
+export * from './ShippingZoneDetailsPage';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx b/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx
new file mode 100644
index 0000000000..573aef9653
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx
@@ -0,0 +1,33 @@
+import Card from "@material-ui/core/Card";
+import CardContent from "@material-ui/core/CardContent";
+import TextField from "@material-ui/core/TextField";
+import * as React from "react";
+
+import CardTitle from "../../../components/CardTitle";
+import i18n from "../../../i18n";
+import { FormData } from "../ShippingZoneDetailsPage";
+
+export interface ShippingZoneInfoProps {
+ data: FormData;
+ onChange: (event: React.ChangeEvent<any>) => void;
+}
+
+const ShippingZoneInfo: React.StatelessComponent<ShippingZoneInfoProps> = ({
+ data,
+ onChange
+}) => (
+ <Card>
+ <CardTitle title={i18n.t("General Information")} />
+ <CardContent>
+ <TextField
+ fullWidth
+ label={i18n.t("Shipping Zone Name")}
+ name={"name" as keyof FormData}
+ value={data.name}
+ onChange={onChange}
+ />
+ </CardContent>
+ </Card>
+);
+ShippingZoneInfo.displayName = "ShippingZoneInfo";
+export default ShippingZoneInfo;
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/index.ts b/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/index.ts
new file mode 100644
index 0000000000..a04821eb00
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneInfo/index.ts
@@ -0,0 +1,2 @@
+export { default } from './ShippingZoneInfo';
+export * from './ShippingZoneInfo';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx b/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx
new file mode 100644
index 0000000000..dae0fd2614
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx
@@ -0,0 +1,171 @@
+import Button from "@material-ui/core/Button";
+import Card from "@material-ui/core/Card";
+import IconButton from "@material-ui/core/IconButton";
+import {
+ createStyles,
+ Theme,
+ withStyles,
+ WithStyles
+} from "@material-ui/core/styles";
+import Table from "@material-ui/core/Table";
+import TableBody from "@material-ui/core/TableBody";
+import TableCell from "@material-ui/core/TableCell";
+import TableHead from "@material-ui/core/TableHead";
+import TableRow from "@material-ui/core/TableRow";
+import DeleteIcon from "@material-ui/icons/Delete";
+import EditIcon from "@material-ui/icons/Edit";
+import * as React from "react";
+
+import CardTitle from "../../../components/CardTitle";
+import Money from "../../../components/Money";
+import MoneyRange from "../../../components/MoneyRange";
+import Skeleton from "../../../components/Skeleton";
+import WeightRange from "../../../components/WeightRange";
+import i18n from "../../../i18n";
+import { maybe, renderCollection } from "../../../misc";
+import { ICONBUTTON_SIZE } from "../../../theme";
+import { ShippingZoneDetailsFragment_shippingMethods } from "../../types/ShippingZoneDetailsFragment";
+
+export interface ShippingZoneRatesProps {
+ disabled: boolean;
+ rates: ShippingZoneDetailsFragment_shippingMethods[];
+ variant: "price" | "weight";
+ onRateAdd: () => void;
+ onRateEdit: (id: string) => void;
+ onRateRemove: (id: string) => void;
+}
+
+const styles = (theme: Theme) =>
+ createStyles({
+ alignRight: {
+ "&:last-child": {
+ paddingRight: 0
+ },
+ paddingRight: 0,
+ width: ICONBUTTON_SIZE + theme.spacing.unit / 2
+ },
+ nameColumn: {
+ width: 300
+ },
+ valueColumn: {
+ width: 300
+ }
+ });
+const ShippingZoneRates = withStyles(styles, { name: "ShippingZoneRates" })(
+ ({
+ classes,
+ disabled,
+ onRateAdd,
+ onRateEdit,
+ onRateRemove,
+ rates,
+ variant
+ }: ShippingZoneRatesProps & WithStyles<typeof styles>) => (
+ <Card>
+ <CardTitle
+ height="const"
+ title={i18n.t("Shipping by zone")}
+ toolbar={
+ <Button color="secondary" onClick={onRateAdd}>
+ {i18n.t("Add rate", {
+ context: "button"
+ })}
+ </Button>
+ }
+ />
+ <Table>
+ <TableHead>
+ <TableRow>
+ <TableCell className={classes.nameColumn}>
+ {i18n.t("Name", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.valueColumn}>
+ {variant === "price"
+ ? i18n.t("Value Range", { context: "object" })
+ : i18n.t("Weight Range", { context: "object" })}
+ </TableCell>
+ <TableCell className={classes.nameColumn}>
+ {i18n.t("Price", { context: "object" })}
+ </TableCell>
+ <TableCell />
+ <TableCell />
+ </TableRow>
+ </TableHead>
+ <TableBody>
+ {renderCollection(
+ rates,
+ rate => (
+ <TableRow
+ hover={!!rate}
+ key={rate ? rate.id : "skeleton"}
+ onClick={!!rate && (() => onRateEdit(rate.id))}
+ >
+ <TableCell className={classes.nameColumn}>
+ {maybe<React.ReactNode>(() => rate.name, <Skeleton />)}
+ </TableCell>
+ <TableCell>
+ {maybe<React.ReactNode>(
+ () =>
+ variant === "price" ? (
+ <MoneyRange
+ from={rate.minimumOrderPrice}
+ to={rate.maximumOrderPrice}
+ />
+ ) : (
+ <WeightRange
+ from={rate.minimumOrderWeight}
+ to={rate.maximumOrderWeight}
+ />
+ ),
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell>
+ {maybe<React.ReactNode>(
+ () => (
+ <Money money={rate.price} />
+ ),
+ <Skeleton />
+ )}
+ </TableCell>
+ <TableCell className={classes.alignRight}>
+ <IconButton
+ color="secondary"
+ disabled={disabled}
+ onClick={event => {
+ event.stopPropagation();
+ onRateEdit(rate.id);
+ }}
+ >
+ <EditIcon />
+ </IconButton>
+ </TableCell>
+ <TableCell className={classes.alignRight}>
+ <IconButton
+ color="secondary"
+ disabled={disabled}
+ onClick={event => {
+ event.stopPropagation();
+ onRateRemove(rate.id);
+ }}
+ >
+ <DeleteIcon />
+ </IconButton>
+ </TableCell>
+ </TableRow>
+ ),
+ () => (
+ <TableRow>
+ <TableCell colSpan={5}>
+ {i18n.t("No shipping rates found")}
+ </TableCell>
+ </TableRow>
+ )
+ )}
+ </TableBody>
+ </Table>
+ </Card>
+ )
+);
+ShippingZoneRates.displayName = "ShippingZoneRates";
+export default ShippingZoneRates;
diff --git a/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/index.ts b/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/index.ts
new file mode 100644
index 0000000000..65c1ae1ce5
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/components/ShippingZoneRates/index.ts
@@ -0,0 +1,2 @@
+export { default } from './ShippingZoneRates';
+export * from './ShippingZoneRates';
\ No newline at end of file
diff --git a/saleor/static/dashboard-next/shipping/fixtures.ts b/saleor/static/dashboard-next/shipping/fixtures.ts
index 9ca1d648c2..cefe56d871 100644
--- a/saleor/static/dashboard-next/shipping/fixtures.ts
+++ b/saleor/static/dashboard-next/shipping/fixtures.ts
@@ -1,3 +1,5 @@
+import { ShippingMethodTypeEnum } from "../types/globalTypes";
+import { ShippingZoneDetailsFragment } from "./types/ShippingZoneDetailsFragment";
import { ShippingZoneFragment } from "./types/ShippingZoneFragment";
export const shippingZones: ShippingZoneFragment[] = [
@@ -1281,3 +1283,366 @@ export const shippingZones: ShippingZoneFragment[] = [
name: "Africa"
}
];
+
+export const shippingZone: ShippingZoneDetailsFragment = {
+ __typename: "ShippingZone",
+ countries: [
+ {
+ __typename: "CountryDisplay",
+ code: "AX",
+ country: "Wyspy Alandzkie"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "AL",
+ country: "Albania"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "AD",
+ country: "Andora"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "AT",
+ country: "Austria"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "BY",
+ country: "Białoruś"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "BE",
+ country: "Belgia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "BA",
+ country: "Bośnia i Hercegowina"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "BG",
+ country: "Bułgaria"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "HR",
+ country: "Chorwacja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "CZ",
+ country: "Czechy"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "DK",
+ country: "Dania"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "EE",
+ country: "Estonia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "FO",
+ country: "Wyspy Owcze"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "FI",
+ country: "Finlandia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "FR",
+ country: "Francja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "DE",
+ country: "Niemcy"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "GI",
+ country: "Gibraltar"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "GR",
+ country: "Grecja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "GG",
+ country: "Guernsey"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "VA",
+ country: "Watykan"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "HU",
+ country: "Węgry"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "IS",
+ country: "Islandia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "IE",
+ country: "Irlandia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "IM",
+ country: "Wyspa Man"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "IT",
+ country: "Włochy"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "JE",
+ country: "Jersey"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "LV",
+ country: "Łotwa"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "LI",
+ country: "Liechtenstein"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "LT",
+ country: "Litwa"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "LU",
+ country: "Luksemburg"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "MK",
+ country: "Macedonia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "MT",
+ country: "Malta"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "MD",
+ country: "Mołdawia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "MC",
+ country: "Monako"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "ME",
+ country: "Czarnogóra"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "NL",
+ country: "Holandia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "NO",
+ country: "Norwegia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "PL",
+ country: "Polska"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "PT",
+ country: "Portugalia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "RO",
+ country: "Rumunia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "RU",
+ country: "Rosja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "SM",
+ country: "San Marino"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "RS",
+ country: "Serbia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "SK",
+ country: "Słowacja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "SI",
+ country: "Słowenia"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "ES",
+ country: "Hiszpania"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "SJ",
+ country: "Svalbard i Jan Mayen"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "SE",
+ country: "Szwecja"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "CH",
+ country: "Szwajcaria"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "UA",
+ country: "Ukraina"
+ },
+ {
+ __typename: "CountryDisplay",
+ code: "GB",
+ country: "Wielka Brytania"
+ }
+ ],
+ default: false,
+ id: "U2hpcHBpbmdab25lOjE=",
+ name: "Europe",
+ shippingMethods: [
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6NA==",
+ maximumOrderPrice: null,
+ maximumOrderWeight: {
+ __typename: "Weight",
+ unit: "kg",
+ value: 80
+ },
+ minimumOrderPrice: {
+ __typename: "Money",
+ amount: 0,
+ currency: "USD"
+ },
+ minimumOrderWeight: {
+ __typename: "Weight",
+ unit: "kg",
+ value: 0
+ },
+ name: "DB Schenker",
+ price: {
+ __typename: "Money",
+ amount: 45.93,
+ currency: "USD"
+ },
+ type: ShippingMethodTypeEnum.WEIGHT
+ },
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6Mw==",
+ maximumOrderPrice: null,
+ maximumOrderWeight: null,
+ minimumOrderPrice: {
+ __typename: "Money",
+ amount: 0,
+ currency: "USD"
+ },
+ minimumOrderWeight: {
+ __typename: "Weight",
+ unit: "kg",
+ value: 0
+ },
+ name: "Registred priority",
+ price: {
+ __typename: "Money",
+ amount: 73.87,
+ currency: "USD"
+ },
+ type: ShippingMethodTypeEnum.WEIGHT
+ },
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6Mg==",
+ maximumOrderPrice: null,
+ maximumOrderWeight: null,
+ minimumOrderPrice: {
+ __typename: "Money",
+ amount: 0,
+ currency: "USD"
+ },
+ minimumOrderWeight: {
+ __typename: "Weight",
+ unit: "kg",
+ value: 0
+ },
+
+ name: "UPS",
+ price: {
+ __typename: "Money",
+ amount: 48.11,
+ currency: "USD"
+ },
+ type: ShippingMethodTypeEnum.PRICE
+ },
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6MQ==",
+ maximumOrderPrice: null,
+ maximumOrderWeight: null,
+ minimumOrderPrice: {
+ __typename: "Money",
+ amount: 0,
+ currency: "USD"
+ },
+ minimumOrderWeight: {
+ __typename: "Weight",
+ unit: "kg",
+ value: 0
+ },
+ name: "DHL",
+ price: {
+ __typename: "Money",
+ amount: 95.24,
+ currency: "USD"
+ },
+ type: ShippingMethodTypeEnum.PRICE
+ }
+ ]
+};
diff --git a/saleor/static/dashboard-next/shipping/index.tsx b/saleor/static/dashboard-next/shipping/index.tsx
index abe4566d03..1115ee107d 100644
--- a/saleor/static/dashboard-next/shipping/index.tsx
+++ b/saleor/static/dashboard-next/shipping/index.tsx
@@ -15,7 +15,8 @@ const ShippingZonesList: React.StatelessComponent<RouteComponentProps<{}>> = ({
const qs = parseQs(location.search.substr(1));
const params: ShippingZonesListQueryParams = {
after: qs.after,
- before: qs.before
+ before: qs.before,
+ delete: qs.delete
};
return <ShippingZonesListComponent params={params} />;
};
diff --git a/saleor/static/dashboard-next/shipping/queries.ts b/saleor/static/dashboard-next/shipping/queries.ts
index c12bb38116..7aa0b5caad 100644
--- a/saleor/static/dashboard-next/shipping/queries.ts
+++ b/saleor/static/dashboard-next/shipping/queries.ts
@@ -1,6 +1,7 @@
import gql from "graphql-tag";
import { pageInfoFragment, TypedQuery } from "../queries";
+import { ShippingZone, ShippingZoneVariables } from "./types/ShippingZone";
import { ShippingZones, ShippingZonesVariables } from "./types/ShippingZones";
export const shippingZoneFragment = gql`
@@ -13,6 +14,38 @@ export const shippingZoneFragment = gql`
name
}
`;
+export const shippingZoneDetailsFragment = gql`
+ ${shippingZoneFragment}
+ fragment ShippingZoneDetailsFragment on ShippingZone {
+ ...ShippingZoneFragment
+ default
+ shippingMethods {
+ id
+ minimumOrderPrice {
+ amount
+ currency
+ }
+ minimumOrderWeight {
+ unit
+ value
+ }
+ maximumOrderPrice {
+ amount
+ currency
+ }
+ maximumOrderWeight {
+ unit
+ value
+ }
+ name
+ price {
+ amount
+ currency
+ }
+ type
+ }
+ }
+`;
const shippingZones = gql`
${pageInfoFragment}
@@ -39,3 +72,16 @@ export const TypedShippingZones = TypedQuery<
ShippingZones,
ShippingZonesVariables
>(shippingZones);
+
+const shippingZone = gql`
+ ${shippingZoneDetailsFragment}
+ query ShippingZone($id: ID!) {
+ shippingZone(id: $id) {
+ ...ShippingZoneDetailsFragment
+ }
+ }
+`;
+export const TypedShippingZone = TypedQuery<
+ ShippingZone,
+ ShippingZoneVariables
+>(shippingZone);
diff --git a/saleor/static/dashboard-next/shipping/types/ShippingZone.ts b/saleor/static/dashboard-next/shipping/types/ShippingZone.ts
new file mode 100644
index 0000000000..9e734f708e
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/types/ShippingZone.ts
@@ -0,0 +1,73 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+import { ShippingMethodTypeEnum } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL query operation: ShippingZone
+// ====================================================
+
+export interface ShippingZone_shippingZone_countries {
+ __typename: "CountryDisplay";
+ code: string;
+ country: string;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods_minimumOrderPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods_minimumOrderWeight {
+ __typename: "Weight";
+ unit: string;
+ value: number;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods_maximumOrderPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods_maximumOrderWeight {
+ __typename: "Weight";
+ unit: string;
+ value: number;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZone_shippingZone_shippingMethods {
+ __typename: "ShippingMethod";
+ id: string;
+ minimumOrderPrice: ShippingZone_shippingZone_shippingMethods_minimumOrderPrice | null;
+ minimumOrderWeight: ShippingZone_shippingZone_shippingMethods_minimumOrderWeight | null;
+ maximumOrderPrice: ShippingZone_shippingZone_shippingMethods_maximumOrderPrice | null;
+ maximumOrderWeight: ShippingZone_shippingZone_shippingMethods_maximumOrderWeight | null;
+ name: string;
+ price: ShippingZone_shippingZone_shippingMethods_price | null;
+ type: ShippingMethodTypeEnum | null;
+}
+
+export interface ShippingZone_shippingZone {
+ __typename: "ShippingZone";
+ id: string;
+ countries: (ShippingZone_shippingZone_countries | null)[] | null;
+ name: string;
+ default: boolean;
+ shippingMethods: (ShippingZone_shippingZone_shippingMethods | null)[] | null;
+}
+
+export interface ShippingZone {
+ shippingZone: ShippingZone_shippingZone | null;
+}
+
+export interface ShippingZoneVariables {
+ id: string;
+}
diff --git a/saleor/static/dashboard-next/shipping/types/ShippingZoneDetailsFragment.ts b/saleor/static/dashboard-next/shipping/types/ShippingZoneDetailsFragment.ts
new file mode 100644
index 0000000000..6046afe6a2
--- /dev/null
+++ b/saleor/static/dashboard-next/shipping/types/ShippingZoneDetailsFragment.ts
@@ -0,0 +1,65 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+import { ShippingMethodTypeEnum } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL fragment: ShippingZoneDetailsFragment
+// ====================================================
+
+export interface ShippingZoneDetailsFragment_countries {
+ __typename: "CountryDisplay";
+ code: string;
+ country: string;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods_minimumOrderPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods_minimumOrderWeight {
+ __typename: "Weight";
+ unit: string;
+ value: number;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods_maximumOrderPrice {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods_maximumOrderWeight {
+ __typename: "Weight";
+ unit: string;
+ value: number;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface ShippingZoneDetailsFragment_shippingMethods {
+ __typename: "ShippingMethod";
+ id: string;
+ minimumOrderPrice: ShippingZoneDetailsFragment_shippingMethods_minimumOrderPrice | null;
+ minimumOrderWeight: ShippingZoneDetailsFragment_shippingMethods_minimumOrderWeight | null;
+ maximumOrderPrice: ShippingZoneDetailsFragment_shippingMethods_maximumOrderPrice | null;
+ maximumOrderWeight: ShippingZoneDetailsFragment_shippingMethods_maximumOrderWeight | null;
+ name: string;
+ price: ShippingZoneDetailsFragment_shippingMethods_price | null;
+ type: ShippingMethodTypeEnum | null;
+}
+
+export interface ShippingZoneDetailsFragment {
+ __typename: "ShippingZone";
+ id: string;
+ countries: (ShippingZoneDetailsFragment_countries | null)[] | null;
+ name: string;
+ default: boolean;
+ shippingMethods: (ShippingZoneDetailsFragment_shippingMethods | null)[] | null;
+}
diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.js
index d089158966..75529cc8d5 100644
--- a/saleor/static/dashboard-next/storybook/config.js
+++ b/saleor/static/dashboard-next/storybook/config.js
@@ -14,6 +14,7 @@ function loadStories() {
require("./stories/components/ErrorPage");
require("./stories/components/ExternalLink");
require("./stories/components/Money");
+ require("./stories/components/MoneyRange");
require("./stories/components/MultiAutocompleteSelectField");
require("./stories/components/MultiSelectField");
require("./stories/components/NotFoundPage");
@@ -28,6 +29,8 @@ function loadStories() {
require("./stories/components/StatusLabel");
require("./stories/components/TablePagination");
require("./stories/components/Timeline");
+ require("./stories/components/Weight");
+ require("./stories/components/WeightRange");
require("./stories/components/messages");
// Authentication
@@ -112,6 +115,7 @@ function loadStories() {
require("./stories/productTypes/ProductTypeListPage");
// Shipping
+ require("./stories/shipping/ShippingZoneDetailsPage");
require("./stories/shipping/ShippingZonesListPage");
// Site settings
diff --git a/saleor/static/dashboard-next/storybook/stories/components/MoneyRange.tsx b/saleor/static/dashboard-next/storybook/stories/components/MoneyRange.tsx
new file mode 100644
index 0000000000..a08f247d77
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/components/MoneyRange.tsx
@@ -0,0 +1,22 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import MoneyRange, { MoneyRangeProps } from "../../../components/MoneyRange";
+import Decorator from "../../Decorator";
+
+const props: MoneyRangeProps = {
+ from: {
+ amount: 5.2,
+ currency: "USD"
+ },
+ to: {
+ amount: 10.6,
+ currency: "USD"
+ }
+};
+
+storiesOf("Generics / Money range", module)
+ .addDecorator(Decorator)
+ .add("from", () => <MoneyRange {...props} to={undefined} />)
+ .add("to", () => <MoneyRange {...props} from={undefined} />)
+ .add("range", () => <MoneyRange {...props} />);
diff --git a/saleor/static/dashboard-next/storybook/stories/components/Weight.tsx b/saleor/static/dashboard-next/storybook/stories/components/Weight.tsx
new file mode 100644
index 0000000000..c2a69487c8
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/components/Weight.tsx
@@ -0,0 +1,16 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import Weight, { WeightProps } from "../../../components/Weight";
+import Decorator from "../../Decorator";
+
+const props: WeightProps = {
+ weight: {
+ unit: "kg",
+ value: 8.4
+ }
+};
+
+storiesOf("Generics / Weight", module)
+ .addDecorator(Decorator)
+ .add("default", () => <Weight {...props} />);
diff --git a/saleor/static/dashboard-next/storybook/stories/components/WeightRange.tsx b/saleor/static/dashboard-next/storybook/stories/components/WeightRange.tsx
new file mode 100644
index 0000000000..c8fd37e88f
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/components/WeightRange.tsx
@@ -0,0 +1,22 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import WeightRange, { WeightRangeProps } from "../../../components/WeightRange";
+import Decorator from "../../Decorator";
+
+const props: WeightRangeProps = {
+ from: {
+ unit: "kg",
+ value: 4.2
+ },
+ to: {
+ unit: "kg",
+ value: 81.9
+ }
+};
+
+storiesOf("Generics / Weight range", module)
+ .addDecorator(Decorator)
+ .add("from", () => <WeightRange {...props} to={undefined} />)
+ .add("to", () => <WeightRange {...props} from={undefined} />)
+ .add("range", () => <WeightRange {...props} />);
diff --git a/saleor/static/dashboard-next/storybook/stories/shipping/ShippingZoneDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/shipping/ShippingZoneDetailsPage.tsx
new file mode 100644
index 0000000000..127a0050b1
--- /dev/null
+++ b/saleor/static/dashboard-next/storybook/stories/shipping/ShippingZoneDetailsPage.tsx
@@ -0,0 +1,36 @@
+import { storiesOf } from "@storybook/react";
+import * as React from "react";
+
+import ShippingZoneDetailsPage, {
+ ShippingZoneDetailsPageProps
+} from "../../../shipping/components/ShippingZoneDetailsPage";
+import { shippingZone } from "../../../shipping/fixtures";
+import Decorator from "../../Decorator";
+
+const props: ShippingZoneDetailsPageProps = {
+ disabled: false,
+ onBack: () => undefined,
+ onCountryAdd: () => undefined,
+ onCountryRemove: () => undefined,
+ onDelete: () => undefined,
+ onPriceRateAdd: () => undefined,
+ onPriceRateEdit: () => undefined,
+ onPriceRateRemove: () => undefined,
+ onSubmit: () => undefined,
+ onWeightRateAdd: () => undefined,
+ onWeightRateEdit: () => undefined,
+ onWeightRateRemove: () => undefined,
+ saveButtonBarState: "default",
+ shippingZone
+};
+
+storiesOf("Views / Shipping / Shipping zone details", module)
+ .addDecorator(Decorator)
+ .add("default", () => <ShippingZoneDetailsPage {...props} />)
+ .add("loading", () => (
+ <ShippingZoneDetailsPage
+ {...props}
+ disabled={true}
+ shippingZone={undefined}
+ />
+ ));
diff --git a/saleor/static/dashboard-next/taxes/queries.ts b/saleor/static/dashboard-next/taxes/queries.ts
index a1292654c8..c20ecd4147 100644
--- a/saleor/static/dashboard-next/taxes/queries.ts
+++ b/saleor/static/dashboard-next/taxes/queries.ts
@@ -35,7 +35,7 @@ const countryList = gql`
shop {
...ShopTaxesFragment
countries {
- ...CountryFragment
+ ...CountryWithTaxesFragment
}
}
}
diff --git a/saleor/static/dashboard-next/taxes/types/CountryList.ts b/saleor/static/dashboard-next/taxes/types/CountryList.ts
index 5da20bf20a..90393b767b 100644
--- a/saleor/static/dashboard-next/taxes/types/CountryList.ts
+++ b/saleor/static/dashboard-next/taxes/types/CountryList.ts
@@ -1,14 +1,29 @@
/* tslint:disable */
// This file was automatically generated and should not be edited.
+import { TaxRateType } from "./../../types/globalTypes";
+
// ====================================================
// GraphQL query operation: CountryList
// ====================================================
+export interface CountryList_shop_countries_vat_reducedRates {
+ __typename: "ReducedRate";
+ rateType: TaxRateType;
+ rate: number;
+}
+
+export interface CountryList_shop_countries_vat {
+ __typename: "VAT";
+ standardRate: number | null;
+ reducedRates: (CountryList_shop_countries_vat_reducedRates | null)[];
+}
+
export interface CountryList_shop_countries {
__typename: "CountryDisplay";
country: string;
code: string;
+ vat: CountryList_shop_countries_vat | null;
}
export interface CountryList_shop {