From ad5b797ce6557af0a4a8d23176b95c199cd1b76a Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 3 Nov 2025 14:58:04 -0500 Subject: [PATCH] Add ability to create new lines/sublines from inside product import --- .../CreateProductCategoryDialog.tsx | 332 ++++++++++++++++++ .../MatchColumnsStep/MatchColumnsStep.tsx | 64 +++- .../components/ValidationContainer.tsx | 84 +++++ inventory/src/services/apiv2.ts | 100 ++++++ inventory/tsconfig.tsbuildinfo | 2 +- 5 files changed, 579 insertions(+), 3 deletions(-) create mode 100644 inventory/src/components/product-import/CreateProductCategoryDialog.tsx diff --git a/inventory/src/components/product-import/CreateProductCategoryDialog.tsx b/inventory/src/components/product-import/CreateProductCategoryDialog.tsx new file mode 100644 index 0000000..c731c7f --- /dev/null +++ b/inventory/src/components/product-import/CreateProductCategoryDialog.tsx @@ -0,0 +1,332 @@ +import { useCallback, useEffect, useMemo, useState } from "react"; +import { Loader2 } from "lucide-react"; +import { toast } from "sonner"; + +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import config from "@/config"; +import { createProductCategory, type CreateProductCategoryResponse } from "@/services/apiv2"; + +type Option = { + label: string; + value: string; +}; + +export type CreatedCategoryInfo = { + id?: string; + name: string; + parentId: string; + type: "line" | "subline"; + response: CreateProductCategoryResponse; +}; + +interface CreateProductCategoryDialogProps { + trigger: React.ReactNode; + companies: Option[]; + defaultCompanyId?: string | null; + defaultLineId?: string | null; + environment?: "dev" | "prod"; + onCreated?: (info: CreatedCategoryInfo) => void | Promise; +} + +const normalizeOptions = (items: Array