import type { Meta, StoryObj } from '@storybook/react'; import { Button } from '@views/components/common/Button'; import type { PromptDialogProps } from '@views/components/common/Prompt'; import PromptDialog from '@views/components/common/Prompt'; import Text from '@views/components/common/Text/Text'; import React from 'react'; const meta = { title: 'Components/Common/Prompt', component: PromptDialog, parameters: { layout: 'centered', }, tags: ['autodocs'], argTypes: { isOpen: { control: 'boolean' }, title: { control: 'object' }, content: { control: 'object' }, children: { control: 'object' }, }, } satisfies Meta; export default meta; const PromptDialogWithButton = ({ children, ...args }: PromptDialogProps) => { const [isOpen, setIsOpen] = React.useState(false); const handleOpen = () => setIsOpen(true); const handleClose = () => setIsOpen(false); const { title, content } = args; const childrenWithHandleClose: React.ReactElement[] = (children ?? []).map(child => { if (child.type === Button) { return React.cloneElement(child, { onClick: () => handleClose() } as React.HTMLAttributes); } return child; }); return (
{childrenWithHandleClose}
); }; export const AreYouSure: StoryObj = { render: args => , args: { title: Are you sure?, content: ( Deleting Main Schedule is permanent and will remove all added courses and schedules. ), children: [ , , ], }, }; export const YouHave10ActiveSchedules: StoryObj = { render: args => , args: { title: You have 10 active schedules!, content: ( To encourage organization, please consider removing some unused schedules you may have. ), children: [ , ], }, }; export const WelcomeToUTRPV2: StoryObj = { render: args => , args: { title: Welcome to UTRP V2!, content: ( You may have already began planning your Summer or Fall schedule. To migrate your courses into v2.0 please select “Migrate,” or start fresh. ), children: [ , , ], }, };