Skip to content

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

Remove old files

dominik-zeglen56a15414a121
diff --git a/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherDetailsPage.tsx
deleted file mode 100644
index e3e1c63368..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherDetailsPage.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import * as React from "react";
-
-import { categories } from "../../../categories/fixtures";
-import { countries } from "../../../orders/fixtures";
-import { products } from "../../../products/fixtures";
-import VoucherDetailsPage from "../../../vouchers/components/VoucherDetailsPage";
-import { vouchers } from "../../../vouchers/fixtures";
-import Decorator from "../../Decorator";
-
-storiesOf("Views / Vouchers / Voucher details", module)
- .addDecorator(Decorator)
- .add("default", () => (
- <VoucherDetailsPage
- onBack={() => undefined}
- currency="USD"
- voucher={vouchers[0]}
- onVoucherDelete={undefined}
- shippingSearchResults={countries}
- categorySearchResults={categories}
- productSearchResults={products("")}
- />
- ))
- .add("when loading", () => (
- <VoucherDetailsPage disabled onBack={() => undefined} />
- ));
diff --git a/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherListPage.tsx b/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherListPage.tsx
deleted file mode 100644
index 46f75671d6..0000000000
--- a/saleor/static/dashboard-next/storybook/stories/vouchers/VoucherListPage.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { storiesOf } from "@storybook/react";
-import * as React from "react";
-
-import { pageListProps } from "../../../fixtures";
-import VoucherListPage from "../../../vouchers/components/VoucherListPage";
-import { vouchers } from "../../../vouchers/fixtures";
-import Decorator from "../../Decorator";
-
-storiesOf("Views / Vouchers / Voucher list", module)
- .addDecorator(Decorator)
- .add("default", () => (
- <VoucherListPage
- currency="USD"
- vouchers={vouchers}
- {...pageListProps.default}
- />
- ))
- .add("when loading", () => <VoucherListPage {...pageListProps.loading} />)
- .add("no data", () => (
- <VoucherListPage vouchers={[]} {...pageListProps.loading} />
- ));
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherDetails/VoucherDetails.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherDetails/VoucherDetails.tsx
deleted file mode 100644
index 2a73c77430..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherDetails/VoucherDetails.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-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 FormSpacer from "../../../components/FormSpacer";
-import SingleSelectField from "../../../components/SingleSelectField";
-import i18n from "../../../i18n";
-
-const styles = (theme: Theme) =>
- createStyles({
- grid: {
- display: "grid",
- gridColumnGap: theme.spacing.unit * 2 + "px",
- gridTemplateColumns: "1fr 10rem"
- }
- });
-
-interface VoucherDetailsProps extends WithStyles<typeof styles> {
- currency?: string;
- disabled?: boolean;
- voucher?: {
- id: string;
- name: string | null;
- code: string;
- usageLimit: number | null;
- used: number | null;
- startDate: string | null;
- endDate: string | null;
- discountValueType: "PERCENTAGE" | "FIXED" | string;
- discountValue: number;
- product: {
- id: string;
- name: string;
- price: { amount: number; currency: string };
- } | null;
- category: {
- id: string;
- name: string;
- products: { totalCount: number };
- } | null;
- applyTo: string | null;
- limit: { amount: number; currency: string } | null;
- };
- data: {
- code: string;
- discountValueType: string;
- discountValue: number;
- name: string;
- };
- onChange?(event: React.ChangeEvent<any>);
-}
-
-const VoucherDetails = withStyles(styles, { name: "VoucherDetails" })(
- ({ classes, currency, data, disabled, onChange }: VoucherDetailsProps) => (
- <Card>
- <CardContent>
- <TextField
- disabled={disabled}
- fullWidth
- label={i18n.t("Code")}
- name="code"
- onChange={onChange}
- value={data.code}
- />
- <FormSpacer />
- <TextField
- disabled={disabled}
- fullWidth
- helperText={i18n.t("Optional")}
- label={i18n.t("Name")}
- name="name"
- onChange={onChange}
- value={data.name}
- />
- <FormSpacer />
- <div className={classes.grid}>
- <div>
- <TextField
- disabled={disabled}
- fullWidth
- label={i18n.t("Discount value")}
- name="discountValue"
- onChange={onChange}
- type="number"
- value={data.discountValue}
- />
- </div>
- <div>
- <SingleSelectField
- choices={[
- { label: "%", value: "PERCENTAGE" },
- { label: currency, value: "FIXED" }
- ]}
- disabled={disabled}
- label={i18n.t("Discount type")}
- name="discountValueType"
- onChange={onChange}
- value={data.discountValueType}
- />
- </div>
- </div>
- </CardContent>
- </Card>
- )
-);
-VoucherDetails.displayName = "VoucherDetails";
-export default VoucherDetails;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherDetails/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherDetails/index.ts
deleted file mode 100644
index d161158b63..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherDetails/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherDetails";
-export * from "./VoucherDetails";
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/VoucherDetailsPage.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/VoucherDetailsPage.tsx
deleted file mode 100644
index 085708049c..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/VoucherDetailsPage.tsx
+++ /dev/null
@@ -1,228 +0,0 @@
-import DialogContentText from "@material-ui/core/DialogContentText";
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
-import * as CRC from "crc-32";
-import * as React from "react";
-
-import { createVoucherName, VoucherType } from "../..";
-import ActionDialog from "../../../components/ActionDialog";
-import { ConfirmButtonTransitionState } from "../../../components/ConfirmButton/ConfirmButton";
-import Container from "../../../components/Container";
-import Form from "../../../components/Form";
-import PageHeader from "../../../components/PageHeader";
-import SaveButtonBar from "../../../components/SaveButtonBar";
-import Toggle from "../../../components/Toggle";
-import i18n from "../../../i18n";
-import VoucherDetails from "../VoucherDetails/VoucherDetails";
-import VoucherProperties from "../VoucherProperties/VoucherProperties";
-import VoucherUsability from "../VoucherUsability";
-
-const styles = (theme: Theme) =>
- createStyles({
- cardSpacer: {
- marginTop: theme.spacing.unit * 2,
- [theme.breakpoints.down("md")]: {
- marginTop: theme.spacing.unit
- }
- },
- root: {
- display: "grid",
- gridColumnGap: theme.spacing.unit * 2 + "px",
- gridTemplateColumns: "2fr 1fr"
- }
- });
-
-interface VoucherDetailsPageProps extends WithStyles<typeof styles> {
- disabled?: boolean;
- voucher?: {
- id: string;
- name: string | null;
- type: VoucherType;
- code: string;
- usageLimit: number | null;
- used: number | null;
- startDate: string;
- endDate: string | null;
- discountValueType: "PERCENTAGE" | "FIXED" | string;
- discountValue: number;
- product: {
- id: string;
- name: string;
- price: { amount: number; currency: string };
- } | null;
- category: {
- id: string;
- name: string;
- products: { totalCount: number };
- } | null;
- applyTo: string | null;
- limit: { amount: number; currency: string } | null;
- };
- currency?: string;
- categorySearchResults?: Array<{
- id: string;
- name: string;
- }>;
- productSearchResults?: Array<{
- id: string;
- name: string;
- }>;
- shippingSearchResults?: Array<{
- label: string;
- code: string;
- }>;
- saveButtonBarState?: ConfirmButtonTransitionState;
- loadingCategories?: boolean;
- loadingProducts?: boolean;
- loadingShipping?: boolean;
- fetchCategories?();
- fetchProducts?();
- fetchShipping?();
- onBack?();
- onVoucherDelete?();
-}
-
-const VoucherDetailsPage = withStyles(styles, { name: "VoucherDetailsPage" })(
- ({
- classes,
- currency,
- disabled,
- categorySearchResults,
- saveButtonBarState,
- fetchCategories,
- fetchProducts,
- fetchShipping,
- loadingCategories,
- loadingProducts,
- loadingShipping,
- productSearchResults,
- shippingSearchResults,
- voucher,
- onBack,
- onVoucherDelete
- }: VoucherDetailsPageProps) => (
- <Toggle>
- {(openedVoucherDeleteDialog, { toggle: toggleVoucherDeleteDialog }) => (
- <>
- <Form
- initial={{
- applyToAll:
- voucher && voucher.applyTo && voucher.type !== "SHIPPING"
- ? voucher.applyTo === "all"
- : null,
- applyToShipping:
- voucher && voucher.applyTo && voucher.type === "SHIPPING"
- ? { label: voucher.applyTo, value: voucher.applyTo }
- : null,
- category:
- voucher && voucher.category
- ? { label: voucher.category.name, value: voucher.category.id }
- : null,
- code: voucher && voucher.code ? voucher.code : "",
- discountValue:
- voucher && voucher.discountValue ? voucher.discountValue : 0,
- discountValueType:
- voucher && voucher.discountValueType
- ? voucher.discountValueType
- : "",
- endDate: voucher && voucher.endDate ? voucher.endDate : null,
- limit: voucher && voucher.limit ? voucher.limit.amount : null,
- name: voucher && voucher.name ? voucher.name : "",
- product:
- voucher && voucher.product
- ? { label: voucher.product.name, value: voucher.product.id }
- : null,
- startDate:
- voucher && voucher.startDate ? voucher.startDate : null,
- type: voucher && voucher.type ? voucher.type : "VALUE",
- usageLimit:
- voucher && voucher.usageLimit ? voucher.usageLimit : null
- }}
- key={voucher ? CRC.str(JSON.stringify(voucher)) : "loading"}
- >
- {({ change, data, hasChanged, submit }) => (
- <Container width="md">
- <PageHeader
- title={
- voucher
- ? voucher.name !== null
- ? voucher.name
- : createVoucherName(voucher, currency)
- : undefined
- }
- onBack={onBack}
- />
- <div className={classes.root}>
- <div>
- <VoucherDetails
- currency={currency}
- disabled={disabled}
- voucher={voucher}
- data={data}
- onChange={change}
- />
- <div className={classes.cardSpacer} />
- <VoucherProperties
- disabled={disabled}
- loadingCategories={loadingCategories}
- loadingProducts={loadingProducts}
- loadingShipping={loadingShipping}
- categorySearchResults={categorySearchResults}
- productSearchResults={productSearchResults}
- shippingSearchResults={shippingSearchResults}
- fetchCategories={fetchCategories}
- fetchProducts={fetchProducts}
- fetchShipping={fetchShipping}
- voucher={voucher}
- data={data}
- onChange={change}
- />
- </div>
- <div>
- <VoucherUsability
- disabled={disabled}
- onChange={change}
- data={data}
- />
- </div>
- </div>
- <SaveButtonBar
- onCancel={onBack}
- onDelete={toggleVoucherDeleteDialog}
- onSave={submit}
- state={saveButtonBarState}
- disabled={disabled || !hasChanged}
- />
- </Container>
- )}
- </Form>
- {voucher !== undefined && (
- <ActionDialog
- confirmButtonState="default"
- open={openedVoucherDeleteDialog}
- onClose={toggleVoucherDeleteDialog}
- onConfirm={onVoucherDelete}
- title={i18n.t("Remove voucher")}
- variant="delete"
- >
- <DialogContentText
- dangerouslySetInnerHTML={{
- __html: i18n.t(
- "Are you sure you want to remove <strong>{{ name }}</strong>?",
- { name: voucher.name }
- )
- }}
- />
- </ActionDialog>
- )}
- </>
- )}
- </Toggle>
- )
-);
-VoucherDetailsPage.displayName = "VoucherDetailsPage";
-export default VoucherDetailsPage;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/index.ts
deleted file mode 100644
index d165924b65..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherDetailsPage/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherDetailsPage";
-export * from "./VoucherDetailsPage";
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx
deleted file mode 100644
index 1a79d28b10..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherList/VoucherList.tsx
+++ /dev/null
@@ -1,189 +0,0 @@
-import Card from "@material-ui/core/Card";
-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 TableFooter from "@material-ui/core/TableFooter";
-import TableHead from "@material-ui/core/TableHead";
-import TableRow from "@material-ui/core/TableRow";
-import * as React from "react";
-
-import { createVoucherName, VoucherType } from "../..";
-import Date from "../../../components/Date";
-import Money from "../../../components/Money";
-import Percent from "../../../components/Percent";
-import Skeleton from "../../../components/Skeleton";
-import TablePagination from "../../../components/TablePagination";
-import i18n from "../../../i18n";
-import { renderCollection } from "../../../misc";
-import { ListProps } from "../../../types";
-
-const styles = (theme: Theme) =>
- createStyles({
- link: {
- color: theme.palette.secondary.main,
- cursor: "pointer"
- },
- textRight: { textAlign: "right" }
- });
-
-interface VoucherListProps extends ListProps, WithStyles<typeof styles> {
- currency?: string;
- vouchers?: Array<{
- id: string;
- name: string;
- type: VoucherType;
- startDate: string | null;
- endDate: string | null;
- discountValueType: "PERCENTAGE" | "FIXED" | string;
- discountValue: number;
- limit: {
- amount: number;
- currency: string;
- } | null;
- product: {
- name: string;
- } | null;
- category: {
- name: string;
- } | null;
- }>;
-}
-
-const VoucherList = withStyles(styles, { name: "VoucherList" })(
- ({
- classes,
- currency,
- disabled,
- pageInfo,
- vouchers,
- onNextPage,
- onPreviousPage,
- onRowClick
- }: VoucherListProps) => (
- <Card>
- <Table>
- <TableHead>
- <TableRow>
- <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("Start date", { context: "object" })}</TableCell>
- <TableCell>{i18n.t("End date", { context: "object" })}</TableCell>
- <TableCell className={classes.textRight}>
- {i18n.t("Discount", { context: "object" })}
- </TableCell>
- <TableCell className={classes.textRight}>
- {i18n.t("Limit", { context: "object" })}
- </TableCell>
- </TableRow>
- </TableHead>
- <TableFooter>
- <TableRow>
- <TablePagination
- colSpan={5}
- hasNextPage={
- pageInfo && !disabled ? pageInfo.hasNextPage : undefined
- }
- onNextPage={onNextPage}
- hasPreviousPage={
- pageInfo && !disabled ? pageInfo.hasPreviousPage : undefined
- }
- onPreviousPage={onPreviousPage}
- />
- </TableRow>
- </TableFooter>
- <TableBody>
- {renderCollection(
- vouchers,
- voucher => (
- <TableRow key={voucher ? voucher.id : "skeleton"}>
- <TableCell>
- {voucher ? (
- <span
- onClick={onRowClick && onRowClick(voucher.id)}
- className={classes.link}
- >
- {voucher ? (
- voucher.name !== null ? (
- voucher.name
- ) : (
- createVoucherName(voucher, currency)
- )
- ) : (
- <Skeleton />
- )}
- </span>
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell>
- {voucher ? (
- voucher.startDate !== null ? (
- <Date date={voucher.startDate} />
- ) : (
- "-"
- )
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell>
- {voucher ? (
- voucher.endDate !== null ? (
- <Date date={voucher.endDate} />
- ) : (
- "-"
- )
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell className={classes.textRight}>
- {voucher &&
- voucher.discountValueType &&
- voucher.discountValue ? (
- voucher.discountValueType === "PERCENTAGE" ? (
- <Percent amount={voucher.discountValue} />
- ) : (
- <Money
- money={{
- amount: voucher.discountValue,
- currency
- }}
- />
- )
- ) : (
- <Skeleton />
- )}
- </TableCell>
- <TableCell className={classes.textRight}>
- {voucher ? (
- voucher.limit !== null ? (
- <Money money={voucher.limit} />
- ) : (
- "-"
- )
- ) : (
- <Skeleton />
- )}
- </TableCell>
- </TableRow>
- ),
- () => (
- <TableRow>
- <TableCell colSpan={5}>{i18n.t("No vouchers found")}</TableCell>
- </TableRow>
- )
- )}
- </TableBody>
- </Table>
- </Card>
- )
-);
-VoucherList.displayName = "VoucherList";
-export default VoucherList;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherList/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherList/index.ts
deleted file mode 100644
index c844096329..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherList/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherList";
-export * from "./VoucherList";
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherListPage/VoucherListPage.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherListPage/VoucherListPage.tsx
deleted file mode 100644
index b20b9c7dc0..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherListPage/VoucherListPage.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import Button from "@material-ui/core/Button";
-import AddIcon from "@material-ui/icons/Add";
-import * as React from "react";
-
-import { VoucherType } from "../..";
-import { Container } from "../../../components/Container";
-import PageHeader from "../../../components/PageHeader";
-import i18n from "../../../i18n";
-import { PageListProps } from "../../../types";
-import VoucherList from "../VoucherList/VoucherList";
-
-interface VoucherListPageProps extends PageListProps {
- currency?: string;
- vouchers?: Array<{
- id: string;
- name: string;
- type: VoucherType;
- code: string;
- usageLimit: number | null;
- used: number | null;
- startDate: string | null;
- endDate: string | null;
- discountValueType: "PERCENTAGE" | "FIXED" | string;
- discountValue: number;
- product: {
- id: string;
- name: string;
- price: { amount: number; currency: string };
- } | null;
- category: {
- id: string;
- name: string;
- products: { totalCount: number };
- } | null;
- applyTo: string | null;
- limit: { amount: number; currency: string } | null;
- }>;
-}
-
-const VoucherListPage: React.StatelessComponent<VoucherListPageProps> = ({
- currency,
- disabled,
- pageInfo,
- vouchers,
- onAdd,
- onNextPage,
- onPreviousPage,
- onRowClick
-}) => (
- <Container width="md">
- <PageHeader title={i18n.t("Vouchers")}>
- <Button
- color="secondary"
- variant="contained"
- onClick={onAdd}
- disabled={disabled}
- >
- {i18n.t("Add voucher")} <AddIcon />
- </Button>
- </PageHeader>
- <VoucherList
- currency={currency}
- disabled={disabled}
- vouchers={vouchers}
- pageInfo={pageInfo}
- onNextPage={onNextPage}
- onPreviousPage={onPreviousPage}
- onRowClick={onRowClick}
- />
- </Container>
-);
-VoucherListPage.displayName = "VoucherListPage";
-export default VoucherListPage;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherListPage/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherListPage/index.ts
deleted file mode 100644
index 84b3fa702e..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherListPage/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherListPage";
-export * from "./VoucherListPage";
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherProperties/VoucherProperties.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherProperties/VoucherProperties.tsx
deleted file mode 100644
index b53da2cb22..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherProperties/VoucherProperties.tsx
+++ /dev/null
@@ -1,227 +0,0 @@
-import Card from "@material-ui/core/Card";
-import CardContent from "@material-ui/core/CardContent";
-import FormControl from "@material-ui/core/FormControl";
-import FormControlLabel from "@material-ui/core/FormControlLabel";
-import Radio from "@material-ui/core/Radio";
-import RadioGroup from "@material-ui/core/RadioGroup";
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
-import * as React from "react";
-
-import { VoucherType } from "../..";
-import CardTitle from "../../../components/CardTitle";
-import ControlledCheckbox from "../../../components/ControlledCheckbox";
-import FormSpacer from "../../../components/FormSpacer";
-import PriceField from "../../../components/PriceField";
-import SingleAutocompleteSelectField from "../../../components/SingleAutocompleteSelectField";
-import i18n from "../../../i18n";
-
-interface Choice {
- label: string;
- value: string;
-}
-
-const styles = (theme: Theme) =>
- createStyles({
- card: {
- overflow: "visible"
- },
- formControl: {
- margin: `0 ${theme.spacing.unit * 3}px`
- }
- });
-
-interface VoucherPropertiesProps extends WithStyles<typeof styles> {
- voucher?: {
- id: string;
- type: VoucherType;
- product: {
- id: string;
- name: string;
- } | null;
- category: {
- id: string;
- name: string;
- } | null;
- applyTo: string | null;
- limit: { amount: number; currency: string } | null;
- };
- data?: {
- applyToShipping: Choice | null;
- applyToAll: boolean | null;
- type: VoucherType;
- limit: number | null;
- product: Choice | null;
- category: Choice | null;
- };
- disabled?: boolean;
- categorySearchResults?: Array<{
- id: string;
- name: string;
- }>;
- productSearchResults?: Array<{
- id: string;
- name: string;
- }>;
- shippingSearchResults?: Array<{
- label: string;
- code: string;
- }>;
- loadingCategories?: boolean;
- loadingProducts?: boolean;
- loadingShipping?: boolean;
- fetchCategories?();
- fetchProducts?();
- fetchShipping?();
- onChange?(event: React.ChangeEvent<any>);
-}
-
-const VoucherProperties = withStyles(styles, { name: "VoucherProperties" })(
- ({
- classes,
- data,
- disabled,
- fetchCategories,
- fetchProducts,
- fetchShipping,
- loadingCategories,
- loadingProducts,
- loadingShipping,
- productSearchResults,
- shippingSearchResults,
- onChange
- }: VoucherPropertiesProps) => (
- <Card classes={{ root: classes.card }}>
- <CardTitle title={i18n.t("Voucher type")} />
- <FormControl required className={classes.formControl}>
- <RadioGroup name="type" value={data.type} onChange={onChange}>
- <FormControlLabel
- disabled={disabled}
- value="VALUE"
- control={<Radio />}
- label={i18n.t("Whole cart")}
- />
- <FormControlLabel
- disabled={disabled}
- value="SHIPPING"
- control={<Radio />}
- label={i18n.t("Shipping")}
- />
- <FormControlLabel
- disabled={disabled}
- value="PRODUCT"
- control={<Radio />}
- label={i18n.t("Product")}
- />
- <FormControlLabel
- disabled={disabled}
- value="CATEGORY"
- control={<Radio />}
- label={i18n.t("Category")}
- />
- </RadioGroup>
- </FormControl>
- <CardContent>
- {data.type === "VALUE" && (
- <PriceField
- disabled={disabled}
- hint={i18n.t("Optional")}
- label={i18n.t("Minimal cart value")}
- name="limit"
- onChange={onChange}
- value={data.limit}
- />
- )}
- {data.type === "SHIPPING" && (
- <>
- <SingleAutocompleteSelectField
- choices={
- shippingSearchResults
- ? shippingSearchResults.map(s => ({
- label: s.label,
- value: s.code
- }))
- : []
- }
- fetchChoices={fetchShipping}
- label={i18n.t("Discounted shipping")}
- loading={loadingShipping}
- name="applyTo"
- onChange={onChange}
- value={data.applyToShipping}
- />
- <FormSpacer />
- <PriceField
- disabled={disabled}
- hint={i18n.t("Optional")}
- label={i18n.t("Minimal cart value")}
- name="limit"
- onChange={onChange}
- value={data.limit}
- />
- </>
- )}
- {data.type === "PRODUCT" && (
- <>
- <SingleAutocompleteSelectField
- choices={
- productSearchResults
- ? productSearchResults.map(s => ({
- label: s.name,
- value: s.id
- }))
- : []
- }
- fetchChoices={fetchProducts}
- label={i18n.t("Discounted product")}
- loading={loadingProducts}
- name="product"
- onChange={onChange}
- value={data.product}
- />
- <FormSpacer />
- <ControlledCheckbox
- checked={data.applyToAll}
- onChange={onChange}
- label={i18n.t("Apply to whole cart")}
- name="applyToAll"
- />
- </>
- )}
- {data.type === "CATEGORY" && (
- <>
- <SingleAutocompleteSelectField
- choices={
- productSearchResults
- ? productSearchResults.map(s => ({
- label: s.name,
- value: s.id
- }))
- : []
- }
- fetchChoices={fetchCategories}
- label={i18n.t("Discounted category")}
- loading={loadingCategories}
- name="category"
- onChange={onChange}
- value={data.category}
- />
- <FormSpacer />
- <ControlledCheckbox
- checked={data.applyToAll}
- onChange={onChange}
- label={i18n.t("Apply to whole cart")}
- name="applyToAll"
- />
- </>
- )}
- </CardContent>
- </Card>
- )
-);
-VoucherProperties.displayName = "VoucherProperties";
-export default VoucherProperties;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherProperties/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherProperties/index.ts
deleted file mode 100644
index e7b7fcc637..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherProperties/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherProperties";
-export * from "./VoucherProperties";
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherUsability/VoucherUsability.tsx b/saleor/static/dashboard-next/vouchers/components/VoucherUsability/VoucherUsability.tsx
deleted file mode 100644
index 671d05e3d5..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherUsability/VoucherUsability.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-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 { FormSpacer } from "../../../components/FormSpacer";
-import i18n from "../../../i18n";
-
-interface VoucherDateProps {
- disabled?: boolean;
- data: {
- startDate: string;
- endDate: string | null;
- usageLimit: number | null;
- };
- onChange?(event: React.ChangeEvent<any>);
-}
-
-const VoucherUsability: React.StatelessComponent<VoucherDateProps> = ({
- data,
- disabled,
- onChange
-}) => (
- <Card>
- <CardContent>
- <TextField
- InputLabelProps={{ shrink: true }}
- disabled={disabled}
- fullWidth
- label={i18n.t("Active since")}
- name="startDate"
- onChange={onChange}
- type="date"
- value={data.startDate}
- />
- <FormSpacer />
- <TextField
- InputLabelProps={{ shrink: true }}
- disabled={disabled}
- fullWidth
- label={i18n.t("Active until")}
- name="endDate"
- onChange={onChange}
- type="date"
- value={data.endDate}
- />
- <FormSpacer />
- <TextField
- disabled={disabled}
- fullWidth
- label={i18n.t("Usage limit")}
- name="usageLimit"
- onChange={onChange}
- value={data.usageLimit}
- />
- </CardContent>
- </Card>
-);
-VoucherUsability.displayName = "VoucherUsability";
-export default VoucherUsability;
diff --git a/saleor/static/dashboard-next/vouchers/components/VoucherUsability/index.ts b/saleor/static/dashboard-next/vouchers/components/VoucherUsability/index.ts
deleted file mode 100644
index e8bd9d276d..0000000000
--- a/saleor/static/dashboard-next/vouchers/components/VoucherUsability/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { default } from "./VoucherUsability";
-export * from "./VoucherUsability";
diff --git a/saleor/static/dashboard-next/vouchers/fixtures.ts b/saleor/static/dashboard-next/vouchers/fixtures.ts
deleted file mode 100644
index 0ebffdbbdc..0000000000
--- a/saleor/static/dashboard-next/vouchers/fixtures.ts
+++ /dev/null
@@ -1,294 +0,0 @@
-export const vouchers = [
- {
- applyTo: "all",
- category: null,
- code: "COPY",
- discountValue: 71,
- discountValueType: "FIXED",
- endDate: "2027-07-23T12:08:56.291Z",
- id: "v76793",
- limit: null,
- name: "aut odit",
- product: {
- id: "p34799",
- name: "Gorgeous Wooden Tuna",
- price: { amount: 83.57784207415109, currency: "KHR" }
- },
- startDate: "2018-08-17T07:26:05.192Z",
- type: "PRODUCT",
- usageLimit: 525,
- used: 359
- },
- {
- applyTo: null,
- category: null,
- code: "SLEEK WOODEN KEYBOARD",
- discountValue: 61,
- discountValueType: "PERCENTAGE",
- endDate: "2018-12-25T18:36:26.959Z",
- id: "v64875",
- limit: { amount: 20, currency: "CHF" },
- name: "omnis quia",
- product: null,
- startDate: "2018-08-15T23:58:54.945Z",
- type: "SHIPPING",
- usageLimit: 880,
- used: 342
- },
- {
- applyTo: "all",
- category: { id: "c22379", name: "Steel", products: { totalCount: 6 } },
- code: "CUBAN PESO PESO CONVERTIBLE",
- discountValue: 89,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v89064",
- limit: null,
- name: null,
- product: null,
- startDate: "2018-08-12T12:12:04.133Z",
- type: "CATEGORY",
- usageLimit: null,
- used: null
- },
- {
- applyTo: "LI",
- category: null,
- code: "BIFURCATED",
- discountValue: 75,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v90367",
- limit: { amount: 0, currency: "EEK" },
- name: null,
- product: null,
- startDate: "2018-08-13T14:47:59.997Z",
- type: "SHIPPING",
- usageLimit: null,
- used: null
- },
- {
- applyTo: null,
- category: null,
- code: "REDUNDANT",
- discountValue: 10,
- discountValueType: "PERCENTAGE",
- endDate: "2021-02-25T06:05:33.803Z",
- id: "v47286",
- limit: null,
- name: "quod dolor",
- product: null,
- startDate: "2018-08-19T14:24:09.321Z",
- type: "VALUE",
- usageLimit: 347,
- used: 315
- },
- {
- applyTo: "one",
- category: null,
- code: "DEPOSIT",
- discountValue: 39,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v6809",
- limit: null,
- name: "libero nemo",
- product: {
- id: "p72465",
- name: "Licensed Plastic Cheese",
- price: { amount: 589.1264441625161, currency: "MAD" }
- },
- startDate: "2018-08-12T11:31:45.570Z",
- type: "PRODUCT",
- usageLimit: 939,
- used: 801
- },
- {
- applyTo: "all",
- category: null,
- code: "OLIVE",
- discountValue: 41,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v6914",
- limit: { amount: 0, currency: "XTS" },
- name: "vel nobis",
- product: {
- id: "p60415",
- name: "Handcrafted Plastic Keyboard",
- price: { amount: 216.45774857735978, currency: "INR BTN" }
- },
- startDate: "2018-08-11T17:03:15.977Z",
- type: "PRODUCT",
- usageLimit: null,
- used: null
- },
- {
- applyTo: "one",
- category: null,
- code: "BLUETOOTH",
- discountValue: 43,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v56019",
- limit: null,
- name: "non optio",
- product: {
- id: "p53885",
- name: "Refined Cotton Chair",
- price: { amount: 124.65143750356478, currency: "RON" }
- },
- startDate: "2018-08-11T11:09:07.002Z",
- type: "PRODUCT",
- usageLimit: 304,
- used: 232
- },
- {
- applyTo: "one",
- category: null,
- code: "GORGEOUS",
- discountValue: 83,
- discountValueType: "FIXED",
- endDate: "2024-01-17T10:16:26.589Z",
- id: "v68418",
- limit: null,
- name: "numquam modi",
- product: {
- id: "p37268",
- name: "Small Steel Gloves",
- price: { amount: 897.1040565714468, currency: "TJS" }
- },
- startDate: "2018-08-20T01:27:59.891Z",
- type: "PRODUCT",
- usageLimit: null,
- used: null
- },
- {
- applyTo: "one",
- category: null,
- code: "GLOBAL",
- discountValue: 38,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v71008",
- limit: { amount: 70, currency: "XOF" },
- name: "sunt odit",
- product: {
- id: "p12490",
- name: "Small Granite Car",
- price: { amount: 107.31189752489989, currency: "XOF" }
- },
- startDate: "2018-08-19T03:42:51.965Z",
- type: "PRODUCT",
- usageLimit: 150,
- used: 12
- },
- {
- applyTo: "all",
- category: { id: "c89806", name: "Chief", products: { totalCount: 2 } },
- code: "USERS",
- discountValue: 44,
- discountValueType: "PERCENTAGE",
- endDate: "2027-08-07T17:56:17.717Z",
- id: "v59684",
- limit: { amount: 70, currency: "INR" },
- name: "distinctio aliquam",
- product: null,
- startDate: "2018-08-20T08:29:30.527Z",
- type: "CATEGORY",
- usageLimit: 456,
- used: 402
- },
- {
- applyTo: "all",
- category: null,
- code: "BACON",
- discountValue: 52,
- discountValueType: "FIXED",
- endDate: "2018-10-23T13:04:44.374Z",
- id: "v75583",
- limit: null,
- name: null,
- product: {
- id: "p34343",
- name: "Handmade Metal Computer",
- price: { amount: 970.0800823446644, currency: "BIF" }
- },
- startDate: "2018-08-11T22:44:57.412Z",
- type: "PRODUCT",
- usageLimit: null,
- used: null
- },
- {
- applyTo: "RS",
- category: null,
- code: "BLUETOOTH",
- discountValue: 17,
- discountValueType: "FIXED",
- endDate: "2024-06-04T13:48:28.823Z",
- id: "v98631",
- limit: null,
- name: null,
- product: null,
- startDate: "2018-08-19T10:37:04.055Z",
- type: "SHIPPING",
- usageLimit: 31,
- used: 7
- },
- {
- applyTo: "all",
- category: {
- id: "c5791",
- name: "Buckinghamshire",
- products: { totalCount: 7 }
- },
- code: "PINK",
- discountValue: 0,
- discountValueType: "PERCENTAGE",
- endDate: null,
- id: "v98006",
- limit: null,
- name: "id porro",
- product: null,
- startDate: "2018-08-14T09:32:44.445Z",
- type: "CATEGORY",
- usageLimit: 259,
- used: 58
- },
- {
- applyTo: "all",
- category: {
- id: "c78309",
- name: "Bedfordshire",
- products: { totalCount: 4 }
- },
- code: "INDIANA",
- discountValue: 22,
- discountValueType: "PERCENTAGE",
- endDate: "2028-08-06T13:03:06.531Z",
- id: "v31393",
- limit: null,
- name: null,
- product: null,
- startDate: "2018-08-17T22:25:50.902Z",
- type: "CATEGORY",
- usageLimit: null,
- used: null
- },
- {
- applyTo: null,
- category: null,
- code: "CROSSROAD",
- discountValue: 97,
- discountValueType: "FIXED",
- endDate: "2025-01-26T18:51:51.823Z",
- id: "v77867",
- limit: { amount: 90, currency: "GTQ" },
- name: "non et",
- product: null,
- startDate: "2018-08-14T22:23:22.199Z",
- type: "VALUE",
- usageLimit: 133,
- used: 65
- }
-];
diff --git a/saleor/static/dashboard-next/vouchers/index.ts b/saleor/static/dashboard-next/vouchers/index.ts
deleted file mode 100644
index 57424f8f55..0000000000
--- a/saleor/static/dashboard-next/vouchers/index.ts
+++ /dev/null
@@ -1,71 +0,0 @@
-import i18n from "../i18n";
-
-export type VoucherType =
- | "CATEGORY"
- | "PRODUCT"
- | "SHIPPING"
- | "VALUE"
- | string;
-
-interface Voucher {
- type: VoucherType;
- discountValueType: "PERCENTAGE" | "FIXED" | string;
- discountValue: number;
- product: {
- name: string;
- } | null;
- category: {
- name: string;
- } | null;
-}
-export function createVoucherName(voucher: Voucher, currency: string) {
- switch (voucher.type) {
- case "CATEGORY":
- if (voucher.discountValueType === "FIXED") {
- return i18n.t(
- "{{ value }} {{ currency }} discount for {{ category }}",
- {
- category: voucher.category.name,
- currency,
- value: voucher.discountValue
- }
- );
- }
- return i18n.t("{{ value }}% discount for {{ category }}", {
- category: voucher.category.name,
- value: voucher.discountValue
- });
- case "PRODUCT":
- if (voucher.discountValueType === "FIXED") {
- return i18n.t("{{ value }} {{ currency }} discount for {{ product }}", {
- currency,
- product: voucher.product.name,
- value: voucher.discountValue
- });
- }
- return i18n.t("{{ value }}% discount for {{ product }}", {
- product: voucher.product.name,
- value: voucher.discountValue
- });
- case "SHIPPING":
- if (voucher.discountValueType === "FIXED") {
- return i18n.t("{{ value }} {{ currency }} discount for shipping", {
- currency,
- value: voucher.discountValue
- });
- }
- return i18n.t("{{ value }}% discount for shipping", {
- value: voucher.discountValue
- });
- case "VALUE":
- if (voucher.discountValueType === "FIXED") {
- return i18n.t("{{ value }} {{ currency }} discount", {
- currency,
- value: voucher.discountValue
- });
- }
- return i18n.t("{{ value }}% discount", {
- value: voucher.discountValue
- });
- }
-}