import { WEB_BASE_URL } from "../../api/request";
import { useAuth } from "../../stores/auth";

export interface ReportEntryConfig {
  title: string;
  subtitle: string;
  path: string;
  tags: string[];
}

export const reportEntries: Record<string, ReportEntryConfig> = {
  jimuReport: {
    title: "报表设计器",
    subtitle: "移动端用于快速进入 Web 报表设计器，复杂设计建议在 PC 端完成",
    path: "/jmreport/list",
    tags: ["报表", "模板", "数据集"],
  },
  jimuBi: {
    title: "仪表盘设计器",
    subtitle: "进入 Web 仪表盘设计器维护图表、组件和数据源",
    path: "/jmreport/list?jimuType=drag",
    tags: ["仪表盘", "图表", "设计"],
  },
  goView: {
    title: "大屏设计器",
    subtitle: "进入 Web 大屏设计器维护可视化大屏页面",
    path: "/go-view",
    tags: ["大屏", "可视化", "发布"],
  },
};

export function buildReportUrl(config: ReportEntryConfig) {
  const { state } = useAuth();
  const separator = config.path.includes("?") ? "&" : "?";
  const token = encodeURIComponent(state.refreshToken || state.accessToken || "");
  return `${WEB_BASE_URL}${config.path}${separator}token=${token}`;
}
