|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import { fn } from '@storybook/test'; |
| 3 | +import { DashboardHome } from './DashboardHome'; |
| 4 | +import type { DashboardData } from '@/lib/dashboard'; |
| 5 | + |
| 6 | +const meta: Meta<typeof DashboardHome> = { |
| 7 | + title: 'Dashboard/DashboardHome', |
| 8 | + component: DashboardHome, |
| 9 | + parameters: { |
| 10 | + // Prevent real network calls in Storybook/Chromatic |
| 11 | + mockData: [], |
| 12 | + chromatic: { viewports: [320, 768, 1024, 1440] }, |
| 13 | + }, |
| 14 | +}; |
| 15 | +export default meta; |
| 16 | +type Story = StoryObj<typeof DashboardHome>; |
| 17 | + |
| 18 | +const mockData: DashboardData = { |
| 19 | + metrics: { |
| 20 | + totalSubscribers: 1247, |
| 21 | + totalSubscribersChangePercent: 12.4, |
| 22 | + mrr: 3840, |
| 23 | + mrrChangePercent: 8.2, |
| 24 | + activeSubscriptions: 892, |
| 25 | + activeSubscriptionsChangePercent: -2.1, |
| 26 | + }, |
| 27 | + recentActivity: [ |
| 28 | + { id: '1', type: 'subscription', title: 'New subscriber', description: '@alex_fan subscribed to Premium', timestamp: new Date('2026-04-23T14:00:00Z').toISOString(), metadata: '+$9.99' }, |
| 29 | + { id: '2', type: 'renewal', title: 'Renewal', description: '@jordan_art renewed Monthly', timestamp: new Date('2026-04-23T13:00:00Z').toISOString(), metadata: '$4.99' }, |
| 30 | + { id: '3', type: 'content', title: 'Content published', description: 'New post: "Behind the scenes"', timestamp: new Date('2026-04-23T12:00:00Z').toISOString() }, |
| 31 | + { id: '4', type: 'cancellation', title: 'Subscription cancelled', description: '@sam_user cancelled Premium', timestamp: new Date('2026-04-23T11:00:00Z').toISOString() }, |
| 32 | + { id: '5', type: 'payout', title: 'Payout sent', description: 'Weekly payout completed', timestamp: new Date('2026-04-23T10:00:00Z').toISOString(), metadata: '$420.00' }, |
| 33 | + ], |
| 34 | +}; |
| 35 | + |
| 36 | +export const Loaded: Story = { |
| 37 | + args: { |
| 38 | + onCreatePlan: fn(), |
| 39 | + onUploadContent: fn(), |
| 40 | + fetchDashboardData: () => Promise.resolve(mockData), |
| 41 | + }, |
| 42 | +}; |
| 43 | + |
| 44 | +export const Loading: Story = { |
| 45 | + args: { |
| 46 | + onCreatePlan: fn(), |
| 47 | + onUploadContent: fn(), |
| 48 | + fetchDashboardData: () => new Promise(() => {}), |
| 49 | + }, |
| 50 | +}; |
| 51 | + |
| 52 | +export const ErrorState: Story = { |
| 53 | + args: { |
| 54 | + onCreatePlan: fn(), |
| 55 | + onUploadContent: fn(), |
| 56 | + fetchDashboardData: () => Promise.reject(new Error('Network error')), |
| 57 | + }, |
| 58 | +}; |
0 commit comments