import {defineField, defineType} from "sanity";

export const quoteSettings = defineType({
  name: "quoteSettings",
  title: "Reglage devis",
  type: "document",
  fields: [
    defineField({name: "companyName", title: "Nom societe", type: "string", validation: (r) => r.required()}),
    defineField({name: "companyAddress", title: "Adresse societe", type: "text"}),
    defineField({name: "companyEmail", title: "Email societe", type: "string"}),
    defineField({name: "companyPhone", title: "Telephone societe", type: "string"}),
    defineField({name: "vatNumber", title: "Numero TVA", type: "string"}),
    defineField({name: "logoUrl", title: "Logo URL", type: "url", description: "Image publique affichee dans l'entete du devis."}),
    defineField({name: "quoteTitle", title: "Titre PDF", type: "string", initialValue: "Devis"}),
    defineField({
      name: "quoteNumberPrefixTemplate",
      title: "Template prefixe numero devis",
      type: "string",
      initialValue: "{YYYY}/{MM}",
      description:
        "Prefixe applique avant le numero du devis. Variables: {YYYY}, {YY}, {MM}, {MONTH}. Exemple: {YYYY}/{MM} => 2026/03/ABC123",
    }),
    defineField({
      name: "introText",
      title: "Texte introduction",
      type: "text",
      description: "Texte court affiche sous le bloc client.",
    }),
    defineField({name: "footerNote", title: "Note pied de page", type: "text"}),
    defineField({name: "paymentTerms", title: "Conditions / delais", type: "text"}),
    defineField({name: "accentHexColor", title: "Couleur accent", type: "string", initialValue: "#f55050"}),
  ],
});
