Skip to content

Commit

Permalink
✅ [#4798] Added story to showcase the custom confirmation modal
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmolen committed Nov 8, 2024
1 parent 093d4e9 commit 4aaa7cc
Showing 1 changed file with 37 additions and 0 deletions.
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',
};

0 comments on commit 4aaa7cc

Please sign in to comment.