Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add country selection
dominik-zeglen0d05d21d3908
diff --git a/package-lock.json b/package-lock.jsonindex 2b88a7b9fa..564fd8673b 100644--- a/package-lock.json+++ b/package-lock.json@@ -5096,6 +5096,11 @@"@types/node": "*"}},+ "@types/fuzzaldrin": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/@types/fuzzaldrin/-/fuzzaldrin-2.1.1.tgz",+ "integrity": "sha512-KHKQApfuxY67bNVCvRYXEJA/8krvf27T4aA5dTQV8GBx19FKOhcvznbHBVqR7pFJhXZk/yYMWiPEPJ/JVdQ0jQ=="+ },"@types/history": {"version": "4.6.2","resolved": "https://registry.npmjs.org/@types/history/-/history-4.6.2.tgz",@@ -12998,14 +13003,12 @@"balanced-match": {"version": "1.0.0","bundled": true,- "dev": true,- "optional": true+ "dev": true},"brace-expansion": {"version": "1.1.11","bundled": true,"dev": true,- "optional": true,"requires": {"balanced-match": "^1.0.0","concat-map": "0.0.1"@@ -13020,20 +13023,17 @@"code-point-at": {"version": "1.1.0","bundled": true,- "dev": true,- "optional": true+ "dev": true},"concat-map": {"version": "0.0.1","bundled": true,- "dev": true,- "optional": true+ "dev": true},"console-control-strings": {"version": "1.1.0","bundled": true,- "dev": true,- "optional": true+ "dev": true},"core-util-is": {"version": "1.0.2",@@ -13150,8 +13150,7 @@"inherits": {"version": "2.0.3","bundled": true,- "dev": true,- "optional": true+ "dev": true},"ini": {"version": "1.3.5",@@ -13163,7 +13162,6 @@"version": "1.0.0","bundled": true,"dev": true,- "optional": true,"requires": {"number-is-nan": "^1.0.0"}@@ -13178,7 +13176,6 @@"version": "3.0.4","bundled": true,"dev": true,- "optional": true,"requires": {"brace-expansion": "^1.1.7"}@@ -13186,14 +13183,12 @@"minimist": {"version": "0.0.8","bundled": true,- "dev": true,- "optional": true+ "dev": true},"minipass": {"version": "2.2.4","bundled": true,"dev": true,- "optional": true,"requires": {"safe-buffer": "^5.1.1","yallist": "^3.0.0"@@ -13212,7 +13207,6 @@"version": "0.5.1","bundled": true,"dev": true,- "optional": true,"requires": {"minimist": "0.0.8"}@@ -13293,8 +13287,7 @@"number-is-nan": {"version": "1.0.1","bundled": true,- "dev": true,- "optional": true+ "dev": true},"object-assign": {"version": "4.1.1",@@ -13306,7 +13299,6 @@"version": "1.4.0","bundled": true,"dev": true,- "optional": true,"requires": {"wrappy": "1"}@@ -13428,7 +13420,6 @@"version": "1.0.2","bundled": true,"dev": true,- "optional": true,"requires": {"code-point-at": "^1.0.0","is-fullwidth-code-point": "^1.0.0",@@ -13540,6 +13531,11 @@"integrity": "sha512-ESBRkGLWMuVkapqYCcNO1uqMg5qbCKkgb+VS6wsy17Rix0/cMS9kSOZoYkjH8Ko//pgJ/EEGu0GTjk2mjX2LGQ==","dev": true},+ "fuzzaldrin": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/fuzzaldrin/-/fuzzaldrin-2.1.0.tgz",+ "integrity": "sha1-kCBMPi/appQbso0WZF1BgGOpDps="+ },"gauge": {"version": "2.7.4","resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",diff --git a/package.json b/package.jsonindex 4b40e4b943..36b62488ac 100644--- a/package.json+++ b/package.json@@ -21,6 +21,7 @@"@material-ui/icons": "^3.0.1","@types/classnames": "^2.2.6","@types/enzyme": "^3.1.15",+ "@types/fuzzaldrin": "^2.1.1","@types/moment-timezone": "^0.5.9","@types/react-dropzone": "^4.2.2","@types/react-helmet": "^5.0.7",@@ -43,6 +44,7 @@"detect-passive-events": "^1.0.4","downshift": "^1.31.14","dropzone": "^5.2.0",+ "fuzzaldrin": "^2.1.0","graphql": "^14.0.2","graphql-tag": "^2.10.0","i18next": "^11.2.2",diff --git a/saleor/static/dashboard-next/components/Shop/query.ts b/saleor/static/dashboard-next/components/Shop/query.tsindex 7076ec6610..af1df82ac5 100644--- a/saleor/static/dashboard-next/components/Shop/query.ts+++ b/saleor/static/dashboard-next/components/Shop/query.ts@@ -6,6 +6,10 @@ import { ShopInfo } from "./types/ShopInfo";const shopInfo = gql`query ShopInfo {shop {+ countries {+ country+ code+ }defaultCountry {codecountrydiff --git a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.tsindex 1ee4fab48b..3caecac8d5 100644--- a/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts+++ b/saleor/static/dashboard-next/components/Shop/types/ShopInfo.ts@@ -7,6 +7,12 @@ import { WeightUnitsEnum } from "./../../../types/globalTypes";// GraphQL query operation: ShopInfo// ====================================================+export interface ShopInfo_shop_countries {+ __typename: "CountryDisplay";+ country: string;+ code: string;+}+export interface ShopInfo_shop_defaultCountry {__typename: "CountryDisplay";code: string;@@ -21,6 +27,7 @@ export interface ShopInfo_shop_domain {export interface ShopInfo_shop {__typename: "Shop";+ countries: (ShopInfo_shop_countries | null)[];defaultCountry: ShopInfo_shop_defaultCountry | null;defaultCurrency: string;defaultWeightUnit: WeightUnitsEnum | null;diff --git a/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.tsx b/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.tsxnew file mode 100644index 0000000000..e4f7c84fcf--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.tsx@@ -0,0 +1,164 @@+import Button from "@material-ui/core/Button";+import Checkbox from "@material-ui/core/Checkbox";+import Dialog from "@material-ui/core/Dialog";+import DialogActions from "@material-ui/core/DialogActions";+import DialogContent from "@material-ui/core/DialogContent";+import DialogTitle from "@material-ui/core/DialogTitle";+import { createStyles, 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 TableRow from "@material-ui/core/TableRow";+import TextField from "@material-ui/core/TextField";+import Typography from "@material-ui/core/Typography";+import { filter } from "fuzzaldrin";+import * as React from "react";++import ConfirmButton, {+ ConfirmButtonTransitionState+} from "../../../components/ConfirmButton/ConfirmButton";+import Form from "../../../components/Form";+import FormSpacer from "../../../components/FormSpacer";+import Hr from "../../../components/Hr";+import { ShopInfo_shop_countries } from "../../../components/Shop/types/ShopInfo";+import i18n from "../../../i18n";++interface FormData {+ countries: string[];+ query: string;+}++export interface DiscountCountrySelectDialogProps {+ confirmButtonState: ConfirmButtonTransitionState;+ countries: ShopInfo_shop_countries[];+ initial: string[];+ open: boolean;+ onClose: () => void;+ onConfirm: (data: FormData) => void;+}++const styles = createStyles({+ checkboxCell: {+ paddingLeft: 0+ },+ container: {+ maxHeight: 500+ },+ wideCell: {+ width: "100%"+ }+});+const DiscountCountrySelectDialog = withStyles(styles, {+ name: "DiscountCountrySelectDialog"+})(+ ({+ classes,+ confirmButtonState,+ onClose,+ countries,+ open,+ initial,+ onConfirm+ }: DiscountCountrySelectDialogProps & WithStyles<typeof styles>) => {+ const initialForm: FormData = {+ countries: initial,+ query: ""+ };+ return (+ <Dialog open={open} fullWidth maxWidth="sm">+ <Form initial={initialForm} onSubmit={onConfirm}>+ {({ data, change }) => (+ <>+ <DialogTitle>{i18n.t("Assign Countries")}</DialogTitle>+ <DialogContent>+ <Typography>+ {i18n.t(+ "Choose countries you want to add to shipping zone from list below"+ )}+ </Typography>+ <FormSpacer />+ <TextField+ name="query"+ value={data.query}+ onChange={event => change(event, () => fetch(data.query))}+ label={i18n.t("Search Countries", {+ context: "product search input label"+ })}+ placeholder={i18n.t("Search by country name", {+ context: "country search input placeholder"+ })}+ fullWidth+ />+ </DialogContent>+ <Hr />+ <DialogContent className={classes.container}>+ <Table>+ <TableBody>+ {filter(countries, data.query, {+ key: "country"+ }).map(country => (+ <TableRow key={country.code}>+ <TableCell className={classes.wideCell}>+ {country.country}+ </TableCell>+ <TableCell+ padding="checkbox"+ className={classes.checkboxCell}+ >+ <Checkbox+ checked={+ !!data.countries.find(+ selectedCountries =>+ selectedCountries === country.code+ )+ }+ onChange={() =>+ data.countries.find(+ selectedCountries =>+ selectedCountries === country.code+ )+ ? change({+ target: {+ name: "countries" as keyof FormData,+ value: data.countries.filter(+ selectedCountries =>+ selectedCountries !== country.code+ )+ }+ } as any)+ : change({+ target: {+ name: "countries" as keyof FormData,+ value: [...data.countries, country.code]+ }+ } as any)+ }+ />+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </DialogContent>+ <DialogActions>+ <Button onClick={onClose}>+ {i18n.t("Cancel", { context: "button" })}+ </Button>+ <ConfirmButton+ transitionState={confirmButtonState}+ color="primary"+ variant="contained"+ type="submit"+ >+ {i18n.t("Assign countries", { context: "button" })}+ </ConfirmButton>+ </DialogActions>+ </>+ )}+ </Form>+ </Dialog>+ );+ }+);+DiscountCountrySelectDialog.displayName = "DiscountCountrySelectDialog";+export default DiscountCountrySelectDialog;diff --git a/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/index.ts b/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/index.tsnew file mode 100644index 0000000000..cbbee8a484--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/DiscountCountrySelectDialog/index.ts@@ -0,0 +1,2 @@+export { default } from './DiscountCountrySelectDialog';+export * from './DiscountCountrySelectDialog';\ No newline at end of filediff --git a/saleor/static/dashboard-next/discounts/queries.ts b/saleor/static/dashboard-next/discounts/queries.tsindex e982291c7e..e5905952b7 100644--- a/saleor/static/dashboard-next/discounts/queries.ts+++ b/saleor/static/dashboard-next/discounts/queries.ts@@ -87,6 +87,10 @@ export const voucherFragment = gql`usageLimitdiscountValueTypediscountValue+ countries {+ code+ country+ }minAmountSpent {currencyamount@@ -154,10 +158,6 @@ export const voucherDetailsFragment = gql`...PageInfoFragment}}- countries {- code- country- }}`;diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.tsindex 29078c3f41..72346117a5 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesAdd.ts@@ -13,6 +13,12 @@ export interface VoucherCataloguesAdd_voucherCataloguesAdd_errors {message: string | null;}+export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher_minAmountSpent {__typename: "Money";currency: string;@@ -123,12 +129,6 @@ export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher_categories {pageInfo: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_categories_pageInfo;}-export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries {- __typename: "CountryDisplay";- code: string;- country: string;-}-export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher {__typename: "Voucher";id: string;@@ -138,6 +138,7 @@ export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries | null)[] | null;minAmountSpent: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_minAmountSpent | null;type: VoucherType;code: string;@@ -146,7 +147,6 @@ export interface VoucherCataloguesAdd_voucherCataloguesAdd_voucher {products: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_products | null;collections: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_collections | null;categories: VoucherCataloguesAdd_voucherCataloguesAdd_voucher_categories | null;- countries: (VoucherCataloguesAdd_voucherCataloguesAdd_voucher_countries | null)[] | null;}export interface VoucherCataloguesAdd_voucherCataloguesAdd {diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.tsindex 920d7f664a..8abb7b1170 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherCataloguesRemove.ts@@ -13,6 +13,12 @@ export interface VoucherCataloguesRemove_voucherCataloguesRemove_errors {message: string | null;}+export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher_minAmountSpent {__typename: "Money";currency: string;@@ -123,12 +129,6 @@ export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher_categorpageInfo: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_categories_pageInfo;}-export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries {- __typename: "CountryDisplay";- code: string;- country: string;-}-export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher {__typename: "Voucher";id: string;@@ -138,6 +138,7 @@ export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries | null)[] | null;minAmountSpent: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_minAmountSpent | null;type: VoucherType;code: string;@@ -146,7 +147,6 @@ export interface VoucherCataloguesRemove_voucherCataloguesRemove_voucher {products: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_products | null;collections: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_collections | null;categories: VoucherCataloguesRemove_voucherCataloguesRemove_voucher_categories | null;- countries: (VoucherCataloguesRemove_voucherCataloguesRemove_voucher_countries | null)[] | null;}export interface VoucherCataloguesRemove_voucherCataloguesRemove {diff --git a/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts b/saleor/static/dashboard-next/discounts/types/VoucherCreate.tsindex 96aca4abb9..d7d7ab216a 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherCreate.ts@@ -13,6 +13,12 @@ export interface VoucherCreate_voucherCreate_errors {message: string | null;}+export interface VoucherCreate_voucherCreate_voucher_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherCreate_voucherCreate_voucher_minAmountSpent {__typename: "Money";currency: string;@@ -28,6 +34,7 @@ export interface VoucherCreate_voucherCreate_voucher {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherCreate_voucherCreate_voucher_countries | null)[] | null;minAmountSpent: VoucherCreate_voucherCreate_voucher_minAmountSpent | null;}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetails.tsindex 0d9bcec683..0444824312 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts@@ -7,6 +7,12 @@ import { VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes// GraphQL query operation: VoucherDetails// ====================================================+export interface VoucherDetails_voucher_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherDetails_voucher_minAmountSpent {__typename: "Money";currency: string;@@ -117,12 +123,6 @@ export interface VoucherDetails_voucher_categories {pageInfo: VoucherDetails_voucher_categories_pageInfo;}-export interface VoucherDetails_voucher_countries {- __typename: "CountryDisplay";- code: string;- country: string;-}-export interface VoucherDetails_voucher {__typename: "Voucher";id: string;@@ -132,6 +132,7 @@ export interface VoucherDetails_voucher {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherDetails_voucher_countries | null)[] | null;minAmountSpent: VoucherDetails_voucher_minAmountSpent | null;type: VoucherType;code: string;@@ -140,7 +141,6 @@ export interface VoucherDetails_voucher {products: VoucherDetails_voucher_products | null;collections: VoucherDetails_voucher_collections | null;categories: VoucherDetails_voucher_categories | null;- countries: (VoucherDetails_voucher_countries | null)[] | null;}export interface VoucherDetails {diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.tsindex b763a8d6d8..aeb84c93b1 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts@@ -7,6 +7,12 @@ import { VoucherDiscountValueType, VoucherType } from "./../../types/globalTypes// GraphQL fragment: VoucherDetailsFragment// ====================================================+export interface VoucherDetailsFragment_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherDetailsFragment_minAmountSpent {__typename: "Money";currency: string;@@ -117,12 +123,6 @@ export interface VoucherDetailsFragment_categories {pageInfo: VoucherDetailsFragment_categories_pageInfo;}-export interface VoucherDetailsFragment_countries {- __typename: "CountryDisplay";- code: string;- country: string;-}-export interface VoucherDetailsFragment {__typename: "Voucher";id: string;@@ -132,6 +132,7 @@ export interface VoucherDetailsFragment {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherDetailsFragment_countries | null)[] | null;minAmountSpent: VoucherDetailsFragment_minAmountSpent | null;type: VoucherType;code: string;@@ -140,5 +141,4 @@ export interface VoucherDetailsFragment {products: VoucherDetailsFragment_products | null;collections: VoucherDetailsFragment_collections | null;categories: VoucherDetailsFragment_categories | null;- countries: (VoucherDetailsFragment_countries | null)[] | null;}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherFragment.tsindex 5dfdda1b34..14de40352f 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts@@ -7,6 +7,12 @@ import { VoucherDiscountValueType } from "./../../types/globalTypes";// GraphQL fragment: VoucherFragment// ====================================================+export interface VoucherFragment_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherFragment_minAmountSpent {__typename: "Money";currency: string;@@ -22,5 +28,6 @@ export interface VoucherFragment {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherFragment_countries | null)[] | null;minAmountSpent: VoucherFragment_minAmountSpent | null;}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherList.ts b/saleor/static/dashboard-next/discounts/types/VoucherList.tsindex 917cb2d8db..1e44887cf9 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherList.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherList.ts@@ -7,6 +7,12 @@ import { VoucherDiscountValueType } from "./../../types/globalTypes";// GraphQL query operation: VoucherList// ====================================================+export interface VoucherList_vouchers_edges_node_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherList_vouchers_edges_node_minAmountSpent {__typename: "Money";currency: string;@@ -22,6 +28,7 @@ export interface VoucherList_vouchers_edges_node {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherList_vouchers_edges_node_countries | null)[] | null;minAmountSpent: VoucherList_vouchers_edges_node_minAmountSpent | null;}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts b/saleor/static/dashboard-next/discounts/types/VoucherUpdate.tsindex c850bfe3dd..c7078c6f4f 100644--- a/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts+++ b/saleor/static/dashboard-next/discounts/types/VoucherUpdate.ts@@ -13,6 +13,12 @@ export interface VoucherUpdate_voucherUpdate_errors {message: string | null;}+export interface VoucherUpdate_voucherUpdate_voucher_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}+export interface VoucherUpdate_voucherUpdate_voucher_minAmountSpent {__typename: "Money";currency: string;@@ -28,6 +34,7 @@ export interface VoucherUpdate_voucherUpdate_voucher {usageLimit: number | null;discountValueType: VoucherDiscountValueType;discountValue: number;+ countries: (VoucherUpdate_voucherUpdate_voucher_countries | null)[] | null;minAmountSpent: VoucherUpdate_voucherUpdate_voucher_minAmountSpent | null;}diff --git a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsxindex 7015c87903..2fbc550ca4 100644--- a/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx+++ b/saleor/static/dashboard-next/discounts/views/VoucherDetails/index.tsx@@ -49,8 +49,11 @@ import {voucherAssignProductsPath,voucherAssignProductsUrl,voucherDeletePath,- voucherDeleteUrl+ voucherDeleteUrl,+ voucherAssignCountriesPath} from "./urls";+import DiscountCountrySelectDialog from "../../components/DiscountCountrySelectDialog";+import { VoucherUpdate } from "../../types/VoucherUpdate";const PAGINATE_BY = 20;@@ -102,6 +105,7 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({navigate(voucherUrl(id), true, true);}};+const handleVoucherDelete = (data: VoucherDelete) => {if (data.voucherDelete.errors.length === 0) {pushMessage({@@ -113,6 +117,12 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({}};+ const handleVoucherUpdate = (data: VoucherUpdate) => {+ if (data.voucherUpdate.errors.length === 0) {+ navigate(voucherUrl(id), true, true);+ }+ };+return (<TypedVoucherCataloguesRemove>{(voucherCataloguesRemove, voucherCataloguesRemoveOpts) => (@@ -120,7 +130,7 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({onCompleted={handleCatalogueAdd}>{(voucherCataloguesAdd, voucherCataloguesAddOpts) => (- <TypedVoucherUpdate>+ <TypedVoucherUpdate onCompleted={handleVoucherUpdate}>{(voucherUpdate, voucherUpdateOpts) => (<TypedVoucherDeleteonCompleted={handleVoucherDelete}@@ -551,6 +561,45 @@ export const VoucherDetails: React.StatelessComponent<VoucherDetailsProps> = ({</ActionDialog>)}/>+ <Route+ path={voucherAssignCountriesPath(+ ":id"+ )}+ render={({ match }) => (+ <DiscountCountrySelectDialog+ confirmButtonState={+ formTransitionState+ }+ countries={maybe(+ () => shop.countries,+ []+ )}+ onClose={() =>+ navigate(voucherUrl(id))+ }+ onConfirm={formData =>+ voucherUpdate({+ variables: {+ id,+ input: {+ countries:+ formData.countries+ }+ }+ })+ }+ open={!!match}+ initial={maybe(+ () =>+ data.voucher.countries.map(+ country =>+ country.code+ ),+ []+ )}+ />+ )}+ /></>)}</Paginator>diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 92e0120461..f2b22b3fd5 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -54,6 +54,7 @@ function loadStories() {require("./stories/customers/CustomerListPage");// Discounts+ require("./stories/discounts/DiscountCountrySelectDialog");require("./stories/discounts/SaleCreatePage");require("./stories/discounts/SaleDetailsPage");require("./stories/discounts/SaleListPage");diff --git a/saleor/static/dashboard-next/storybook/stories/discounts/DiscountCountrySelectDialog.tsx b/saleor/static/dashboard-next/storybook/stories/discounts/DiscountCountrySelectDialog.tsxnew file mode 100644index 0000000000..d4c8c5df67--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/discounts/DiscountCountrySelectDialog.tsx@@ -0,0 +1,26 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import DiscountCountrySelectDialog, {+ DiscountCountrySelectDialogProps+} from "../../../discounts/components/DiscountCountrySelectDialog";+import Decorator from "../../Decorator";++const props: DiscountCountrySelectDialogProps = {+ confirmButtonState: "default",+ countries: [+ { __typename: "CountryDisplay", code: "AF", country: "Afghanistan" },+ { __typename: "CountryDisplay", code: "AX", country: "Åland Islands" },+ { __typename: "CountryDisplay", code: "AL", country: "Albania" },+ { __typename: "CountryDisplay", code: "DZ", country: "Algeria" },+ { __typename: "CountryDisplay", code: "AS", country: "American Samoa" }+ ],+ initial: ["AX", "AL"],+ onClose: () => undefined,+ onConfirm: () => undefined,+ open: true+};++storiesOf("Discounts / Select countries", module)+ .addDecorator(Decorator)+ .add("default", () => <DiscountCountrySelectDialog {...props} />);