import { defineType, defineField } from "sanity";

export default defineType({
  name: "siteSettings",
  title: "Website-Einstellungen",
  type: "document",
  // Singleton — nur ein Dokument
  __experimental_actions: ["update", "publish"],
  fields: [
    defineField({
      name: "contact",
      title: "Kontakt",
      type: "object",
      fields: [
        { name: "email", title: "E-Mail", type: "string" },
        { name: "phone", title: "Telefon (optional)", type: "string" },
        { name: "address", title: "Adresse", type: "string", initialValue: "Keilerstraße 23, 13503 Berlin" },
      ],
    }),
    defineField({
      name: "bank",
      title: "Bankverbindung",
      type: "object",
      fields: [
        { name: "iban", title: "IBAN", type: "string" },
        { name: "bic", title: "BIC", type: "string" },
        { name: "bank", title: "Bankname", type: "string" },
        { name: "accountHolder", title: "Kontoinhaber", type: "string", initialValue: "Kitafreunde Regenbogen e.V." },
      ],
    }),
    defineField({
      name: "social",
      title: "Social Media",
      type: "object",
      fields: [
        { name: "instagram", title: "Instagram-URL", type: "url" },
        { name: "facebook", title: "Facebook-URL", type: "url" },
      ],
    }),
    defineField({
      name: "memberFees",
      title: "Mitgliedsbeiträge",
      type: "object",
      fields: [
        { name: "active", title: "Aktives Mitglied (Mindestbeitrag €/Jahr)", type: "number", initialValue: 12 },
        { name: "supporting", title: "Fördermitglied (Mindestbeitrag €/Jahr)", type: "number", initialValue: 6 },
        { name: "admissionFee", title: "Aufnahmegebühr €", type: "number", initialValue: 5 },
      ],
    }),
    defineField({
      name: "stats",
      title: "Zahlen für die Startseite",
      type: "object",
      fields: [
        { name: "members", title: "Mitgliederzahl", type: "number" },
        { name: "fundsPerYear", title: "Fördersumme €/Jahr", type: "number" },
        { name: "projectsTotal", title: "Projekte gesamt", type: "number" },
      ],
    }),
  ],
  preview: { select: { title: "contact.email" } },
});
