import type { Metadata } from "next";
import { Toaster } from "sonner";
import type { Desa } from "@/lib/types";
import { serverGet } from "@/lib/api";
import { themeStyle } from "@/lib/theme";
import "./globals.css";

export const metadata: Metadata = {
  title: {
    default: "Core Mulyadadi — Sistem Informasi Desa",
    template: "%s | Core Mulyadadi",
  },
  description:
    "Core Mulyadadi — sistem informasi dan pelayanan administrasi Desa Mulyadadi: kependudukan, transparansi APBDes, dan informasi pembangunan desa.",
};

export default async function RootLayout({
  children,
}: Readonly<{ children: React.ReactNode }>) {
  const desa = await serverGet<Desa>("/desa/publik");

  return (
    <html lang="id" style={themeStyle(desa)}>
      <body>
        {children}
        <Toaster richColors position="top-right" />
      </body>
    </html>
  );
}
