2021-08-16 13:44:00 +00:00
|
|
|
import { Button, DialogContent, Typography } from "@material-ui/core";
|
|
|
|
import HorizontalSpacer from "@saleor/apps/components/HorizontalSpacer";
|
|
|
|
import VerticalSpacer from "@saleor/apps/components/VerticalSpacer";
|
|
|
|
import useClipboard from "@saleor/hooks/useClipboard";
|
|
|
|
import useNotifier from "@saleor/hooks/useNotifier";
|
|
|
|
import { buttonMessages } from "@saleor/intl";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
2022-01-25 12:44:19 +00:00
|
|
|
import { giftCardCreateMessages as messages } from "./messages";
|
2021-08-16 13:44:00 +00:00
|
|
|
import { useGiftCardCreateDialogCodeContentStyles as useStyles } from "./styles";
|
|
|
|
|
|
|
|
interface GiftCardCreateDialogCodeContentProps {
|
|
|
|
cardCode: string;
|
|
|
|
onClose: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GiftCardCreateDialogCodeContent: React.FC<GiftCardCreateDialogCodeContentProps> = ({
|
|
|
|
cardCode,
|
|
|
|
onClose
|
|
|
|
}) => {
|
|
|
|
const classes = useStyles({});
|
|
|
|
const intl = useIntl();
|
|
|
|
const notify = useNotifier();
|
|
|
|
const [, copy] = useClipboard();
|
|
|
|
|
|
|
|
const onCopyCode = () => {
|
|
|
|
copy(cardCode);
|
|
|
|
notify({
|
|
|
|
status: "success",
|
|
|
|
text: intl.formatMessage(messages.copiedToClipboardTitle)
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<DialogContent>
|
|
|
|
<Typography>
|
|
|
|
{intl.formatMessage(messages.createdGiftCardLabel)}
|
|
|
|
</Typography>
|
|
|
|
<VerticalSpacer />
|
2021-09-08 11:32:05 +00:00
|
|
|
<Typography variant="h6" color="textSecondary" data-test-id="cardCode">
|
2021-08-16 13:44:00 +00:00
|
|
|
{cardCode}
|
|
|
|
</Typography>
|
|
|
|
<VerticalSpacer spacing={2} />
|
|
|
|
<div className={classes.buttonsContainer}>
|
|
|
|
<Button onClick={onCopyCode}>
|
|
|
|
{intl.formatMessage(messages.copyCodeLabel)}
|
|
|
|
</Button>
|
|
|
|
<HorizontalSpacer spacing={2} />
|
2021-09-08 11:32:05 +00:00
|
|
|
<Button
|
|
|
|
color="primary"
|
|
|
|
variant="contained"
|
|
|
|
onClick={onClose}
|
|
|
|
data-test="submit"
|
|
|
|
>
|
2021-08-16 13:44:00 +00:00
|
|
|
{intl.formatMessage(buttonMessages.ok)}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</DialogContent>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GiftCardCreateDialogCodeContent;
|