From 6ef0617e714c876056f6cb03ea9a0344ecffda70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Neves?= Date: Mon, 13 Nov 2023 16:08:24 +0000 Subject: [PATCH] Adding ability to pass in a ReactNode into the modal body (#205) * Accepting react node in confirmation modal * adding test * fixing bug * fixing api --- src/App.tsx | 2 +- .../ConfirmationDialog.stories.tsx | 12 ++--- .../ConfirmationDialog.test.tsx | 46 +++++++++---------- .../ConfirmationDialog/ConfirmationDialog.tsx | 34 ++++++++------ 4 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f2b6b275..7e22dd99 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -435,7 +435,7 @@ const App = () => { { + onConfirm={() => { console.log("close"); }} > diff --git a/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx b/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx index 9a6f5f44..7aaf65e3 100644 --- a/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx +++ b/src/components/ConfirmationDialog/ConfirmationDialog.stories.tsx @@ -1,4 +1,3 @@ -import { Link } from "@/components"; import { GridCenter } from "../commonElement"; import { ConfirmationDialog, @@ -10,21 +9,20 @@ const ConfirmationDialogComponent = ({ title, message, primaryActionLabel, - onPrimaryActionClick, + onConfirm, secondaryActionLabel, - onOpenChange, + onCancel, }: ConfirmationDialogProps) => ( - Open dialog ); @@ -50,7 +48,7 @@ export const Playground = { onOpenChange: (b: boolean) => { void b; }, - onPrimaryAcyionClick: () => { + onPrimaryActionClick: () => { console.log("Click"); }, primaryActionLabel: "Confirm", diff --git a/src/components/ConfirmationDialog/ConfirmationDialog.test.tsx b/src/components/ConfirmationDialog/ConfirmationDialog.test.tsx index e8ab81e0..180ed062 100644 --- a/src/components/ConfirmationDialog/ConfirmationDialog.test.tsx +++ b/src/components/ConfirmationDialog/ConfirmationDialog.test.tsx @@ -4,17 +4,16 @@ import { ConfirmationDialogProps, } from "@/components/ConfirmationDialog/ConfirmationDialog"; import { fireEvent } from "@testing-library/dom"; -import { Button } from "@/components"; describe("Dialog Component", () => { const renderDialog = ( { title = "Dialog Title", message = "Are you sure you want to proceed?", - onPrimaryActionClick = () => { + onConfirm = () => { void undefined; }, - onOpenChange, + onCancel, open, primaryActionLabel = "Confirm", secondaryActionLabel = "Cancel", @@ -25,10 +24,10 @@ describe("Dialog Component", () => { @@ -65,40 +64,34 @@ describe("Dialog Component", () => { it("closes the dialog on primary action click", () => { const title = "Dialog Title"; const primaryActionLabel = "PrimaryAction"; - const triggerLabel = "Open Dialog"; - const children =