Files
TheGame/packages/web/components/ConfirmModal.tsx
dan13ram 8517a26048 Upgrade dependencies (#486)
* upgraded storybook dependencies

* upgraded web dependencies

* updated timezone selector

* upgrade chakra in metamaps

* upgraded react-dnd in metamaps

* upgraded framer-motion

* fixed types in metamaps

* upgraded eslint

* upgraded lerna, husky and graphql

* upgraded node version

* removed metamaps package

* fixed all eslint issues

* ran yarn format to prettier format all files

* updated lint-staged & husky scripts

* add executable perms to pre-push scripts

* updated yarn.lock

* fixed eslint and moved chakra icons to ds

* fixed emotion errors

* removed extra useContext

* update yarn.lock

* upgraded more packages

* removed unnecessary .huskyrc.json

* lint fix
2021-05-01 12:46:48 +05:30

66 lines
1.4 KiB
TypeScript

import {
AlertDialog,
AlertDialogBody,
AlertDialogContent,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogOverlay,
MetaButton,
} from '@metafam/ds';
import React, { useRef } from 'react';
type Props = {
isOpen: boolean;
onNope: () => void;
onYep: () => void;
header?: React.ReactNode;
body?: React.ReactNode;
loading?: boolean;
loadingText?: string;
};
export const ConfirmModal: React.FC<Props> = ({
isOpen,
onNope,
onYep,
header,
body,
loading,
loadingText,
}) => {
const cancelRef = useRef<HTMLButtonElement>(null);
return (
<AlertDialog
isOpen={isOpen}
leastDestructiveRef={cancelRef}
onClose={onNope}
>
<AlertDialogOverlay>
<AlertDialogContent>
<AlertDialogHeader fontSize="lg" fontWeight="bold">
{header || ' Are you sure ?'}
</AlertDialogHeader>
{body && <AlertDialogBody>{body}</AlertDialogBody>}
<AlertDialogFooter>
<MetaButton ref={cancelRef} onClick={onNope} isDisabled={loading}>
Nope
</MetaButton>
<MetaButton
colorScheme="red"
onClick={onYep}
isLoading={loading}
loadingText={loadingText}
ml={3}
>
Yep
</MetaButton>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialogOverlay>
</AlertDialog>
);
};