import { ok, type ReadonlyDB } from "@tailor-platform/erp-kit/core";
import type { DB } from "../generated/kysely-tailordb";

export interface GetSiteInput {
  id: string;
}

export async function run(db: ReadonlyDB<DB>, input: GetSiteInput) {
  const site = await db
    .selectFrom("Site")
    .selectAll()
    .where("id", "=", input.id)
    .executeTakeFirst();

  return ok({ site: site ?? null });
}
