Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add basic sale details view
dominik-zeglen67652ce05509
diff --git a/saleor/static/dashboard-next/discounts/components/SaleCategories/SaleCategories.tsx b/saleor/static/dashboard-next/discounts/components/SaleCategories/SaleCategories.tsxnew file mode 100644index 0000000000..292f476a34--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleCategories/SaleCategories.tsx@@ -0,0 +1,9 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++export interface SaleCategoriesProps {}++const decorate = withStyles(theme => ({ root: {} }));+const SaleCategories = decorate<SaleCategoriesProps>(({ classes }) => <div />);+SaleCategories.displayName = "SaleCategories";+export default SaleCategories;diff --git a/saleor/static/dashboard-next/discounts/components/SaleCategories/index.ts b/saleor/static/dashboard-next/discounts/components/SaleCategories/index.tsnew file mode 100644index 0000000000..f13d3fd8db--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleCategories/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleCategories";+export * from "./SaleCategories";diff --git a/saleor/static/dashboard-next/discounts/components/SaleCollections/SaleCollections.tsx b/saleor/static/dashboard-next/discounts/components/SaleCollections/SaleCollections.tsxnew file mode 100644index 0000000000..2c9b5bc8c4--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleCollections/SaleCollections.tsx@@ -0,0 +1,9 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++export interface SaleCollectionsProps {}++const decorate = withStyles(theme => ({ root: {} }));+const SaleCollections = decorate<SaleCollectionsProps>(({ classes }) => <div />);+SaleCollections.displayName = "SaleCollections";+export default SaleCollections;diff --git a/saleor/static/dashboard-next/discounts/components/SaleCollections/index.ts b/saleor/static/dashboard-next/discounts/components/SaleCollections/index.tsnew file mode 100644index 0000000000..d2f259271c--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleCollections/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleCollections";+export * from "./SaleCollections";diff --git a/saleor/static/dashboard-next/discounts/components/SaleContent/SaleContent.tsx b/saleor/static/dashboard-next/discounts/components/SaleContent/SaleContent.tsxnew file mode 100644index 0000000000..adb6fb39fd--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleContent/SaleContent.tsx@@ -0,0 +1,9 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++export interface SaleContentProps {}++const decorate = withStyles(theme => ({ root: {} }));+const SaleContent = decorate<SaleContentProps>(({ classes }) => <div />);+SaleContent.displayName = "SaleContent";+export default SaleContent;diff --git a/saleor/static/dashboard-next/discounts/components/SaleContent/index.ts b/saleor/static/dashboard-next/discounts/components/SaleContent/index.tsnew file mode 100644index 0000000000..7cfec4feb7--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleContent/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleContent";+export * from "./SaleContent";diff --git a/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsxnew file mode 100644index 0000000000..bb582b8125--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx@@ -0,0 +1,80 @@+import * as React from "react";++import CardSpacer from "../../../components/CardSpacer";+import Container from "../../../components/Container";+import Form from "../../../components/Form";+import Grid from "../../../components/Grid";+import PageHeader from "../../../components/PageHeader";+import i18n from "../../../i18n";+import { maybe } from "../../../misc";+import { ListProps } from "../../../types";+import { SaleType } from "../../../types/globalTypes";+import { SaleDetails_sale } from "../../types/SaleDetails";+import SaleInfo from "../SaleInfo";+import SalePricing from "../SalePricing";+import SaleSummary from "../SaleSummary";++export interface FormData {+ name: string;+ startDate: string;+ endDate: string;+ value: string;+ type: SaleType;+}++export interface SaleDetailsPageProps extends ListProps {+ activeTab: "categories" | "collections" | "products";+ defaultCurrency: string;+ sale: SaleDetails_sale;+ onBack: () => void;+ onRemove: () => void;+ onSubmit: (data: FormData) => void;+}++const SaleDetailsPage: React.StatelessComponent<SaleDetailsPageProps> = ({+ activeTab,+ defaultCurrency,+ disabled,+ sale,+ pageInfo,+ onBack,+ onNextPage,+ onPreviousPage,+ onRemove,+ onRowClick,+ onSubmit+}) => {+ const initialForm: FormData = {+ endDate: maybe(() => sale.endDate),+ name: maybe(() => sale.name),+ startDate: maybe(() => sale.startDate),+ type: maybe(() => sale.type),+ value: maybe(() => sale.value.toString())+ };+ return (+ <Form initial={initialForm} onSubmit={onSubmit}>+ {({ change, data, errors, hasChanged, submit }) => (+ <Container width="md">+ <PageHeader title={maybe(() => sale.name)} onBack={onBack} />+ <Grid>+ <div>+ <SaleInfo data={data} disabled={disabled} onChange={change} />+ <CardSpacer />+ <SalePricing+ data={data}+ defaultCurrency={defaultCurrency}+ disabled={disabled}+ onChange={change}+ />+ </div>+ <div>+ <SaleSummary defaultCurrency={defaultCurrency} sale={sale} />+ </div>+ </Grid>+ </Container>+ )}+ </Form>+ );+};+SaleDetailsPage.displayName = "SaleDetailsPage";+export default SaleDetailsPage;diff --git a/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/index.ts b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/index.tsnew file mode 100644index 0000000000..32c43a08b5--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleDetailsPage/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleDetailsPage";+export * from "./SaleDetailsPage";diff --git a/saleor/static/dashboard-next/discounts/components/SaleInfo/SaleInfo.tsx b/saleor/static/dashboard-next/discounts/components/SaleInfo/SaleInfo.tsxnew file mode 100644index 0000000000..a8f1f14f2b--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleInfo/SaleInfo.tsx@@ -0,0 +1,56 @@+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 i18n from "../../../i18n";+import { FormData } from "../SaleDetailsPage";++export interface SaleInfoProps {+ data: FormData;+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const styles = (theme: Theme) =>+ createStyles({+ root: {+ display: "grid",+ gridColumnGap: theme.spacing.unit * 2 + "px",+ gridTemplateColumns: "3fr 1fr"+ }+ });++const SaleInfo = withStyles(styles, {+ name: "SaleInfo"+})(+ ({+ classes,+ data,+ disabled,+ onChange+ }: SaleInfoProps & WithStyles<typeof styles>) => (+ <Card>+ <CardTitle title={i18n.t("General Informations")} />+ <CardContent className={classes.root}>+ <TextField+ disabled={disabled}+ name={"name" as keyof FormData}+ onChange={onChange}+ label={i18n.t("Name")}+ value={data.name}+ fullWidth+ />+ </CardContent>+ </Card>+ )+);+SaleInfo.displayName = "SaleInfo";+export default SaleInfo;diff --git a/saleor/static/dashboard-next/discounts/components/SaleInfo/index.ts b/saleor/static/dashboard-next/discounts/components/SaleInfo/index.tsnew file mode 100644index 0000000000..2abfa07d85--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleInfo/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleInfo";+export * from "./SaleInfo";diff --git a/saleor/static/dashboard-next/discounts/components/SalePricing/SalePricing.tsx b/saleor/static/dashboard-next/discounts/components/SalePricing/SalePricing.tsxnew file mode 100644index 0000000000..be1c82faac--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SalePricing/SalePricing.tsx@@ -0,0 +1,191 @@+import Card from "@material-ui/core/Card";+import CardContent from "@material-ui/core/CardContent";+import ClickAwayListener from "@material-ui/core/ClickAwayListener";+import Grow from "@material-ui/core/Grow";+import MenuItem from "@material-ui/core/MenuItem";+import Menu from "@material-ui/core/MenuList";+import Paper from "@material-ui/core/Paper";+import Popper from "@material-ui/core/Popper";+import {+ createStyles,+ Theme,+ WithStyles,+ withStyles+} from "@material-ui/core/styles";+import TextField from "@material-ui/core/TextField";+import Typography from "@material-ui/core/Typography";+import DropdownIcon from "@material-ui/icons/ArrowDropDown";+import * as React from "react";++import CardTitle from "../../../components/CardTitle";+import Hr from "../../../components/Hr";+import MenuToggle from "../../../components/MenuToggle";+import i18n from "../../../i18n";+import { SaleType } from "../../../types/globalTypes";+import { FormData } from "../SaleDetailsPage";++export interface SalePricingProps {+ data: FormData;+ defaultCurrency: string;+ disabled: boolean;+ onChange: (event: React.ChangeEvent<any>) => void;+}++const styles = (theme: Theme) =>+ createStyles({+ adornment: {+ alignItems: "center",+ cursor: "pointer",+ display: "flex"+ },+ menu: {+ zIndex: 10+ },+ root: {+ display: "grid",+ gridColumnGap: theme.spacing.unit * 2 + "px",+ gridTemplateColumns: "1fr 1fr"+ },+ subheading: {+ gridColumnEnd: "span 2",+ marginBottom: theme.spacing.unit * 2+ }+ });++const SalePricing = withStyles(styles, {+ name: "SalePricing"+})(+ class SalePricingComponent extends React.Component<+ SalePricingProps & WithStyles<typeof styles>+ > {+ anchor = React.createRef<HTMLDivElement>();++ render() {+ const { classes, data, defaultCurrency, disabled, onChange } = this.props;++ return (+ <Card>+ <CardTitle title={i18n.t("Pricing")} />+ <CardContent className={classes.root}>+ <TextField+ disabled={disabled}+ name={"value" as keyof FormData}+ onChange={onChange}+ label={i18n.t("Discount Value")}+ value={data.value}+ type="number"+ fullWidth+ InputProps={{+ endAdornment: (+ <MenuToggle ariaOwns="user-menu">+ {({+ open: menuOpen,+ actions: { open: openMenu, close: closeMenu }+ }) => {+ const handleSelect = (value: SaleType) => {+ onChange({+ target: {+ name: "type",+ value+ }+ } as any);+ closeMenu();+ };++ return (+ <>+ <div+ className={classes.adornment}+ ref={this.anchor}+ onClick={!menuOpen ? openMenu : undefined}+ >+ <Typography component="span" variant="caption">+ {data.type === SaleType.FIXED+ ? defaultCurrency+ : "%"}+ </Typography>+ <DropdownIcon />+ </div>+ <Popper+ open={menuOpen}+ anchorEl={this.anchor.current}+ transition+ disablePortal+ placement="bottom-end"+ className={classes.menu}+ >+ {({ TransitionProps, placement }) => (+ <Grow+ {...TransitionProps}+ style={{+ transformOrigin:+ placement === "bottom"+ ? "right top"+ : "right bottom"+ }}+ >+ <Paper>+ <ClickAwayListener+ onClickAway={closeMenu}+ mouseEvent="onClick"+ >+ <Menu>+ <MenuItem+ onClick={() =>+ handleSelect(SaleType.FIXED)+ }+ >+ {defaultCurrency}+ </MenuItem>+ <MenuItem+ onClick={() =>+ handleSelect(SaleType.PERCENTAGE)+ }+ >+ %+ </MenuItem>+ </Menu>+ </ClickAwayListener>+ </Paper>+ </Grow>+ )}+ </Popper>+ </>+ );+ }}+ </MenuToggle>+ )+ }}+ />+ </CardContent>+ <Hr />+ <CardContent className={classes.root}>+ <Typography className={classes.subheading} variant="subheading">+ {i18n.t("Time Frame")}+ </Typography>+ <TextField+ disabled={disabled}+ name={"startDate" as keyof FormData}+ onChange={onChange}+ label={i18n.t("Start Date")}+ value={data.startDate}+ type="date"+ fullWidth+ />+ <TextField+ disabled={disabled}+ name={"endDate" as keyof FormData}+ onChange={onChange}+ label={i18n.t("End Date")}+ value={data.endDate}+ type="date"+ fullWidth+ />+ </CardContent>+ </Card>+ );+ }+ }+);+SalePricing.displayName = "SalePricing";+export default SalePricing;diff --git a/saleor/static/dashboard-next/discounts/components/SalePricing/index.ts b/saleor/static/dashboard-next/discounts/components/SalePricing/index.tsnew file mode 100644index 0000000000..347c08adca--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SalePricing/index.ts@@ -0,0 +1,2 @@+export { default } from "./SalePricing";+export * from "./SalePricing";diff --git a/saleor/static/dashboard-next/discounts/components/SaleProducts/SaleProducts.tsx b/saleor/static/dashboard-next/discounts/components/SaleProducts/SaleProducts.tsxnew file mode 100644index 0000000000..d2c413d0e1--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleProducts/SaleProducts.tsx@@ -0,0 +1,9 @@+import { withStyles } from "@material-ui/core/styles";+import * as React from "react";++export interface SaleProductsProps {}++const decorate = withStyles(theme => ({ root: {} }));+const SaleProducts = decorate<SaleProductsProps>(({ classes }) => <div />);+SaleProducts.displayName = "SaleProducts";+export default SaleProducts;diff --git a/saleor/static/dashboard-next/discounts/components/SaleProducts/index.ts b/saleor/static/dashboard-next/discounts/components/SaleProducts/index.tsnew file mode 100644index 0000000000..b3905aca28--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleProducts/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleProducts";+export * from "./SaleProducts";diff --git a/saleor/static/dashboard-next/discounts/components/SaleSummary/SaleSummary.tsx b/saleor/static/dashboard-next/discounts/components/SaleSummary/SaleSummary.tsxnew file mode 100644index 0000000000..f7168fa289--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleSummary/SaleSummary.tsx@@ -0,0 +1,81 @@+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 { SaleType } from "../../../types/globalTypes";+import { SaleDetails_sale } from "../../types/SaleDetails";++export interface SaleSummaryProps {+ defaultCurrency: string;+ sale: SaleDetails_sale;+}++const SaleSummary: React.StatelessComponent<SaleSummaryProps> = ({+ defaultCurrency,+ sale+}) => (+ <Card>+ <CardTitle title={i18n.t("Summary")} />+ <CardContent>+ <Typography variant="body2">{i18n.t("Name")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(() => sale.name, <Skeleton />)}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("Value")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () =>+ sale.type === SaleType.FIXED ? (+ <Money+ money={{+ amount: sale.value,+ currency: defaultCurrency+ }}+ />+ ) : (+ <Percent amount={sale.value} />+ ),+ <Skeleton />+ )}+ </Typography>+ </CardContent>++ <Hr />++ <CardContent>+ <Typography variant="body2">{i18n.t("Start Date")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () => (+ <DateFormatter date={sale.startDate} />+ ),+ <Skeleton />+ )}+ </Typography>+ <FormSpacer />++ <Typography variant="body2">{i18n.t("End Date")}</Typography>+ <Typography>+ {maybe<React.ReactNode>(+ () =>+ sale.endDate === null ? "-" : <DateFormatter date={sale.endDate} />,+ <Skeleton />+ )}+ </Typography>+ </CardContent>+ </Card>+);+SaleSummary.displayName = "SaleSummary";+export default SaleSummary;diff --git a/saleor/static/dashboard-next/discounts/components/SaleSummary/index.ts b/saleor/static/dashboard-next/discounts/components/SaleSummary/index.tsnew file mode 100644index 0000000000..6e0a510f5c--- /dev/null+++ b/saleor/static/dashboard-next/discounts/components/SaleSummary/index.ts@@ -0,0 +1,2 @@+export { default } from "./SaleSummary";+export * from "./SaleSummary";diff --git a/saleor/static/dashboard-next/discounts/fixtures.ts b/saleor/static/dashboard-next/discounts/fixtures.tsindex d1b05d1fbe..562e8dd542 100644--- a/saleor/static/dashboard-next/discounts/fixtures.ts+++ b/saleor/static/dashboard-next/discounts/fixtures.ts@@ -1,4 +1,5 @@import { SaleType, VoucherDiscountValueType } from "../types/globalTypes";+import { SaleDetails_sale } from "./types/SaleDetails";import { SaleList_sales_edges_node } from "./types/SaleList";import { VoucherList_vouchers_edges_node } from "./types/VoucherList";@@ -78,3 +79,103 @@ export const voucherList: VoucherList_vouchers_edges_node[] = [usageLimit: 150}];++export const sale: SaleDetails_sale = {+ __typename: "Sale",+ categories: {+ __typename: "CategoryCountableConnection",+ edges: [],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: null,+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: null+ }+ },+ collections: {+ __typename: "CollectionCountableConnection",+ edges: [],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: null,+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: null+ }+ },+ endDate: null,+ id: "U2FsZTo1",+ name: "Happy minute day!",+ products: {+ __typename: "ProductCountableConnection",+ edges: [+ {+ __typename: "ProductCountableEdge",+ node: {+ __typename: "Product",+ id: "UHJvZHVjdDo3MQ==",+ isPublished: true,+ name: "Orange Juice",+ productType: {+ __typename: "ProductType",+ id: "UHJvZHVjdFR5cGU6OQ==",+ name: "Juice"+ }+ }+ },+ {+ __typename: "ProductCountableEdge",+ node: {+ __typename: "Product",+ id: "UHJvZHVjdDo3Mw==",+ isPublished: true,+ name: "Carrot Juice",+ productType: {+ __typename: "ProductType",+ id: "UHJvZHVjdFR5cGU6OQ==",+ name: "Juice"+ }+ }+ },+ {+ __typename: "ProductCountableEdge",+ node: {+ __typename: "Product",+ id: "UHJvZHVjdDo3OQ==",+ isPublished: true,+ name: "Bean Juice",+ productType: {+ __typename: "ProductType",+ id: "UHJvZHVjdFR5cGU6OQ==",+ name: "Juice"+ }+ }+ },+ {+ __typename: "ProductCountableEdge",+ node: {+ __typename: "Product",+ id: "UHJvZHVjdDoxMTU=",+ isPublished: true,+ name: "Black Hoodie",+ productType: {+ __typename: "ProductType",+ id: "UHJvZHVjdFR5cGU6MTQ=",+ name: "Top (clothing)"+ }+ }+ }+ ],+ pageInfo: {+ __typename: "PageInfo",+ endCursor: "YXJyYXljb25uZWN0aW9uOjM=",+ hasNextPage: false,+ hasPreviousPage: false,+ startCursor: "YXJyYXljb25uZWN0aW9uOjA="+ }+ },+ startDate: "2019-01-03",+ type: "PERCENTAGE" as SaleType,+ value: 30+};diff --git a/saleor/static/dashboard-next/discounts/queries.ts b/saleor/static/dashboard-next/discounts/queries.tsindex 8eeeef8c37..e24ce130aa 100644--- a/saleor/static/dashboard-next/discounts/queries.ts+++ b/saleor/static/dashboard-next/discounts/queries.ts@@ -1,10 +1,11 @@import gql from "graphql-tag";-import { TypedQuery } from "../queries";+import { pageInfoFragment, TypedQuery } from "../queries";import { SaleList, SaleListVariables } from "./types/SaleList";import { VoucherList, VoucherListVariables } from "./types/VoucherList";export const saleList = gql`+ ${pageInfoFragment}query SaleList($after: String, $before: String, $first: Int, $last: Int) {sales(after: $after, before: $before, first: $first, last: $last) {edges {@@ -18,10 +19,7 @@ export const saleList = gql`}}pageInfo {- endCursor- hasNextPage- hasPreviousPage- startCursor+ ...PageInfoFragment}}}@@ -29,6 +27,7 @@ export const saleList = gql`export const TypedSaleList = TypedQuery<SaleList, SaleListVariables>(saleList);export const voucherList = gql`+ ${pageInfoFragment}query VoucherList($after: String, $before: String, $first: Int, $last: Int) {vouchers(after: $after, before: $before, first: $first, last: $last) {edges {@@ -47,10 +46,7 @@ export const voucherList = gql`}}pageInfo {- endCursor- hasNextPage- hasPreviousPage- startCursor+ ...PageInfoFragment}}}@@ -58,3 +54,67 @@ export const voucherList = gql`export const TypedVoucherList = TypedQuery<VoucherList, VoucherListVariables>(voucherList);++export const saleDetails = gql`+ ${pageInfoFragment}+ query SaleDetails(+ $id: ID!+ $after: String+ $before: String+ $first: Int+ $last: Int+ ) {+ sale(id: $id) {+ id+ name+ type+ value+ products(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ isPublished+ productType {+ id+ name+ }+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ categories(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ products {+ totalCount+ }+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ collections(after: $after, before: $before, first: $first, last: $last) {+ edges {+ node {+ id+ name+ products {+ totalCount+ }+ }+ }+ pageInfo {+ ...PageInfoFragment+ }+ }+ startDate+ endDate+ }+ }+`;diff --git a/saleor/static/dashboard-next/discounts/types/SaleDetails.ts b/saleor/static/dashboard-next/discounts/types/SaleDetails.tsnew file mode 100644index 0000000000..9de41f9bc6--- /dev/null+++ b/saleor/static/dashboard-next/discounts/types/SaleDetails.ts@@ -0,0 +1,128 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { SaleType } from "./../../types/globalTypes";++// ====================================================+// GraphQL query operation: SaleDetails+// ====================================================++export interface SaleDetails_sale_products_edges_node_productType {+ __typename: "ProductType";+ id: string;+ name: string;+}++export interface SaleDetails_sale_products_edges_node {+ __typename: "Product";+ id: string;+ name: string;+ isPublished: boolean;+ productType: SaleDetails_sale_products_edges_node_productType;+}++export interface SaleDetails_sale_products_edges {+ __typename: "ProductCountableEdge";+ node: SaleDetails_sale_products_edges_node;+}++export interface SaleDetails_sale_products_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface SaleDetails_sale_products {+ __typename: "ProductCountableConnection";+ edges: SaleDetails_sale_products_edges[];+ pageInfo: SaleDetails_sale_products_pageInfo;+}++export interface SaleDetails_sale_categories_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface SaleDetails_sale_categories_edges_node {+ __typename: "Category";+ id: string;+ name: string;+ products: SaleDetails_sale_categories_edges_node_products | null;+}++export interface SaleDetails_sale_categories_edges {+ __typename: "CategoryCountableEdge";+ node: SaleDetails_sale_categories_edges_node;+}++export interface SaleDetails_sale_categories_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface SaleDetails_sale_categories {+ __typename: "CategoryCountableConnection";+ edges: SaleDetails_sale_categories_edges[];+ pageInfo: SaleDetails_sale_categories_pageInfo;+}++export interface SaleDetails_sale_collections_edges_node_products {+ __typename: "ProductCountableConnection";+ totalCount: number | null;+}++export interface SaleDetails_sale_collections_edges_node {+ __typename: "Collection";+ id: string;+ name: string;+ products: SaleDetails_sale_collections_edges_node_products | null;+}++export interface SaleDetails_sale_collections_edges {+ __typename: "CollectionCountableEdge";+ node: SaleDetails_sale_collections_edges_node;+}++export interface SaleDetails_sale_collections_pageInfo {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}++export interface SaleDetails_sale_collections {+ __typename: "CollectionCountableConnection";+ edges: SaleDetails_sale_collections_edges[];+ pageInfo: SaleDetails_sale_collections_pageInfo;+}++export interface SaleDetails_sale {+ __typename: "Sale";+ id: string;+ name: string;+ type: SaleType;+ value: number;+ products: SaleDetails_sale_products | null;+ categories: SaleDetails_sale_categories | null;+ collections: SaleDetails_sale_collections | null;+ startDate: any;+ endDate: any | null;+}++export interface SaleDetails {+ sale: SaleDetails_sale | null;+}++export interface SaleDetailsVariables {+ id: string;+ after?: string | null;+ before?: string | null;+ first?: number | null;+ last?: number | null;+}diff --git a/saleor/static/dashboard-next/discounts/urls.ts b/saleor/static/dashboard-next/discounts/urls.tsindex b2afa988c7..7dcb4a0c9d 100644--- a/saleor/static/dashboard-next/discounts/urls.ts+++ b/saleor/static/dashboard-next/discounts/urls.ts@@ -10,5 +10,10 @@ export const saleUrl = (id: string) => salePath(encodeURIComponent(id));export const saleAddPath = urlJoin(saleSection, "add");export const saleAddUrl = saleAddPath;-export const voucherListPath = urlJoin(discountSection, "vouchers");+export const voucherSection = urlJoin(discountSection, "vouchers");+export const voucherListPath = voucherSection;export const voucherListUrl = voucherListPath;+export const voucherPath = (id: string) => urlJoin(voucherSection, id);+export const voucherUrl = (id: string) => voucherPath(encodeURIComponent(id));+export const voucherAddPath = urlJoin(voucherSection, "add");+export const voucherAddUrl = voucherAddPath;diff --git a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx b/saleor/static/dashboard-next/discounts/views/VoucherList.tsxindex 0a8e399ab8..6025afca4e 100644--- a/saleor/static/dashboard-next/discounts/views/VoucherList.tsx+++ b/saleor/static/dashboard-next/discounts/views/VoucherList.tsx@@ -3,12 +3,12 @@ import * as React from "react";import Navigator from "../../components/Navigator";import { createPaginationState, Paginator } from "../../components/Paginator";import Shop from "../../components/Shop";+import { WindowTitle } from "../../components/WindowTitle";+import i18n from "../../i18n";import { maybe } from "../../misc";import VoucherListPage from "../components/VoucherListPage";import { TypedVoucherList } from "../queries";import { voucherAddUrl, voucherUrl } from "../urls";-import { WindowTitle } from "../../components/WindowTitle";-import i18n from "../../i18n";const PAGINATE_BY = 20;diff --git a/saleor/static/dashboard-next/queries.tsx b/saleor/static/dashboard-next/queries.tsxindex bb6afafd5a..c06b773ccc 100644--- a/saleor/static/dashboard-next/queries.tsx+++ b/saleor/static/dashboard-next/queries.tsx@@ -1,4 +1,5 @@import { DocumentNode } from "graphql";+import gql from "graphql-tag";import * as React from "react";import { Query, QueryResult } from "react-apollo";@@ -149,3 +150,12 @@ export function TypedQuery<TData, TVariables>(query: DocumentNode) {</AppProgress>);}++export const pageInfoFragment = gql`+ fragment PageInfoFragment on PageInfo {+ endCursor+ hasNextPage+ hasPreviousPage+ startCursor+ }+`;diff --git a/saleor/static/dashboard-next/storybook/config.js b/saleor/static/dashboard-next/storybook/config.jsindex 82a69563f2..1f6700a902 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/SaleDetailsPage");require("./stories/discounts/SaleListPage");require("./stories/discounts/VoucherListPage");diff --git a/saleor/static/dashboard-next/storybook/stories/discounts/SaleDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/discounts/SaleDetailsPage.tsxnew file mode 100644index 0000000000..bd3a01104c--- /dev/null+++ b/saleor/static/dashboard-next/storybook/stories/discounts/SaleDetailsPage.tsx@@ -0,0 +1,32 @@+import { storiesOf } from "@storybook/react";+import * as React from "react";++import SaleDetailsPage, {+ SaleDetailsPageProps+} from "../../../discounts/components/SaleDetailsPage";+import { sale } from "../../../discounts/fixtures";+import Decorator from "../../Decorator";++const props: SaleDetailsPageProps = {+ activeTab: "categories",+ defaultCurrency: "USD",+ disabled: false,+ onBack: () => undefined,+ onNextPage: () => undefined,+ onPreviousPage: () => undefined,+ onRemove: () => undefined,+ onRowClick: () => () => undefined,+ onSubmit: () => undefined,+ pageInfo: {+ hasNextPage: true,+ hasPreviousPage: false+ },+ sale+};++storiesOf("Views / Discounts / Sale details", module)+ .addDecorator(Decorator)+ .add("default", () => <SaleDetailsPage {...props} />)+ .add("loading", () => (+ <SaleDetailsPage {...props} sale={undefined} disabled={true} />+ ));diff --git a/saleor/static/dashboard-next/storybook/stories/discounts/SaleListPage.tsx b/saleor/static/dashboard-next/storybook/stories/discounts/SaleListPage.tsxindex a84a33e406..573ff4ce4a 100644--- a/saleor/static/dashboard-next/storybook/stories/discounts/SaleListPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/discounts/SaleListPage.tsx@@ -14,7 +14,7 @@ const props: SaleListPageProps = {sales: saleList};-storiesOf("Views / Discounts / Sale List", module)+storiesOf("Views / Discounts / Sale list", module).addDecorator(Decorator).add("default", () => <SaleListPage {...props} />).add("loading", () => <SaleListPage {...props} sales={undefined} />)diff --git a/saleor/static/dashboard-next/storybook/stories/discounts/VoucherListPage.tsx b/saleor/static/dashboard-next/storybook/stories/discounts/VoucherListPage.tsxindex 6a073fc430..93db73a0ff 100644--- a/saleor/static/dashboard-next/storybook/stories/discounts/VoucherListPage.tsx+++ b/saleor/static/dashboard-next/storybook/stories/discounts/VoucherListPage.tsx@@ -14,7 +14,7 @@ const props: VoucherListPageProps = {vouchers: voucherList};-storiesOf("Views / Discounts / Voucher List", module)+storiesOf("Views / Discounts / Voucher list", module).addDecorator(Decorator).add("default", () => <VoucherListPage {...props} />).add("loading", () => <VoucherListPage {...props} vouchers={undefined} />)diff --git a/saleor/static/dashboard-next/types/PageInfoFragment.ts b/saleor/static/dashboard-next/types/PageInfoFragment.tsnew file mode 100644index 0000000000..b743abe3a4--- /dev/null+++ b/saleor/static/dashboard-next/types/PageInfoFragment.ts@@ -0,0 +1,14 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++// ====================================================+// GraphQL fragment: PageInfoFragment+// ====================================================++export interface PageInfoFragment {+ __typename: "PageInfo";+ endCursor: string | null;+ hasNextPage: boolean;+ hasPreviousPage: boolean;+ startCursor: string | null;+}