added location field
This commit is contained in:
@ -5,7 +5,7 @@ import { Upload, Plus, AlertCircle, CheckCircle2 } from "lucide-react";
|
||||
import * as xlsx from "xlsx";
|
||||
|
||||
export default function AddImportPage() {
|
||||
const [formData, setFormData] = useState({ name: "", qrCodeId: "", quantity: 0, price: 0.0, category: "", description: "" });
|
||||
const [formData, setFormData] = useState({ name: "", qrCodeId: "", quantity: 0, price: 0.0, category: "", location: "", description: "" });
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [status, setStatus] = useState({ type: "", message: "" });
|
||||
const [importStats, setImportStats] = useState(null);
|
||||
@ -37,7 +37,7 @@ export default function AddImportPage() {
|
||||
if (!res.ok) throw new Error(data.error || "Failed to create item");
|
||||
|
||||
setStatus({ type: "success", message: `Successfully added ${data.name}.` });
|
||||
setFormData({ name: "", qrCodeId: "", quantity: 0, price: 0.0, category: "", description: "" });
|
||||
setFormData({ name: "", qrCodeId: "", quantity: 0, price: 0.0, category: "", location: "", description: "" });
|
||||
} catch (err) {
|
||||
setStatus({ type: "error", message: err.message });
|
||||
} finally {
|
||||
@ -81,6 +81,7 @@ export default function AddImportPage() {
|
||||
quantity: parseInt(normalizedRow["quantity"] || normalizedRow["qty"]) || 0,
|
||||
price: parseFloat(normalizedRow["price"] || normalizedRow["cost"]) || 0.0,
|
||||
category: normalizedRow["category"] || "",
|
||||
location: normalizedRow["location"] || normalizedRow["bin"] || normalizedRow["aisle"] || "",
|
||||
description: normalizedRow["description"] || "",
|
||||
};
|
||||
|
||||
@ -147,9 +148,15 @@ export default function AddImportPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-group">
|
||||
<label>Category</label>
|
||||
<input type="text" name="category" className="input-field" value={formData.category} onChange={handleInputChange} />
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }}>
|
||||
<div className="form-group">
|
||||
<label>Category</label>
|
||||
<input type="text" name="category" className="input-field" value={formData.category} onChange={handleInputChange} />
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>Location</label>
|
||||
<input type="text" name="location" className="input-field" value={formData.location} onChange={handleInputChange} placeholder="e.g. Aisle 4" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" className="btn btn-primary mt-4" style={{ width: "100%", justifyContent: "center" }} disabled={loading}>
|
||||
@ -170,7 +177,7 @@ export default function AddImportPage() {
|
||||
<input type="file" accept=".xlsx, .xls, .csv" style={{ display: "none" }} onChange={handleFileUpload} disabled={loading} />
|
||||
</label>
|
||||
<div className="mt-4" style={{ fontSize: "0.85rem", color: "var(--text-muted)" }}>
|
||||
Make sure your file has headers like: <strong>Name, QR ID, Quantity, Price</strong>.
|
||||
Make sure your file has headers like: <strong>Name, QR ID, Quantity, Price, Location</strong>.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user