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

export interface GetPartnerInput {
  id: string;
}

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

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