Skip to content

Commit 0574f44

Browse files
committed
update stories
1 parent 644e565 commit 0574f44

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
import { Story } from "@storybook/react";
2-
import { ScheduleForm, ScheduleFormProps } from "./ScheduleForm";
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { ScheduleForm } from "./ScheduleForm";
33
import { mockApiError } from "testHelpers/entities";
4+
import { action } from "@storybook/addon-actions";
45

5-
export default {
6-
title: "pages/UserSettingsPage/SchedulePage/ScheduleForm",
7-
component: ScheduleForm,
8-
argTypes: {
9-
onSubmit: { action: "Submit" },
10-
},
11-
};
12-
13-
const Template: Story<ScheduleFormProps> = (args: ScheduleFormProps) => (
14-
<ScheduleForm {...args} />
15-
);
16-
17-
export const ExampleDefault = Template.bind({});
18-
ExampleDefault.args = {
6+
const defaultArgs = {
197
submitting: false,
208
initialValues: {
219
raw_schedule: "CRON_TZ=Australia/Sydney 0 2 * * *",
@@ -25,41 +13,53 @@ ExampleDefault.args = {
2513
next: "2023-09-05T02:00:00+10:00",
2614
},
2715
updateErr: undefined,
28-
onSubmit: () => {
29-
return Promise.resolve();
30-
},
3116
now: new Date("2023-09-04T15:00:00+10:00"),
17+
onSubmit: action("onSubmit"),
3218
};
3319

34-
export const ExampleUserSet = Template.bind({});
35-
ExampleUserSet.args = {
36-
...ExampleDefault.args,
37-
initialValues: {
38-
raw_schedule: "CRON_TZ=America/Chicago 0 2 * * *",
39-
user_set: true,
40-
time: "02:00",
41-
timezone: "America/Chicago",
42-
next: "2023-09-05T02:00:00-05:00",
20+
const meta: Meta<typeof ScheduleForm> = {
21+
title: "pages/UserSettingsPage/ScheduleForm",
22+
component: ScheduleForm,
23+
args: defaultArgs,
24+
};
25+
export default meta;
26+
27+
type Story = StoryObj<typeof ScheduleForm>;
28+
29+
export const ExampleDefault: Story = {};
30+
31+
export const ExampleUserSet: Story = {
32+
args: {
33+
...defaultArgs,
34+
initialValues: {
35+
raw_schedule: "CRON_TZ=America/Chicago 0 2 * * *",
36+
user_set: true,
37+
time: "02:00",
38+
timezone: "America/Chicago",
39+
next: "2023-09-05T02:00:00-05:00",
40+
},
41+
now: new Date("2023-09-04T15:00:00-05:00"),
4342
},
44-
now: new Date("2023-09-04T15:00:00-05:00"),
4543
};
4644

47-
export const Submitting = Template.bind({});
48-
Submitting.args = {
49-
...ExampleDefault.args,
50-
submitting: true,
45+
export const Submitting: Story = {
46+
args: {
47+
...defaultArgs,
48+
submitting: true,
49+
},
5150
};
5251

53-
export const WithError = Template.bind({});
54-
WithError.args = {
55-
...ExampleDefault.args,
56-
updateErr: mockApiError({
57-
message: "Invalid schedule",
58-
validations: [
59-
{
60-
field: "schedule",
61-
detail: "Could not validate cron schedule.",
62-
},
63-
],
64-
}),
52+
export const WithError: Story = {
53+
args: {
54+
...defaultArgs,
55+
updateErr: mockApiError({
56+
message: "Invalid schedule",
57+
validations: [
58+
{
59+
field: "schedule",
60+
detail: "Could not validate cron schedule.",
61+
},
62+
],
63+
}),
64+
},
6565
};

0 commit comments

Comments
 (0)