-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#4798] Added story to showcase the custom confirmation modal
- Loading branch information
1 parent
734f725
commit 95d30d0
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/openforms/js/components/admin/form_design/useConfirm.stories.js
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,37 @@ | ||
import {useState} from 'react'; | ||
|
||
import ActionButton from '../forms/ActionButton'; | ||
import useConfirm from './useConfirm'; | ||
|
||
const ButtonWithUseConfirm = () => { | ||
const [ConfirmationModal, confirm] = useConfirm( | ||
'A sample confirmation message', | ||
'The confirmation title' | ||
); | ||
const [confirmationResult, setConfirmationResult] = useState(null); | ||
return ( | ||
<div> | ||
<ActionButton | ||
text="Open confirmation modal" | ||
onClick={async () => { | ||
const result = await confirm(); | ||
setConfirmationResult(result); | ||
}} | ||
/> | ||
{confirmationResult !== null ? ( | ||
<p>Confirmation result: {confirmationResult.toString()}</p> | ||
) : null} | ||
<ConfirmationModal /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default { | ||
title: 'Admin / Custom / UseConfirm', | ||
render: () => <ButtonWithUseConfirm />, | ||
component: useConfirm, | ||
}; | ||
|
||
export const Default = { | ||
name: 'Default', | ||
}; |