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 11, 2024
1 parent 734f725 commit 95d30d0
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 95d30d0

Please sign in to comment.