import { ReactNode, useState } from "react"; import { useTranslation } from "react-i18next"; import { Button, ButtonProps, Modal, ModalProps } from "@patternfly/react-core"; import { TranslationKeys } from "../../i18next"; type ContinueCancelModalProps = Omit & { modalTitle: TranslationKeys; modalMessage?: string; buttonTitle: TranslationKeys | ReactNode; buttonVariant?: ButtonProps["variant"]; isDisabled?: boolean; onContinue: () => void; continueLabel?: TranslationKeys; cancelLabel?: TranslationKeys; component?: React.ElementType | React.ComponentType; children?: ReactNode; }; export const ContinueCancelModal = ({ modalTitle, modalMessage, buttonTitle, isDisabled, buttonVariant, onContinue, continueLabel = "continue", cancelLabel = "doCancel", component = "button", children, ...rest }: ContinueCancelModalProps) => { const { t } = useTranslation(); const [open, setOpen] = useState(false); const Component = component; return ( <> setOpen(true)} isDisabled={isDisabled} > { //@ts-ignore typeof buttonTitle === "string" ? t(buttonTitle) : buttonTitle } setOpen(false)} actions={[ , , ]} > { //@ts-ignore modalMessage ? t(modalMessage) : children } ); };