import dayjs from 'dayjs';
import type {
  WorkbenchActivityItemSource,
  WorkbenchBannerSummarySource,
  WorkbenchKpiSource,
  WorkbenchProjectItemSource,
  WorkbenchTodoItemSource
} from './homepage';

const now = dayjs();
const iso = (date: dayjs.Dayjs) => date.format('YYYY-MM-DD HH:mm:ss');

export const workbenchBannerSummaryMock = {
  todoCount: 8,
  upcomingCount: 2,
  weekDone: 12,
  weekTotal: 18,
  weekInProgress: 5,
  weekOverdue: 1
} satisfies WorkbenchBannerSummarySource;

export const workbenchKpiMock = {
  todo: { count: 8, diffFromYesterday: 1 },
  task: { count: 14, diffFromYesterday: -1 },
  project: { count: 3, activeCount: 2 },
  requirement: { count: 6, pendingReview: 2 }
} satisfies WorkbenchKpiSource;

export const workbenchTodoMock = [
  {
    id: 'todo-1',
    category: 'review',
    title: '订单导出 V2 需求评审',
    deadline: iso(now.add(2, 'day').hour(18).minute(0)),
    source: '张三 · 收银台 V3',
    highPriority: true,
    routeKey: 'product_list'
  },
  {
    id: 'todo-2',
    category: 'task',
    title: '支付回调接口联调',
    deadline: iso(now.add(1, 'day').hour(17).minute(30)),
    source: '收银台 V3 · 后端联调',
    routeKey: 'project_list'
  },
  {
    id: 'todo-3',
    category: 'ticket',
    title: '工单 #1024 等待我处理',
    deadline: iso(now.hour(20).minute(0)),
    source: '王五 · 客户反馈',
    routeKey: 'ticket'
  },
  {
    id: 'todo-4',
    category: 'mention',
    title: '需求「会员等级」中 @ 了你',
    deadline: null,
    source: '李四 · 会员中心',
    routeKey: 'product_list'
  },
  {
    id: 'todo-5',
    category: 'task',
    title: '订单中心结算文档评审',
    deadline: iso(now.add(4, 'day').hour(15).minute(0)),
    source: '订单中心 · 文档',
    routeKey: 'project_list'
  },
  {
    id: 'todo-6',
    category: 'review',
    title: 'API 返回结构调整评审',
    deadline: iso(now.subtract(1, 'day').hour(18).minute(0)),
    source: '赵六 · 收银台 V3',
    overdue: true,
    highPriority: true,
    routeKey: 'product_list'
  },
  {
    id: 'todo-7',
    category: 'task',
    title: '会员等级提示文案校对',
    deadline: iso(now.add(3, 'day').hour(11).minute(0)),
    source: '会员中心 · 文案',
    routeKey: 'project_list'
  },
  {
    id: 'todo-8',
    category: 'ticket',
    title: '工单 #1018 用户登录异常',
    deadline: iso(now.add(1, 'day').hour(10).minute(0)),
    source: '客户支持 · 紧急',
    highPriority: true,
    routeKey: 'ticket'
  }
] satisfies WorkbenchTodoItemSource[];

export const workbenchActivityMock = [
  {
    id: 'act-1',
    actor: '张三',
    action: '提交了需求评审申请',
    target: '订单导出 V2',
    targetKind: 'requirement',
    time: iso(now.subtract(10, 'minute'))
  },
  {
    id: 'act-2',
    actor: '李四',
    action: '完成了任务',
    target: '支付回调接口联调',
    targetKind: 'task',
    time: iso(now.subtract(2, 'hour'))
  },
  {
    id: 'act-3',
    actor: '李四',
    action: '在需求中 @ 了你',
    target: '会员等级',
    targetKind: 'requirement',
    time: iso(now.subtract(1, 'day').hour(17).minute(23)),
    mentioned: true
  },
  {
    id: 'act-4',
    actor: '王五',
    action: '提交了工单',
    target: '#1024 · 客户反馈',
    targetKind: 'ticket',
    time: iso(now.subtract(1, 'day').hour(15).minute(8))
  },
  {
    id: 'act-5',
    actor: '赵六',
    action: '把项目状态调整为',
    target: '试运行（订单中心）',
    targetKind: 'project',
    time: iso(now.subtract(2, 'day').hour(10).minute(0))
  },
  {
    id: 'act-6',
    actor: '系统',
    action: '提醒：你有 1 项任务即将逾期',
    target: 'API 返回结构调整评审',
    targetKind: 'requirement',
    time: iso(now.subtract(3, 'day').hour(9).minute(30))
  },
  {
    id: 'act-7',
    actor: '钱七',
    action: '更新了产品资料',
    target: '收银台 V3 · 定位说明',
    targetKind: 'product',
    time: iso(now.subtract(4, 'day').hour(16).minute(45))
  }
] satisfies WorkbenchActivityItemSource[];

export const workbenchProjectMock = [
  {
    id: 'prj-1',
    name: '收银台 V3',
    code: 'CASHIER-V3',
    status: 'active',
    myRole: '项目负责人',
    progress: 72,
    myTaskCount: 6,
    myPendingTaskCount: 2,
    lastActiveTime: iso(now.subtract(35, 'minute'))
  },
  {
    id: 'prj-2',
    name: '会员中心',
    code: 'MEMBER',
    status: 'active',
    myRole: '后端负责人',
    progress: 58,
    myTaskCount: 4,
    myPendingTaskCount: 1,
    lastActiveTime: iso(now.subtract(3, 'hour'))
  },
  {
    id: 'prj-3',
    name: '订单中心',
    code: 'ORDER-CENTER',
    status: 'preview',
    myRole: '产品经理',
    progress: 95,
    myTaskCount: 4,
    myPendingTaskCount: 0,
    lastActiveTime: iso(now.subtract(2, 'day').hour(10))
  }
] satisfies WorkbenchProjectItemSource[];
