misc_pterodactyl-panel/resources/scripts/components/elements/ConfirmationModal.tsx

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-11-25 20:25:03 +00:00
import type { ReactNode } from 'react';
import { useContext } from 'react';
2020-07-04 22:05:44 +00:00
import tw from 'twin.macro';
2022-11-25 20:25:03 +00:00
2020-07-04 22:05:44 +00:00
import Button from '@/components/elements/Button';
import ModalContext from '@/context/ModalContext';
2022-11-25 20:25:03 +00:00
import asModal from '@/hoc/asModal';
interface Props {
children: ReactNode;
title: string;
buttonText: string;
onConfirmed: () => void;
showSpinnerOverlay?: boolean;
2022-11-25 20:25:03 +00:00
}
2022-11-25 20:25:03 +00:00
function ConfirmationModal({ title, children, buttonText, onConfirmed }: Props) {
const { dismiss } = useContext(ModalContext);
return (
<>
<h2 css={tw`text-2xl mb-6`}>{title}</h2>
<div css={tw`text-neutral-300`}>{children}</div>
2022-11-25 20:25:03 +00:00
<div css={tw`flex flex-wrap items-center justify-end mt-8`}>
<Button isSecondary onClick={() => dismiss()} css={tw`w-full sm:w-auto border-transparent`}>
Cancel
</Button>
<Button color={'red'} css={tw`w-full sm:w-auto mt-4 sm:mt-0 sm:ml-4`} onClick={() => onConfirmed()}>
{buttonText}
</Button>
</div>
</>
);
2022-11-25 20:25:03 +00:00
}
2022-11-25 20:25:03 +00:00
export default asModal<Props>(props => ({
showSpinnerOverlay: props.showSpinnerOverlay,
}))(ConfirmationModal);