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

export interface ListProductCategoryChildrenInput {
  parentId: string;
}

export async function run(db: ReadonlyDB<DB>, input: ListProductCategoryChildrenInput) {
  const children = await db
    .selectFrom("ProductCategory")
    .selectAll()
    .where("parentId", "=", input.parentId)
    .execute();

  return ok({ children });
}
