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

export interface GetListingInput {
  id: string;
}

export async function run(db: ReadonlyDB<DB>, input: GetListingInput) {
  const listing = await db
    .selectFrom("Listing")
    .selectAll()
    .where("id", "=", input.id)
    .executeTakeFirst();
  return ok({ listing: listing ?? null });
}
