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

export interface ListCategoryAssignmentsByProductInput {
  productId: string;
}

export async function run(db: ReadonlyDB<DB>, input: ListCategoryAssignmentsByProductInput) {
  const assignments = await db
    .selectFrom("ProductCategoryAssignment")
    .selectAll()
    .where("productId", "=", input.productId)
    .execute();

  return ok({ assignments });
}
