From 3e1d0876150dabd50112c89adc60e7ef2e092fac Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Wed, 6 Mar 2024 17:47:55 +0100 Subject: [PATCH] refactor(design-system): Rename props Signed-off-by: Jeroen Branje --- .../src/components/Atoms/Dialog/Dialog.stories.tsx | 8 ++++---- .../src/components/Atoms/Dialog/Dialog.tsx | 14 +++++++------- .../src/components/Atoms/Dialog/Dialog.ui.test.tsx | 6 +++--- .../modules/Users/UsersDialogConfirm.tsx | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/design-system/src/components/Atoms/Dialog/Dialog.stories.tsx b/apps/design-system/src/components/Atoms/Dialog/Dialog.stories.tsx index ced0fc5f..657e0481 100644 --- a/apps/design-system/src/components/Atoms/Dialog/Dialog.stories.tsx +++ b/apps/design-system/src/components/Atoms/Dialog/Dialog.stories.tsx @@ -8,15 +8,15 @@ export default { title: 'Components/Dialog', } as Meta -const Template: Story = ({ open, setOpen, heading, description }) => ( - CLICK} /> +const Template: Story = ({ isOpen, setShowHide, heading, description }) => ( + CLICK} /> ) export const DialogStory = Template.bind({}) DialogStory.args = { - open: true, - setOpen: () => {}, + isOpen: true, + setShowHide: () => {}, heading: 'Heading', description: 'Description', } diff --git a/apps/design-system/src/components/Atoms/Dialog/Dialog.tsx b/apps/design-system/src/components/Atoms/Dialog/Dialog.tsx index d8e1a071..0ec69104 100644 --- a/apps/design-system/src/components/Atoms/Dialog/Dialog.tsx +++ b/apps/design-system/src/components/Atoms/Dialog/Dialog.tsx @@ -3,17 +3,17 @@ import { ExclamationTriangleIcon, XMarkIcon } from '@heroicons/react/24/outline' import { FC, Fragment, JSXElementConstructor, ReactElement } from 'react' interface DialogProps { - open: boolean - setOpen: (x: boolean) => void + isOpen: boolean + setShowHide: (x: boolean) => void heading: string | ReactElement> description: string | ReactElement> action: ReactElement } -export const Dialog: FC = ({ open, setOpen, heading, description, action }) => { +export const Dialog: FC = ({ isOpen, setShowHide, heading, description, action }) => { return ( - - + + = ({ open, setOpen, heading, description, a type="button" className="rounded-md bg-white dark:bg-gray-900 text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-900 focus:ring-offset-0" onClick={() => { - setOpen(false) + setShowHide(false) }} > Close @@ -72,7 +72,7 @@ export const Dialog: FC = ({ open, setOpen, heading, description, a type="button" className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto" onClick={() => { - setOpen(false) + setShowHide(false) }} > Cancel diff --git a/apps/design-system/src/components/Atoms/Dialog/Dialog.ui.test.tsx b/apps/design-system/src/components/Atoms/Dialog/Dialog.ui.test.tsx index 80310f7d..3072f6d1 100644 --- a/apps/design-system/src/components/Atoms/Dialog/Dialog.ui.test.tsx +++ b/apps/design-system/src/components/Atoms/Dialog/Dialog.ui.test.tsx @@ -6,13 +6,13 @@ describe('atoms/Dialog', () => { describe('render', () => { it('should render Dialog with content', () => { // when ... rendering component - const setOpenStub = jest.fn() + const setShowHideStub = jest.fn() render( BUTTON} />, ) diff --git a/apps/envited.ascs.digital/modules/Users/UsersDialogConfirm.tsx b/apps/envited.ascs.digital/modules/Users/UsersDialogConfirm.tsx index 78eb10a2..30bebf4a 100644 --- a/apps/envited.ascs.digital/modules/Users/UsersDialogConfirm.tsx +++ b/apps/envited.ascs.digital/modules/Users/UsersDialogConfirm.tsx @@ -2,7 +2,7 @@ import { Dialog } from '@envited-marketplace/design-system' import { TrashIcon } from '@heroicons/react/24/outline' -import { FC, Fragment, ReactElement, useState } from 'react' +import { FC, useState } from 'react' import { useTranslation } from '../../common/i18n' import { useNotification } from '../../common/notifications' @@ -15,13 +15,13 @@ interface DialogConfirmProps { export const UserDialogConfirm: FC = ({ id }) => { const { t } = useTranslation('Users') const { error, success } = useNotification() - const [open, setOpen] = useState(true) + const [showDialog, setShowDialog] = useState(true) const deleteUserWithId = (id: string) => async () => { try { await deleteUser(id) success(t('[Notification] success')) - setOpen(false) + setShowDialog(false) } catch (e) { error(t('[Notification] error')) } @@ -29,15 +29,15 @@ export const UserDialogConfirm: FC = ({ id }) => { return ( <> -