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

export const proStatusEnum = pgEnum("pro_status", ["professional", "non_professional"]);
export const approvalStatusEnum = pgEnum("approval_status", ["pending", "approved", "rejected"]);

export const profilesTable = pgTable("profiles", {
  id: serial("id").primaryKey(),
  profileId: text("profile_id").notNull().unique(),
  userId: integer("user_id"),
  name: text("name").notNull(),
  city: text("city").notNull(),
  photoUrl: text("photo_url"),
  bio: text("bio"),
  proStatus: proStatusEnum("pro_status"),
  price1h: integer("price_1h"),
  price2h: integer("price_2h"),
  priceFullDay: integer("price_full_day"),
  priceNight: integer("price_night"),
  services: text("services"),
  contactPlatform: text("contact_platform").default("whatsapp"),
  whatsappNumber: text("whatsapp_number"),
  approvalStatus: approvalStatusEnum("approval_status").notNull().default("pending"),
  isFeatured: boolean("is_featured").notNull().default(false),
  isActive: boolean("is_active").notNull().default(true),
  tags: text("tags").array().notNull().default([]),
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date()),
});

export const insertProfileSchema = createInsertSchema(profilesTable).omit({ id: true, createdAt: true, updatedAt: true });
export type InsertProfile = z.infer<typeof insertProfileSchema>;
export type Profile = typeof profilesTable.$inferSelect;
