Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/resources/scripts/components/elements/ConfirmationModal.tsx
7461 views
1
import React, { useContext } from 'react';
2
import tw from 'twin.macro';
3
import Button from '@/components/elements/Button';
4
import asModal from '@/hoc/asModal';
5
import ModalContext from '@/context/ModalContext';
6
7
type Props = {
8
title: string;
9
buttonText: string;
10
onConfirmed: () => void;
11
showSpinnerOverlay?: boolean;
12
};
13
14
const ConfirmationModal: React.FC<Props> = ({ title, children, buttonText, onConfirmed }) => {
15
const { dismiss } = useContext(ModalContext);
16
17
return (
18
<>
19
<h2 css={tw`text-2xl mb-6`}>{title}</h2>
20
<div css={tw`text-neutral-300`}>{children}</div>
21
<div css={tw`flex flex-wrap items-center justify-end mt-8`}>
22
<Button isSecondary onClick={() => dismiss()} css={tw`w-full sm:w-auto border-transparent`}>
23
Cancel
24
</Button>
25
<Button color={'red'} css={tw`w-full sm:w-auto mt-4 sm:mt-0 sm:ml-4`} onClick={() => onConfirmed()}>
26
{buttonText}
27
</Button>
28
</div>
29
</>
30
);
31
};
32
33
ConfirmationModal.displayName = 'ConfirmationModal';
34
35
export default asModal<Props>((props) => ({
36
showSpinnerOverlay: props.showSpinnerOverlay,
37
}))(ConfirmationModal);
38
39