import { App } from 'antd';
import type { SampleMeta } from '../../../widgets/core';
import {
  type EvidenceAttachmentItem,
  EvidenceAttachmentStrip,
} from '../index';

export const sampleMeta: SampleMeta = {
  id: 'evidence-attachment-strip-ui-base',
  componentId: 'evidence-attachment-strip-ui',
  title: 'Evidence Attachment Strip UI',
  description:
    '스크린샷, 문서, 로그, 링크를 같은 카드 스트립으로 정리하고 링크 열기, 복사, 미리보기 액션을 공통 제공하는 첨부 UI입니다.',
  category: 'Common',
  kind: 'base',
  variantLabel: 'Base',
  order: 58,
  features: ['docs', 'component-sample'],
};

const baseAttachments: EvidenceAttachmentItem[] = [
  {
    key: 'image',
    kind: 'image',
    title: 'widget-gps-sample.png',
    description: 'docs/assets/worklogs/2026-04-09/widget-gps-sample.png',
    linkUrl: '/docs/assets/worklogs/2026-04-09/widget-gps-sample.png',
    value: '/docs/assets/worklogs/2026-04-09/widget-gps-sample.png',
  },
  {
    key: 'markdown',
    kind: 'markdown',
    title: '2026-04-09.md',
    description: 'docs/worklogs/2026-04-09.md',
    linkUrl: '/docs/worklogs/2026-04-09.md',
    value: '# Worklog\n- Evidence Attachment Strip UI 정리\n- 작업일지 카드 미리보기 제공',
  },
  {
    key: 'preview',
    kind: 'preview',
    title: 'Release Preview',
    description: 'https://release.example.local/plan/board-post-14',
    linkUrl: 'https://release.example.local/plan/board-post-14',
    value: 'https://release.example.local/plan/board-post-14',
  },
  {
    key: 'code',
    kind: 'code',
    title: 'commands.log',
    description: '실행 로그',
    language: 'bash',
    value: 'npm run build\nnpm run preview',
  },
];

export function Sample() {
  const { message } = App.useApp();

  return (
    <EvidenceAttachmentStrip
      title="산출물 Preview"
      description="작업일지, 이미지, 링크, 로그를 같은 패턴으로 정리합니다."
      attachments={baseAttachments}
      compact
      onPreview={(attachment) => {
        message.info(`${String(attachment.title)} 미리보기 진입`);
      }}
      onCopy={async (attachment) => {
        await navigator.clipboard.writeText(attachment.copyValue ?? attachment.value);
        message.success(`${String(attachment.title)} 복사`);
      }}
      maxVisible={3}
    />
  );
}
