Spaces:
Sleeping
Sleeping
Deploy ProFlo admin dashboard (Docker Space)
Browse filesFiles changed (2)
251 unmodified lines252253254255256257204 unmodified lines46246346446546646746814 unmodified lines48348448548648748818 unmodified lines507508509510511512268 unmodified lines78178278378478578678778821 unmodified lines810811812813814815816817818819820821822823347 unmodified lines1171117211731174117511761177220 unmodified lines1398139914001401140214031404140514061407115 unmodified lines15231524152515261527152875 unmodified lines160416051606160716081609251 unmodified linesconst imageInputRef = useRef<HTMLInputElement>(null);const inventoryImageInputRef = useRef<HTMLInputElement>(null);const [imageTargetId, setImageTargetId] = useState<string | null>(null);const [formErrors, setFormErrors] = useState<FormErrors>({});const [barcodeConflict, setBarcodeConflict] = useState<AdminProduct | null>(null);const nameInputRef = useRef<HTMLInputElement>(null);204 unmodified linesif (!trimmedBarcode) errors.barcode = "Barcode is required.";else if (trimmedBarcode.length < 4) errors.barcode = "Barcode must be at least 4 characters.";else if (products.some((p) => p.barcode === trimmedBarcode)) errors.barcode = "This barcode is already in the catalogue.";if (!trimmedName) errors.name = "Product name is required.";if (!trimmedCategory) errors.category = "Category is required.";14 unmodified lines}function resetProductForm() {setBarcode("");setName("");setCategory("General");18 unmodified linessetCameraOn(false);}function handleBarcodeInput(value: string) {setBarcode(value);setFormErrors((prev) => ({ ...prev, barcode: undefined }));268 unmodified linessetLoading(true);setMessage("");const resp = await fetch(`${apiBase}/v1/admin/products`, {method: "POST",headers: adminFetchHeaders(true),body: JSON.stringify({barcode: barcode.trim(),21 unmodified linesreturn;}if (resp.ok) {setMessage("Product added to catalogue.");resetProductForm();await loadProducts();await loadMetrics();await loadMovements();} else {const data = await resp.json().catch(() => ({}));const errMsg = (data as { message?: string }).message ?? "Unable to add product";setMessage(errMsg);if (resp.status === 409 || errMsg.toLowerCase().includes("barcode")) {setFormErrors((prev) => ({ ...prev, barcode: errMsg }));347 unmodified lines<div className="adminWorkspace"><div className="adminWorkspace__left"><section className="panel adminPanel adminPanel--add"><h2 className="adminPanel__title">Add product</h2><p className="adminPanel__lede">Landed cost vs list shelf price. Scan barcodes with the camera or a USB scanner.</p>220 unmodified linesdisabled={loading || !!barcodeConflict}onClick={() => void addProduct()}>{loading ? "Saving…" : "Save product"}</button><button type="button" className="adminBtn adminBtn--ghost" disabled={loading} onClick={resetProductForm}>Clear form</button><p className="formNote">Each size/color is a separate SKU with its own hang-tag barcode. SKU auto-generates as STYLE-COLOR-SIZE.</p></div>115 unmodified lines<button type="button" className="adminBtn adminBtn--small" onClick={() => openStockModal(p)}>Set stock</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"75 unmodified lines<button type="button" className="adminBtn adminBtn--small" onClick={() => openStockModal(p)}>Set stock</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"251 unmodified lines252253254255256257258204 unmodified lines46346446546646746846914 unmodified lines48448548648748848949018 unmodified lines509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551268 unmodified lines82082182282382482582682782882983083121 unmodified lines853854855856857858859860861862863864865866347 unmodified lines1214121512161217121812191220220 unmodified lines1441144214431444144514461447144814491450115 unmodified lines156615671568156915701571157215731574157515761577157875 unmodified lines1654165516561657165816591660166116621663166416651666251 unmodified linesconst imageInputRef = useRef<HTMLInputElement>(null);const inventoryImageInputRef = useRef<HTMLInputElement>(null);const [imageTargetId, setImageTargetId] = useState<string | null>(null);const [editingProductId, setEditingProductId] = useState<string | null>(null);const [formErrors, setFormErrors] = useState<FormErrors>({});const [barcodeConflict, setBarcodeConflict] = useState<AdminProduct | null>(null);const nameInputRef = useRef<HTMLInputElement>(null);204 unmodified linesif (!trimmedBarcode) errors.barcode = "Barcode is required.";else if (trimmedBarcode.length < 4) errors.barcode = "Barcode must be at least 4 characters.";else if (products.some((p) => p.barcode === trimmedBarcode && p.id !== editingProductId)) errors.barcode = "This barcode is already in the catalogue.";if (!trimmedName) errors.name = "Product name is required.";if (!trimmedCategory) errors.category = "Category is required.";14 unmodified lines}function resetProductForm() {setEditingProductId(null);setBarcode("");setName("");setCategory("General");18 unmodified linessetCameraOn(false);}function startEditingProduct(p: AdminProduct) {setEditingProductId(p.id);setBarcode(p.barcode);setName(p.name);setCategory(p.category);setStyleCode(p.styleCode);setSize(p.size);setColor(p.color);setBrand(p.brand);setSeason(p.season);setGender(p.gender);setCostPrice(String(p.costPrice));setSellingPrice(String(p.unitPrice));setReorderLevel(String(p.reorderLevel));setTaxPercent(String(p.taxPercent));setInStock(String(p.inStock));setDemandScore(String(p.demandScore));setImageUrl(p.imageUrl || "");setFormErrors({});setBarcodeConflict(null);setCameraOn(false);const sell = p.unitPrice;const cost = p.costPrice;if (sell > 0 && cost > 0) {setMarginPct((((sell - cost) / sell) * 100).toFixed(1));setMarkupPct((((sell - cost) / cost) * 100).toFixed(1));} else {setMarginPct("");setMarkupPct("");}const addPanel = document.querySelector(".adminPanel--add");addPanel?.scrollIntoView({ behavior: "smooth" });window.setTimeout(() => nameInputRef.current?.focus(), 150);}function handleBarcodeInput(value: string) {setBarcode(value);setFormErrors((prev) => ({ ...prev, barcode: undefined }));268 unmodified linessetLoading(true);setMessage("");const url = editingProductId? `${apiBase}/v1/admin/products/${editingProductId}`: `${apiBase}/v1/admin/products`;const method = editingProductId ? "PATCH" : "POST";const resp = await fetch(url, {method,headers: adminFetchHeaders(true),body: JSON.stringify({barcode: barcode.trim(),21 unmodified linesreturn;}if (resp.ok) {setMessage(editingProductId ? "Product details updated." : "Product added to catalogue.");resetProductForm();await loadProducts();await loadMetrics();await loadMovements();} else {const data = await resp.json().catch(() => ({}));const errMsg = (data as { message?: string }).message ?? (editingProductId ? "Unable to update product" : "Unable to add product");setMessage(errMsg);if (resp.status === 409 || errMsg.toLowerCase().includes("barcode")) {setFormErrors((prev) => ({ ...prev, barcode: errMsg }));347 unmodified lines<div className="adminWorkspace"><div className="adminWorkspace__left"><section className="panel adminPanel adminPanel--add"><h2 className="adminPanel__title">{editingProductId ? "Edit product details" : "Add product"}</h2><p className="adminPanel__lede">Landed cost vs list shelf price. Scan barcodes with the camera or a USB scanner.</p>220 unmodified linesdisabled={loading || !!barcodeConflict}onClick={() => void addProduct()}>{loading ? "Saving…" : editingProductId ? "Update product" : "Save product"}</button><button type="button" className="adminBtn adminBtn--ghost" disabled={loading} onClick={resetProductForm}>{editingProductId ? "Cancel edit" : "Clear form"}</button><p className="formNote">Each size/color is a separate SKU with its own hang-tag barcode. SKU auto-generates as STYLE-COLOR-SIZE.</p></div>115 unmodified lines<button type="button" className="adminBtn adminBtn--small" onClick={() => openStockModal(p)}>Set stock</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"onClick={() => startEditingProduct(p)}>Edit Info</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"75 unmodified lines<button type="button" className="adminBtn adminBtn--small" onClick={() => openStockModal(p)}>Set stock</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"onClick={() => startEditingProduct(p)}>Edit Info</button><buttontype="button"className="adminBtn adminBtn--small adminBtn--ghost"
123456/// <reference types="next" />/// <reference types="next/image-types/global" />import "./.next/dev/types/routes.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.123456/// <reference types="next" />/// <reference types="next/image-types/global" />import "./.next/types/routes.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
apps/admin-web/app/admin/dashboard/page.tsx+65-8
apps/admin-web/next-env.d.ts+1-1