Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add basic voucher details view
dominik-zeglen8bc8e4fa4d6c
diff --git a/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsxnew file mode 100644index 0000000000..de915cfd16--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx@@ -0,0 +1,67 @@+import * as React from "react";++import Container from "../../../components/Container";+import Form from "../../../components/Form";+import Grid from "../../../components/Grid";+import PageHeader from "../../../components/PageHeader";+import { maybe } from "../../../misc";+import { ListProps } from "../../../types";+import { VoucherType } from "../../../types/globalTypes";+import { VoucherDetails_voucher } from "../../types/VoucherDetails";+import VoucherInfo from "../VoucherInfo";+import VoucherSummary from "../VoucherSummary";++export interface FormData {+ code: string;+ name: string;+ type: VoucherType;+}++export interface VoucherDetailsPageProps+ extends Pick<ListProps, Exclude<keyof ListProps, "onRowClick">> {+ defaultCurrency: string;+ voucher: VoucherDetails_voucher;+ onBack: () => void;+ onSubmit: (data: FormData) => void;+}++const VoucherDetailsPage: React.StatelessComponent<VoucherDetailsPageProps> = ({+ defaultCurrency,+ disabled,+ pageInfo,+ voucher,+ onBack,+ onNextPage,+ onPreviousPage,+ onSubmit+}) => {+ const initialForm: FormData = {+ code: maybe(() => voucher.code),+ name: maybe(() => voucher.name),+ type: maybe(() => voucher.type)+ };++ return (+ <Form initial={initialForm} onSubmit={onSubmit}>+ {({ change, data, errors, hasChanged, submit }) => (+ <Container width="md">+ <PageHeader title={maybe(() => voucher.name)} onBack={onBack} />+ <Grid>+ <div>+ <VoucherInfo data={data} disabled={disabled} onChange={change} />+ </div>+ <div>+ <VoucherSummary+ defaultCurrency={defaultCurrency}+ voucher={voucher}+ />+ </div>+ </Grid>+ </Container>+ )}+ </Form>+ );+};+VoucherDetailsPage.displayName = "VoucherDetailsPage";++export default VoucherDetailsPage;diff --git a/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/index.ts b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/index.tsnew file mode 100644index 0000000000..d165924b65--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherDetailsPage/index.ts@@ -0,0 +1,2 @@+export { default } from "./VoucherDetailsPage";+export * from "./VoucherDetailsPage";diff --git a/saleor/static/dashboard-next/discounts/components/VoucherInfo/VoucherInfo.tsx b/saleor/static/dashboard-next/discounts/components/VoucherInfo/VoucherInfo.tsxnew file mode 100644index 0000000000..72aa2b69ca--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherInfo/VoucherInfo.tsx@@ -0,0 +1,90 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import {+ createStyles,+ Theme,+ withStyles,+ WithStyles+} from "@material-ui/core/styles";+import TextField from "@material-ui/core/TextField";+import * as React from "react";++import CardTitle from "../../../components/CardTitle";+import FormSpacer from "../../../components/FormSpacer";+import SingleSelectField from "../../../components/SingleSelectField";+import i18n from "../../../i18n";+import { VoucherType } from "../../../types/globalTypes";+import { translateVoucherTypes } from "../../translations";+import { FormData } from "../VoucherDetailsPage";++interface VoucherInfoProps {+ data: FormData;+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const styles = (theme: Theme) =>+ createStyles({+ nameInput: {+ gridColumnEnd: "span 2"+ },+ root: {+ display: "grid",+ gridColumnGap: theme.spacing.unit * 2 + "px",+ gridTemplateColumns: "1fr 1fr"+ }+ });++const VoucherInfo = withStyles(styles, {+ name: "VoucherInfo"+})(+ ({+ classes,+ data,+ disabled,+ onChange+ }: VoucherInfoProps & WithStyles<typeof styles>) => {+ const translatedVoucherTypes = translateVoucherTypes();+ const voucherTypeChoices = Object.values(VoucherType).map(type => ({+ label: translatedVoucherTypes[type],+ value: type+ }));++ return (+ <Card>+ <CardTitle title={i18n.t("General Informations")} />+ <CardContent>+ <TextField+ className={classes.nameInput}+ disabled={disabled}+ fullWidth+ name={"name" as keyof FormData}+ label={i18n.t("Name")}+ value={data.name}+ onChange={onChange}+ />+ <FormSpacer />+ <div className={classes.root}>+ <TextField+ disabled={disabled}+ fullWidth+ name={"code" as keyof FormData}+ label={i18n.t("Discount Code")}+ value={data.code}+ onChange={onChange}+ />+ <SingleSelectField+ choices={voucherTypeChoices}+ disabled={disabled}+ name={"type" as keyof FormData}+ label={i18n.t("Type of Discount")}+ value={data.type}+ onChange={onChange}+ />+ </div>+ </CardContent>+ </Card>+ );+ }+);+export default VoucherInfo;diff --git a/saleor/static/dashboard-next/discounts/components/VoucherInfo/index.ts b/saleor/static/dashboard-next/discounts/components/VoucherInfo/index.tsnew file mode 100644index 0000000000..0f852b9106--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherInfo/index.ts@@ -0,0 +1,2 @@+export { default } from "./VoucherInfo";+export * from "./VoucherInfo";diff --git a/saleor/static/dashboard-next/discounts/components/VoucherSummary/VoucherSummary.tsx b/saleor/static/dashboard-next/discounts/components/VoucherSummary/VoucherSummary.tsxnew file mode 100644index 0000000000..49aea657c0--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherSummary/VoucherSummary.tsx@@ -0,0 +1,128 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import Typography from "@material-ui/core/Typography";+import * as React from "react";++import CardTitle from "../../../components/CardTitle";+import DateFormatter from "../../../components/DateFormatter";+import FormSpacer from "../../../components/FormSpacer";+import Hr from "../../../components/Hr";+import Money from "../../../components/Money";+import Percent from "../../../components/Percent";+import Skeleton from "../../../components/Skeleton";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import {+ VoucherDiscountValueType,+ VoucherType+} from "../../../types/globalTypes";+import { translateVoucherTypes } from "../../translations";+import { VoucherDetails_voucher } from "../../types/VoucherDetails";++export interface VoucherSummaryProps {+ defaultCurrency: string;+ voucher: VoucherDetails_voucher;+}++const VoucherSummary: React.StatelessComponent<VoucherSummaryProps> = ({+ defaultCurrency,+ voucher+}) => {+ const translatedVoucherTypes = translateVoucherTypes();++ return (+ <Card>+ <CardTitle title={i18n.t("Summary")} />+ <CardContent>+ <Typography variant="body2">{i18n.t("Name")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(() => voucher.name, <Skeleton />)}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("Applies to")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () => translatedVoucherTypes[voucher.type],+ <Skeleton />+ )}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("Value")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () =>+ voucher.discountValueType === VoucherDiscountValueType.FIXED ? (+ <Money+ money={{+ amount: voucher.discountValue,+ currency: defaultCurrency+ }}+ />+ ) : (+ <Percent amount={voucher.discountValue} />+ ),+ <Skeleton />+ )}+ </Typography>+ </CardContent>++ <Hr />++ <CardContent>+ <Typography variant="body2">{i18n.t("Start Date")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () => (+ <DateFormatter date={voucher.startDate} />+ ),+ <Skeleton />+ )}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("End Date")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () =>+ voucher.endDate === null ? (+ "-"+ ) : (+ <DateFormatter date={voucher.endDate} />+ ),+ <Skeleton />+ )}+ </Typography>+ </CardContent>++ <Hr />++ <CardContent>+ <Typography variant="body2">{i18n.t("Min. Order Value")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () =>+ voucher.minAmountSpent ? (+ <Money money={voucher.minAmountSpent} />+ ) : (+ "-"+ ),+ <Skeleton />+ )}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("Usage Limit")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () => (voucher.usageLimit === null ? "-" : voucher.usageLimit),+ <Skeleton />+ )}+ </Typography>+ </CardContent>+ </Card>+ );+};+VoucherSummary.displayName = "VoucherSummary";+export default VoucherSummary;diff --git a/saleor/static/dashboard-next/discounts/components/VoucherSummary/index.ts b/saleor/static/dashboard-next/discounts/components/VoucherSummary/index.tsnew file mode 100644index 0000000000..a7c1bebc13--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/VoucherSummary/index.ts@@ -0,0 +1,2 @@+export { default } from "./VoucherSummary";+export * from "./VoucherSummary";diff --git a/saleor/static/dashboard-next/discounts/fixtures.ts b/saleor/static/dashboard-next/discounts/fixtures.tsindex eebd5dd251..048b4c65e4 100644--- a/saleor/static/dashboard-next/discounts/fixtures.ts+++ b/saleor/static/dashboard-next/discounts/fixtures.ts@@ -1,7 +1,13 @@import * as placeholderImage from "../../images/placeholder60x60.png";-import { SaleType, VoucherDiscountValueType } from "../types/globalTypes";+import {+ SaleType,+ VoucherCountries,+ VoucherDiscountValueType,+ VoucherType+} from "../types/globalTypes";import { SaleDetails_sale } from "./types/SaleDetails";import { SaleList_sales_edges_node } from "./types/SaleList";+import { VoucherDetails_voucher } from "./types/VoucherDetails";import { VoucherList_vouchers_edges_node } from "./types/VoucherList";export const saleList: SaleList_sales_edges_node[] = [@@ -222,3 +228,60 @@ export const sale: SaleDetails_sale = {type: "PERCENTAGE" as SaleType,value: 30};++export const voucherDetails: VoucherDetails_voucher = {+ __typename: "Voucher",+ applyOncePerOrder: false,+ categories: {+ __typename: "CategoryCountableConnection",+ edges: [],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: "YXJyYXljb25uZWN0aW9uOjM=",+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: "YXJyYXljb25uZWN0aW9uOjA="+ },+ totalCount: 0+ },+ code: "DISCOUNT",+ collections: {+ __typename: "CollectionCountableConnection",+ edges: [],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: "YXJyYXljb25uZWN0aW9uOjM=",+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: "YXJyYXljb25uZWN0aW9uOjA="+ },+ totalCount: 0+ },+ countries: VoucherCountries.DE,+ discountValue: 25,+ discountValueType: VoucherDiscountValueType.FIXED,+ endDate: null,+ id: "Vm91Y2hlcjoy",+ minAmountSpent: {+ __typename: "Money",+ amount: 200,+ currency: "USD"+ },+ name: "Big order discount",+ products: {+ __typename: "ProductCountableConnection",+ edges: [],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: "YXJyYXljb25uZWN0aW9uOjM=",+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: "YXJyYXljb25uZWN0aW9uOjA="+ },+ totalCount: 0+ },+ startDate: "2018-11-27",+ type: VoucherType.VALUE,+ usageLimit: null,+ used: 0+};diff --git a/saleor/static/dashboard-next/discounts/queries.ts b/saleor/static/dashboard-next/discounts/queries.tsindex 226281fc5d..bb2863b4b9 100644--- a/saleor/static/dashboard-next/discounts/queries.ts+++ b/saleor/static/dashboard-next/discounts/queries.ts@@ -3,8 +3,92 @@ import gql from "graphql-tag";import { pageInfoFragment, TypedQuery } from "../queries";import { SaleDetails, SaleDetailsVariables } from "./types/SaleDetails";import { SaleList, SaleListVariables } from "./types/SaleList";+import {+ VoucherDetails,+ VoucherDetailsVariables+} from "./types/VoucherDetails";import { VoucherList, VoucherListVariables } from "./types/VoucherList";+export const voucherFragment = gql`+ fragment VoucherFragment on Voucher {+ id+ name+ startDate+ endDate+ usageLimit+ discountValueType+ discountValue+ minAmountSpent {+ currency+ amount+ }+ }+`;++export const voucherDetailsFragment = gql`+ ${pageInfoFragment}+ ${voucherFragment}+ fragment VoucherDetailsFragment on Voucher {+ ...VoucherFragment+ type+ code+ usageLimit+ used+ applyOncePerOrder+ products(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ productType {+ id+ name+ }+ isPublished+ thumbnail {+ url+ }+ }+ }+ totalCount+ pageInfo {+ ...PageInfoFragment+ }+ }+ collections(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ products {+ totalCount+ }+ }+ }+ totalCount+ pageInfo {+ ...PageInfoFragment+ }+ }+ categories(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ products {+ totalCount+ }+ }+ }+ totalCount+ pageInfo {+ ...PageInfoFragment+ }+ }+ countries+ }+`;+export const saleList = gql`${pageInfoFragment}query SaleList($after: String, $before: String, $first: Int, $last: Int) {@@ -29,21 +113,12 @@ export const TypedSaleList = TypedQuery<SaleList, SaleListVariables>(saleList);export const voucherList = gql`${pageInfoFragment}+ ${voucherFragment}query VoucherList($after: String, $before: String, $first: Int, $last: Int) {vouchers(after: $after, before: $before, first: $first, last: $last) {edges {node {- id- name- startDate- endDate- usageLimit- discountValueType- discountValue- minAmountSpent {- currency- amount- }+ ...VoucherFragment}}pageInfo {@@ -125,3 +200,22 @@ export const saleDetails = gql`export const TypedSaleDetails = TypedQuery<SaleDetails, SaleDetailsVariables>(saleDetails);++const voucherDetails = gql`+ ${voucherDetailsFragment}+ query VoucherDetails(+ $id: ID!+ $after: String+ $before: String+ $first: Int+ $last: Int+ ) {+ voucher(id: $id) {+ ...VoucherDetailsFragment+ }+ }+`;+export const TypedVoucherDetails = TypedQuery<+ VoucherDetails,+ VoucherDetailsVariables+>(voucherDetails);diff --git a/saleor/static/dashboard-next/discounts/translations.ts b/saleor/static/dashboard-next/discounts/translations.tsnew file mode 100644index 0000000000..b6f6af8e52--- /dev/null+++ b/saleor/static/dashboard-next/discounts/translations.ts@@ -0,0 +1,10 @@+import i18n from "../i18n";+import { VoucherType } from "../types/globalTypes";++export const translateVoucherTypes = () => ({+ [VoucherType.CATEGORY]: i18n.t("Selected Categories"),+ [VoucherType.COLLECTION]: i18n.t("Selected Collections"),+ [VoucherType.PRODUCT]: i18n.t("Selected Products"),+ [VoucherType.SHIPPING]: i18n.t("Shipment"),+ [VoucherType.VALUE]: i18n.t("All Products")+});diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetails.tsnew file mode 100644index 0000000000..c76c986d39--- /dev/null+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetails.ts@@ -0,0 +1,150 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { VoucherDiscountValueType, VoucherType, VoucherCountries } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: VoucherDetails+// ====================================================++export interface VoucherDetails_voucher_minAmountSpent {+ __typename: "Money";+ currency: string;+ amount: number;+}++export interface VoucherDetails_voucher_products_edges_node_productType {+ __typename: "ProductType";+ id: string;+ name: string;+}++export interface VoucherDetails_voucher_products_edges_node_thumbnail {+ __typename: "Image";+ url: string;+}++export interface VoucherDetails_voucher_products_edges_node {+ __typename: "Product";+ id: string;+ name: string;+ productType: VoucherDetails_voucher_products_edges_node_productType;+ isPublished: boolean;+ thumbnail: VoucherDetails_voucher_products_edges_node_thumbnail | null;+}++export interface VoucherDetails_voucher_products_edges {+ __typename: "ProductCountableEdge";+ node: VoucherDetails_voucher_products_edges_node;+}++export interface VoucherDetails_voucher_products_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetails_voucher_products {+ __typename: "ProductCountableConnection";+ edges: VoucherDetails_voucher_products_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetails_voucher_products_pageInfo;+}++export interface VoucherDetails_voucher_collections_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface VoucherDetails_voucher_collections_edges_node {+ __typename: "Collection";+ id: string;+ name: string;+ products: VoucherDetails_voucher_collections_edges_node_products | null;+}++export interface VoucherDetails_voucher_collections_edges {+ __typename: "CollectionCountableEdge";+ node: VoucherDetails_voucher_collections_edges_node;+}++export interface VoucherDetails_voucher_collections_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetails_voucher_collections {+ __typename: "CollectionCountableConnection";+ edges: VoucherDetails_voucher_collections_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetails_voucher_collections_pageInfo;+}++export interface VoucherDetails_voucher_categories_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface VoucherDetails_voucher_categories_edges_node {+ __typename: "Category";+ id: string;+ name: string;+ products: VoucherDetails_voucher_categories_edges_node_products | null;+}++export interface VoucherDetails_voucher_categories_edges {+ __typename: "CategoryCountableEdge";+ node: VoucherDetails_voucher_categories_edges_node;+}++export interface VoucherDetails_voucher_categories_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetails_voucher_categories {+ __typename: "CategoryCountableConnection";+ edges: VoucherDetails_voucher_categories_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetails_voucher_categories_pageInfo;+}++export interface VoucherDetails_voucher {+ __typename: "Voucher";+ id: string;+ name: string | null;+ startDate: any;+ endDate: any | null;+ usageLimit: number | null;+ discountValueType: VoucherDiscountValueType;+ discountValue: number;+ minAmountSpent: VoucherDetails_voucher_minAmountSpent | null;+ type: VoucherType;+ code: string;+ used: number;+ applyOncePerOrder: boolean;+ products: VoucherDetails_voucher_products | null;+ collections: VoucherDetails_voucher_collections | null;+ categories: VoucherDetails_voucher_categories | null;+ countries: VoucherCountries;+}++export interface VoucherDetails {+ voucher: VoucherDetails_voucher | null;+}++export interface VoucherDetailsVariables {+ id: string;+ after?: string | null;+ before?: string | null;+ first?: number | null;+ last?: number | null;+}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.tsnew file mode 100644index 0000000000..37ce2f95ad--- /dev/null+++ b/saleor/static/dashboard-next/discounts/types/VoucherDetailsFragment.ts@@ -0,0 +1,138 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { VoucherDiscountValueType, VoucherType, VoucherCountries } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: VoucherDetailsFragment+// ====================================================++export interface VoucherDetailsFragment_minAmountSpent {+ __typename: "Money";+ currency: string;+ amount: number;+}++export interface VoucherDetailsFragment_products_edges_node_productType {+ __typename: "ProductType";+ id: string;+ name: string;+}++export interface VoucherDetailsFragment_products_edges_node_thumbnail {+ __typename: "Image";+ url: string;+}++export interface VoucherDetailsFragment_products_edges_node {+ __typename: "Product";+ id: string;+ name: string;+ productType: VoucherDetailsFragment_products_edges_node_productType;+ isPublished: boolean;+ thumbnail: VoucherDetailsFragment_products_edges_node_thumbnail | null;+}++export interface VoucherDetailsFragment_products_edges {+ __typename: "ProductCountableEdge";+ node: VoucherDetailsFragment_products_edges_node;+}++export interface VoucherDetailsFragment_products_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetailsFragment_products {+ __typename: "ProductCountableConnection";+ edges: VoucherDetailsFragment_products_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetailsFragment_products_pageInfo;+}++export interface VoucherDetailsFragment_collections_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface VoucherDetailsFragment_collections_edges_node {+ __typename: "Collection";+ id: string;+ name: string;+ products: VoucherDetailsFragment_collections_edges_node_products | null;+}++export interface VoucherDetailsFragment_collections_edges {+ __typename: "CollectionCountableEdge";+ node: VoucherDetailsFragment_collections_edges_node;+}++export interface VoucherDetailsFragment_collections_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetailsFragment_collections {+ __typename: "CollectionCountableConnection";+ edges: VoucherDetailsFragment_collections_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetailsFragment_collections_pageInfo;+}++export interface VoucherDetailsFragment_categories_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface VoucherDetailsFragment_categories_edges_node {+ __typename: "Category";+ id: string;+ name: string;+ products: VoucherDetailsFragment_categories_edges_node_products | null;+}++export interface VoucherDetailsFragment_categories_edges {+ __typename: "CategoryCountableEdge";+ node: VoucherDetailsFragment_categories_edges_node;+}++export interface VoucherDetailsFragment_categories_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface VoucherDetailsFragment_categories {+ __typename: "CategoryCountableConnection";+ edges: VoucherDetailsFragment_categories_edges[];+ totalCount: number | null;+ pageInfo: VoucherDetailsFragment_categories_pageInfo;+}++export interface VoucherDetailsFragment {+ __typename: "Voucher";+ id: string;+ name: string | null;+ startDate: any;+ endDate: any | null;+ usageLimit: number | null;+ discountValueType: VoucherDiscountValueType;+ discountValue: number;+ minAmountSpent: VoucherDetailsFragment_minAmountSpent | null;+ type: VoucherType;+ code: string;+ used: number;+ applyOncePerOrder: boolean;+ products: VoucherDetailsFragment_products | null;+ collections: VoucherDetailsFragment_collections | null;+ categories: VoucherDetailsFragment_categories | null;+ countries: VoucherCountries;+}diff --git a/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts b/saleor/static/dashboard-next/discounts/types/VoucherFragment.tsnew file mode 100644index 0000000000..5dfdda1b34--- /dev/null+++ b/saleor/static/dashboard-next/discounts/types/VoucherFragment.ts@@ -0,0 +1,26 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { VoucherDiscountValueType } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: VoucherFragment+// ====================================================++export interface VoucherFragment_minAmountSpent {+ __typename: "Money";+ currency: string;+ amount: number;+}++export interface VoucherFragment {+ __typename: "Voucher";+ id: string;+ name: string | null;+ startDate: any;+ endDate: any | null;+ usageLimit: number | null;+ discountValueType: VoucherDiscountValueType;+ discountValue: number;+ minAmountSpent: VoucherFragment_minAmountSpent | null;+}diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 1f6700a902..c721718ae6 100644--- a/saleor/static/dashboard-next/storybook/config.js+++ b/saleor/static/dashboard-next/storybook/config.js@@ -57,6 +57,7 @@ function loadStories() {require("./stories/discounts/SaleDetailsPage");require("./stories/discounts/SaleListPage");require("./stories/discounts/VoucherListPage");+ require("./stories/discounts/VoucherDetailsPage");// Homepagerequire("./stories/home/HomePage");diff --git a/saleor/static/dashboard-next/storybook/stories/discounts/VoucherDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/discounts/VoucherDetailsPage.tsxnew file mode 100644index 0000000000..7a8e655019--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/discounts/VoucherDetailsPage.tsx@@ -0,0 +1,23 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import VoucherDetailsPage, {+ VoucherDetailsPageProps+} from "../../../discounts/components/VoucherDetailsPage";+import { voucherDetails } from "../../../discounts/fixtures";+import { pageListProps } from "../../../fixtures";+import Decorator from "../../Decorator";++const props: VoucherDetailsPageProps = {+ ...pageListProps.default,+ defaultCurrency: "USD",+ onBack: () => undefined,+ voucher: voucherDetails+};++storiesOf("Views / Discounts / Voucher Details", module)+ .addDecorator(Decorator)+ .add("default", () => <VoucherDetailsPage {...props} />)+ .add("loading", () => (+ <VoucherDetailsPage {...props} disabled={true} voucher={undefined} />+ ));diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex a748014863..90e7209a5a 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -124,11 +124,272 @@ export enum TaxRateType {WINE = "WINE",}+export enum VoucherCountries {+ AD = "AD",+ AE = "AE",+ AF = "AF",+ AG = "AG",+ AI = "AI",+ AL = "AL",+ AM = "AM",+ AO = "AO",+ AQ = "AQ",+ AR = "AR",+ AS = "AS",+ AT = "AT",+ AU = "AU",+ AW = "AW",+ AX = "AX",+ AZ = "AZ",+ BA = "BA",+ BB = "BB",+ BD = "BD",+ BE = "BE",+ BF = "BF",+ BG = "BG",+ BH = "BH",+ BI = "BI",+ BJ = "BJ",+ BL = "BL",+ BM = "BM",+ BN = "BN",+ BO = "BO",+ BQ = "BQ",+ BR = "BR",+ BS = "BS",+ BT = "BT",+ BV = "BV",+ BW = "BW",+ BY = "BY",+ BZ = "BZ",+ CA = "CA",+ CC = "CC",+ CD = "CD",+ CF = "CF",+ CG = "CG",+ CH = "CH",+ CI = "CI",+ CK = "CK",+ CL = "CL",+ CM = "CM",+ CN = "CN",+ CO = "CO",+ CR = "CR",+ CU = "CU",+ CV = "CV",+ CW = "CW",+ CX = "CX",+ CY = "CY",+ CZ = "CZ",+ DE = "DE",+ DJ = "DJ",+ DK = "DK",+ DM = "DM",+ DO = "DO",+ DZ = "DZ",+ EC = "EC",+ EE = "EE",+ EG = "EG",+ EH = "EH",+ ER = "ER",+ ES = "ES",+ ET = "ET",+ EU = "EU",+ FI = "FI",+ FJ = "FJ",+ FK = "FK",+ FM = "FM",+ FO = "FO",+ FR = "FR",+ GA = "GA",+ GB = "GB",+ GD = "GD",+ GE = "GE",+ GF = "GF",+ GG = "GG",+ GH = "GH",+ GI = "GI",+ GL = "GL",+ GM = "GM",+ GN = "GN",+ GP = "GP",+ GQ = "GQ",+ GR = "GR",+ GS = "GS",+ GT = "GT",+ GU = "GU",+ GW = "GW",+ GY = "GY",+ HK = "HK",+ HM = "HM",+ HN = "HN",+ HR = "HR",+ HT = "HT",+ HU = "HU",+ ID = "ID",+ IE = "IE",+ IL = "IL",+ IM = "IM",+ IN = "IN",+ IO = "IO",+ IQ = "IQ",+ IR = "IR",+ IS = "IS",+ IT = "IT",+ JE = "JE",+ JM = "JM",+ JO = "JO",+ JP = "JP",+ KE = "KE",+ KG = "KG",+ KH = "KH",+ KI = "KI",+ KM = "KM",+ KN = "KN",+ KP = "KP",+ KR = "KR",+ KW = "KW",+ KY = "KY",+ KZ = "KZ",+ LA = "LA",+ LB = "LB",+ LC = "LC",+ LI = "LI",+ LK = "LK",+ LR = "LR",+ LS = "LS",+ LT = "LT",+ LU = "LU",+ LV = "LV",+ LY = "LY",+ MA = "MA",+ MC = "MC",+ MD = "MD",+ ME = "ME",+ MF = "MF",+ MG = "MG",+ MH = "MH",+ MK = "MK",+ ML = "ML",+ MM = "MM",+ MN = "MN",+ MO = "MO",+ MP = "MP",+ MQ = "MQ",+ MR = "MR",+ MS = "MS",+ MT = "MT",+ MU = "MU",+ MV = "MV",+ MW = "MW",+ MX = "MX",+ MY = "MY",+ MZ = "MZ",+ NA = "NA",+ NC = "NC",+ NE = "NE",+ NF = "NF",+ NG = "NG",+ NI = "NI",+ NL = "NL",+ NO = "NO",+ NP = "NP",+ NR = "NR",+ NU = "NU",+ NZ = "NZ",+ OM = "OM",+ PA = "PA",+ PE = "PE",+ PF = "PF",+ PG = "PG",+ PH = "PH",+ PK = "PK",+ PL = "PL",+ PM = "PM",+ PN = "PN",+ PR = "PR",+ PS = "PS",+ PT = "PT",+ PW = "PW",+ PY = "PY",+ QA = "QA",+ RE = "RE",+ RO = "RO",+ RS = "RS",+ RU = "RU",+ RW = "RW",+ SA = "SA",+ SB = "SB",+ SC = "SC",+ SD = "SD",+ SE = "SE",+ SG = "SG",+ SH = "SH",+ SI = "SI",+ SJ = "SJ",+ SK = "SK",+ SL = "SL",+ SM = "SM",+ SN = "SN",+ SO = "SO",+ SR = "SR",+ SS = "SS",+ ST = "ST",+ SV = "SV",+ SX = "SX",+ SY = "SY",+ SZ = "SZ",+ TC = "TC",+ TD = "TD",+ TF = "TF",+ TG = "TG",+ TH = "TH",+ TJ = "TJ",+ TK = "TK",+ TL = "TL",+ TM = "TM",+ TN = "TN",+ TO = "TO",+ TR = "TR",+ TT = "TT",+ TV = "TV",+ TW = "TW",+ TZ = "TZ",+ UA = "UA",+ UG = "UG",+ UM = "UM",+ US = "US",+ UY = "UY",+ UZ = "UZ",+ VA = "VA",+ VC = "VC",+ VE = "VE",+ VG = "VG",+ VI = "VI",+ VN = "VN",+ VU = "VU",+ WF = "WF",+ WS = "WS",+ YE = "YE",+ YT = "YT",+ ZA = "ZA",+ ZM = "ZM",+ ZW = "ZW",+}+export enum VoucherDiscountValueType {FIXED = "FIXED",PERCENTAGE = "PERCENTAGE",}+export enum VoucherType {+ CATEGORY = "CATEGORY",+ COLLECTION = "COLLECTION",+ PRODUCT = "PRODUCT",+ SHIPPING = "SHIPPING",+ VALUE = "VALUE",+}+export enum WeightUnitsEnum {g = "g",kg = "kg",