import { pgTable, varchar, integer, timestamp, boolean } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod";
import { z } from "zod/v4";

export const appSettingsTable = pgTable("app_settings", {
  id: integer("id").primaryKey().default(1),
  siteNameAr: varchar("site_name_ar", { length: 200 }).notNull().default("نظام Tx"),
  siteNameEn: varchar("site_name_en", { length: 200 }).notNull().default("Tx OS"),
  registrationOpen: boolean("registration_open").notNull().default(true),
  footerTextAr: varchar("footer_text_ar", { length: 300 }).notNull().default("جميع الحقوق محفوظة."),
  footerTextEn: varchar("footer_text_en", { length: 300 }).notNull().default("All rights reserved."),
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date()),
});

export const updateAppSettingsSchema = createInsertSchema(appSettingsTable)
  .omit({ id: true, updatedAt: true })
  .partial();
export type AppSettings = typeof appSettingsTable.$inferSelect;
export type UpdateAppSettings = z.infer<typeof updateAppSettingsSchema>;
