Files
TheGame/packages/web/components/ConfirmModal.tsx
Pacien Boisson dfff04ebaa [Quests] Frontend (#437)
* squash frontend changes

* Style quest explorer

* Style quest page

* Dates

* Dates

* Typecheck

* Prettier

* Fix create page layout

* Update only OPEN quests

* Repetition info

* Fix create quest errors

* Quest form Textarea

* Quest form Textarea

* Truncate texts

* Redirect if user not logged in

* Tooltips

* Factorize skills tags

* fix username in completions

* Metafam as default guild on creation

* Layouts

* Remove todo

* cooldown

* Rename to "claim quest"

* squash frontend changes

* Style quest explorer

* Style quest page

* Dates

* Dates

* Typecheck

* Prettier

* Fix create page layout

* Update only OPEN quests

* Repetition info

* Fix create quest errors

* Quest form Textarea

* Quest form Textarea

* Truncate texts

* Redirect if user not logged in

* Tooltips

* Factorize skills tags

* fix username in completions

* Metafam as default guild on creation

* Layouts

* Remove todo

* cooldown

* Rename to "claim quest"

* Move ConfirmModal in ds

* Extract pSeed balance

* Fix "created by me" switch

* Reword complete quest

* Style quest form

* prettier

* lint
2021-04-08 15:32:27 +04:00

74 lines
1.9 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>
);
};