-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33b5edd
commit ea403d6
Showing
9 changed files
with
146 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import PropTypes from 'prop-types'; | ||
import { confirmable } from 'react-confirm'; | ||
import {Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader} from "@nextui-org/react"; | ||
|
||
const CustomAlertConfirm = ({show, proceed, confirmation, options}) => ( | ||
<Modal | ||
size={'sm'} | ||
backdrop={'blur'} | ||
isOpen={show} | ||
onOpenChange={(status) => { | ||
proceed(status) | ||
}} | ||
> | ||
<ModalContent> | ||
<ModalHeader className="flex flex-col gap-1">Alert confirm!</ModalHeader> | ||
<ModalBody> | ||
<p className={'text-default-800 text-sm'}> | ||
{confirmation} | ||
</p> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button | ||
size={'sm'} | ||
variant={'flat'} | ||
color={options?.cancel?.color ? options?.cancel?.color : 'default'} | ||
onClick={() => proceed(false)} | ||
> | ||
{options?.cancel?.text ? options?.cancel?.text : 'Cancel'} | ||
</Button> | ||
<Button | ||
size={'sm'} | ||
variant={'flat'} | ||
color={options?.confirm?.color ? options?.confirm?.color : 'primary'} | ||
onClick={() => proceed(true)} | ||
> | ||
{options?.confirm?.text ? options?.confirm?.text : 'Confirm'} | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
|
||
CustomAlertConfirm.propTypes = { | ||
show: PropTypes.bool, // from confirmable. indicates if the dialog is shown or not. | ||
proceed: PropTypes.func, // from confirmable. call to close the dialog with promise resolved. | ||
confirmation: PropTypes.string, // arguments of your confirm function | ||
options: PropTypes.object // arguments of your confirm function | ||
} | ||
|
||
// confirmable HOC pass props `show`, `dismiss`, `cancel` and `proceed` to your component. | ||
export default confirmable(CustomAlertConfirm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createConfirmation } from 'react-confirm'; | ||
import CustomAlertConfirm from './CustomAlertConfirm'; | ||
|
||
// create confirm function | ||
export const confirm = createConfirmation(CustomAlertConfirm); | ||
|
||
// This is optional. But wrapping function makes it easy to use. | ||
export function confirmWrapper(confirmation, options = {}) { | ||
return confirm({ confirmation, options }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters