All files / laravel-saas/resources/js/Components/dashboard ActivityTable.stories.tsx

0% Statements 0/153
100% Branches 1/1
100% Functions 1/1
0% Lines 0/153

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167                                                                                                                                                                                                                                                                                                                                             
import type { Meta, StoryObj } from '@storybook/react';
import { ActivityTable } from './ActivityTable';
 
const meta = {
  title: 'Dashboard/ActivityTable',
  component: ActivityTable,
  parameters: {
    layout: 'padded',
  },
  tags: ['autodocs'],
} satisfies Meta<typeof ActivityTable>;
 
export default meta;
type Story = StoryObj<typeof meta>;
 
const sampleData = [
  {
    id: '1',
    user: {
      name: 'John Doe',
      email: 'john@example.com',
      avatar: 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=32&h=32&fit=crop&crop=face',
    },
    action: 'Created',
    target: 'New user account',
    status: 'success' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 5), // 5 minutes ago
  },
  {
    id: '2',
    user: {
      name: 'Jane Smith',
      email: 'jane@example.com',
    },
    action: 'Updated',
    target: 'Profile settings',
    status: 'success' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 15), // 15 minutes ago
  },
  {
    id: '3',
    user: {
      name: 'Mike Johnson',
      email: 'mike@example.com',
      avatar: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=32&h=32&fit=crop&crop=face',
    },
    action: 'Failed to process',
    target: 'Payment #12345',
    status: 'failed' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 30), // 30 minutes ago
  },
  {
    id: '4',
    user: {
      name: 'Sarah Wilson',
      email: 'sarah@example.com',
    },
    action: 'Uploaded',
    target: 'Document.pdf',
    status: 'pending' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 45), // 45 minutes ago
  },
  {
    id: '5',
    user: {
      name: 'David Brown',
      email: 'david@example.com',
      avatar: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=32&h=32&fit=crop&crop=face',
    },
    action: 'Logged in',
    target: 'Dashboard',
    status: 'warning' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 60), // 1 hour ago
  },
];
 
export const Default: Story = {
  args: {
    data: sampleData,
  },
};
 
export const WithCustomTitle: Story = {
  args: {
    data: sampleData,
    title: 'User Activity Log',
  },
};
 
export const NoHeader: Story = {
  args: {
    data: sampleData,
    showHeader: false,
  },
};
 
export const Empty: Story = {
  args: {
    data: [],
    title: 'No Activity',
  },
};
 
export const SingleItem: Story = {
  args: {
    data: [sampleData[0]],
    title: 'Recent Activity',
  },
};
 
export const SuccessOnly: Story = {
  args: {
    data: sampleData.filter(item => item.status === 'success'),
    title: 'Successful Actions',
  },
};
 
export const FailedOnly: Story = {
  args: {
    data: sampleData.filter(item => item.status === 'failed'),
    title: 'Failed Actions',
  },
};
 
const extraData = [
  {
    id: '6',
    user: {
      name: 'Emma Davis',
      email: 'emma@example.com',
    },
    action: 'Deleted',
    target: 'Old backup files',
    status: 'success' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 90),
  },
  {
    id: '7',
    user: {
      name: 'Alex Thompson',
      email: 'alex@example.com',
      avatar: 'https://images.unsplash.com/photo-1494790108755-2616b2e3c33e?w=32&h=32&fit=crop&crop=face',
    },
    action: 'Exported',
    target: 'Monthly report',
    status: 'pending' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 120),
  },
  {
    id: '8',
    user: {
      name: 'Lisa Garcia',
      email: 'lisa@example.com',
    },
    action: 'Updated',
    target: 'Security settings',
    status: 'warning' as const,
    timestamp: new Date(Date.now() - 1000 * 60 * 150),
  },
];
 
export const LongList: Story = {
  args: {
    data: [...sampleData, ...extraData],
    title: 'Extended Activity Log',
  },
};