import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import { Theme } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; import { makeStyles } from "@material-ui/styles"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import { FormSpacer } from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import RadioGroupField from "@saleor/components/RadioGroupField"; import TextFieldWithChoice from "@saleor/components/TextFieldWithChoice"; import { FormErrors } from "../../../types"; import { DiscountValueTypeEnum } from "../../../types/globalTypes"; import { translateVoucherTypes } from "../../translations"; import { FormData } from "../VoucherDetailsPage"; interface VoucherValueProps { data: FormData; defaultCurrency: string; errors: FormErrors<"discountValue" | "type">; disabled: boolean; variant: string; onChange: (event: React.ChangeEvent) => void; } export enum VoucherType { ENTIRE_ORDER = "ENTIRE_ORDER", SPECIFIC_PRODUCT = "SPECIFIC_PRODUCT" } const useStyles = makeStyles( (theme: Theme) => ({ hr: { margin: `${theme.spacing.unit * 2}px 0` } }), { name: "VoucherValue" } ); const VoucherValue: React.FC = props => { const { data, defaultCurrency, disabled, errors, variant, onChange } = props; const classes = useStyles(props); const intl = useIntl(); const translatedVoucherTypes = translateVoucherTypes(intl); const voucherTypeChoices = Object.values(VoucherType).map(type => ({ label: translatedVoucherTypes[type], value: type })); return ( {variant === "update" && ( <>
)}
} checked={data.applyOncePerOrder} onChange={onChange} disabled={disabled} />
); }; export default VoucherValue;