alpha
Login
or
Join now
nandi.uk
/
semble
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
chore: report card modal stories
author
pdelfan
date
2 months ago
(May 11, 2026, 4:05 PM -0700)
commit
ebc34d9c
ebc34d9cc7f06341f9213608e6a577f1c13cda1a
parent
34afadd6
34afadd6a25f564dac8176092866a405fda346ad
+118
1 changed file
Expand all
Collapse all
Unified
Split
src
webapp
features
cards
components
reportCardModal
ReportCardModal.stories.tsx
+118
src/webapp/features/cards/components/reportCardModal/ReportCardModal.stories.tsx
View file
Reviewed
···
1
1
+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
2
+
import { useState } from 'react';
3
3
+
import { Box, Button } from '@mantine/core';
4
4
+
import ReportCardModal, { ReportSubmission } from './ReportCardModal';
5
5
+
6
6
+
const mockResolve = async (input: ReportSubmission) => {
7
7
+
// eslint-disable-next-line no-console
8
8
+
console.log('[mock] report submitted', input);
9
9
+
await new Promise((r) => setTimeout(r, 800));
10
10
+
};
11
11
+
12
12
+
const mockReject = async () => {
13
13
+
await new Promise((r) => setTimeout(r, 600));
14
14
+
throw new Error('Network error — please try again.');
15
15
+
};
16
16
+
17
17
+
const mockNeverResolve = (): Promise<void> => new Promise(() => {});
18
18
+
19
19
+
const meta: Meta<typeof ReportCardModal> = {
20
20
+
title: 'Features/Cards/ReportCardModal',
21
21
+
component: ReportCardModal,
22
22
+
parameters: {
23
23
+
layout: 'fullscreen',
24
24
+
},
25
25
+
args: {
26
26
+
isOpen: true,
27
27
+
cardId: 'card-mock-001',
28
28
+
onClose: () => {
29
29
+
// eslint-disable-next-line no-console
30
30
+
console.log('[mock] modal closed');
31
31
+
},
32
32
+
onSubmit: mockResolve,
33
33
+
},
34
34
+
decorators: [
35
35
+
(Story) => (
36
36
+
<Box mih="100vh" p="md">
37
37
+
<Story />
38
38
+
</Box>
39
39
+
),
40
40
+
],
41
41
+
};
42
42
+
43
43
+
export default meta;
44
44
+
45
45
+
type Story = StoryObj<typeof ReportCardModal>;
46
46
+
47
47
+
export const Default: Story = {
48
48
+
name: 'Form (default)',
49
49
+
};
50
50
+
51
51
+
export const Submitting: Story = {
52
52
+
name: 'Submitting',
53
53
+
args: {
54
54
+
onSubmit: mockNeverResolve,
55
55
+
initialState: { kind: 'submitting' },
56
56
+
},
57
57
+
};
58
58
+
59
59
+
export const Success: Story = {
60
60
+
name: 'Success',
61
61
+
args: {
62
62
+
initialState: { kind: 'success' },
63
63
+
},
64
64
+
};
65
65
+
66
66
+
export const ErrorState: Story = {
67
67
+
name: 'Error',
68
68
+
args: {
69
69
+
initialState: {
70
70
+
kind: 'error',
71
71
+
message: 'Network error — please try again.',
72
72
+
},
73
73
+
},
74
74
+
};
75
75
+
76
76
+
export const AlreadyReported: Story = {
77
77
+
name: 'Already reported',
78
78
+
args: {
79
79
+
initialState: { kind: 'already-reported' },
80
80
+
},
81
81
+
};
82
82
+
83
83
+
export const SubmitFails: Story = {
84
84
+
name: 'Interactive: submission fails',
85
85
+
args: {
86
86
+
onSubmit: mockReject,
87
87
+
},
88
88
+
parameters: {
89
89
+
docs: {
90
90
+
description: {
91
91
+
story:
92
92
+
'Pick a reason and click Submit — the mock rejects so you can see the error state transition.',
93
93
+
},
94
94
+
},
95
95
+
},
96
96
+
};
97
97
+
98
98
+
const TriggerExample = () => {
99
99
+
const [open, setOpen] = useState(false);
100
100
+
return (
101
101
+
<>
102
102
+
<Button color="red" variant="light" onClick={() => setOpen(true)}>
103
103
+
Report card
104
104
+
</Button>
105
105
+
<ReportCardModal
106
106
+
isOpen={open}
107
107
+
onClose={() => setOpen(false)}
108
108
+
cardId="card-mock-001"
109
109
+
onSubmit={mockResolve}
110
110
+
/>
111
111
+
</>
112
112
+
);
113
113
+
};
114
114
+
115
115
+
export const FromTrigger: Story = {
116
116
+
name: 'Opened from a trigger button',
117
117
+
render: () => <TriggerExample />,
118
118
+
};