import { prisma } from "@/lib/db";
import type { SiteSettings } from "@prisma/client";

export async function getSiteSettings(): Promise<SiteSettings | null> {
  return prisma.siteSettings.findUnique({ where: { id: "main" } });
}

export async function upsertSiteSettings(data: Partial<Omit<SiteSettings, "id" | "updatedAt">>): Promise<SiteSettings> {
  return prisma.siteSettings.upsert({
    where: { id: "main" },
    create: { id: "main", siteTitle: "Ali Taghavi", ...data },
    update: data,
  });
}
