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

export interface GetSupplierProfileInput {
  companyId: string;
  supplierId: string;
}

export async function run(db: ReadonlyDB<DB>, input: GetSupplierProfileInput) {
  const supplierProfile = await db
    .selectFrom("SupplierProfile")
    .selectAll()
    .where("companyId", "=", input.companyId)
    .where("supplierId", "=", input.supplierId)
    .executeTakeFirst();

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