import React from 'react';
import { List,} from 'antd';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import ShareCodeListCard from './ShareCodeListCard';

dayjs.extend(utc);
dayjs.extend(timezone);

export interface ShareCodeItem {
  id: string;
  code: string;
  expiresAt: string;
  fileName: string;
  canUseTimes: number;
  resource: {
    id: string;
    type: string;
    url: string;
    meta: {
      size: number;
      filename: string;
    };
  }
}

interface ShareCodeListProps {
  data: ShareCodeItem[];
  loading?: boolean;
  onEdit?: (id: string,expiresAt:Date,canUseTimes:number,code:string) => void;
  onDelete?: (id: string) => void;
}

const ShareCodeList: React.FC<ShareCodeListProps> = ({ 
  data, 
  loading, 
  onEdit, 
  onDelete 
}) => {
  
  return (
    <List
      grid={{ gutter: 16, xs: 1, sm: 2, md: 4, lg: 4 }}
      dataSource={data}
      loading={loading}
      renderItem={(item) => (
        <List.Item>
          <ShareCodeListCard item={item} onEdit={onEdit} onDelete={onDelete} />
        </List.Item>
      )}
    />
  );
};

export default ShareCodeList;