import Typography from "@material-ui/core/Typography"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import { Choices, SingleSelectField } from "@saleor/components/SingleSelectField"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { buttonMessages } from "@saleor/intl"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { useStyles } from "../styles"; export interface ChannelDeleteDialogProps { channelsChoices: Choices; confirmButtonState: ConfirmButtonTransitionState; open: boolean; onBack: () => void; onClose: () => void; onConfirm: (targetChannelId: string) => void; } const ChannelDeleteDialog: React.FC = ({ channelsChoices = [], confirmButtonState, open, onBack, onClose, onConfirm }) => { const classes = useStyles({}); const intl = useIntl(); const [choice, setChoice] = useStateFromProps( !!channelsChoices.length ? channelsChoices[0].value : "" ); const hasChannels = !!channelsChoices?.length; return ( (hasChannels ? onConfirm(choice) : onBack())} title={intl.formatMessage({ defaultMessage: "Delete Channel", description: "dialog header" })} confirmButtonLabel={intl.formatMessage( hasChannels ? buttonMessages.delete : buttonMessages.ok )} variant={hasChannels ? "delete" : "default"} >
{hasChannels ? ( <>
setChoice(e.target.value)} />
) : ( )}
); }; ChannelDeleteDialog.displayName = "ChannelDeleteDialog"; export default ChannelDeleteDialog;