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

export interface ListProductCategoryAssignmentsInput {
  categoryId: string;
}

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

  return ok({ assignments });
}
