import { prisma } from "@stamp/shared";

const stampData = [
  { name: "尹氏汤包" },
  { name: "中国移动 5G" },
  { name: "紫金农商银行" },
  { name: "孟令军炒货铺" },
  { name: "春山酒窖" },
  { name: "金陵绣男" },
  { name: "LBZ" },
  { name: "二条商店" },
  { name: "陶玉梅" },
  { name: "芳婆糕团" },
  { name: "书锦城创" },
  { name: "闲鱼循环商店" },
  { name: "闽南茶叶店" },
  { name: "魏鬼虾神" },
  { name: "农家小院" },
  { name: "李记清真馆" },
];

async function seed() {
  console.log("Seeding database...");

  // Clear existing stamps (cascades to collections + prize)
  await prisma.stamp.deleteMany();

  const stamps = await Promise.all(
    stampData.map((s, idx) => {
      const pos = String(idx + 1).padStart(2, "0");
      return prisma.stamp.create({
        data: {
          name: s.name,
          imageColor: `/uploads/stamps/stamp-${pos}-color.jpg`,
          imageGrey: `/uploads/stamps/stamp-${pos}-grey.jpg`,
          sortOrder: idx + 1,
          prize: {
            create: {
              name: `${s.name} · 纪念章`,
              description: `在「${s.name}」集到的专属纪念奖品`,
              stock: 100,
              enabled: true,
            },
          },
        },
      });
    }),
  );

  console.log(`Created ${stamps.length} stamps with prizes`);

  console.log("\nStamp IDs for testing:");
  stamps.forEach((s) => {
    console.log(`  ${s.sortOrder}. ${s.name}: /collect/${s.id}`);
  });

  console.log("\nSeed complete!");
}

seed()
  .catch(console.error)
  .finally(() => prisma.$disconnect());
