update: Major Overhaul to all subsystems
This commit is contained in:
@@ -1599,6 +1599,7 @@ export default function DeviceDetail() {
|
||||
const [liveStrikeCounters, setLiveStrikeCounters] = useState(null);
|
||||
const [requestingStrikeCounters, setRequestingStrikeCounters] = useState(false);
|
||||
const lastStrikeRequestAtRef = useRef(0);
|
||||
const [hwProduct, setHwProduct] = useState(null);
|
||||
|
||||
// --- Section edit modal open/close state ---
|
||||
const [editingLocation, setEditingLocation] = useState(false);
|
||||
@@ -1641,6 +1642,25 @@ export default function DeviceDetail() {
|
||||
setDeviceUsers([]);
|
||||
}).finally(() => setUsersLoading(false));
|
||||
|
||||
// Fetch manufacturing record + product catalog to resolve hw image
|
||||
if (d.device_id) {
|
||||
Promise.all([
|
||||
api.get(`/manufacturing/devices/${d.device_id}`).catch(() => null),
|
||||
api.get("/crm/products").catch(() => null),
|
||||
]).then(([mfgItem, productsRes]) => {
|
||||
const hwType = mfgItem?.hw_type || "";
|
||||
if (!hwType) return;
|
||||
const products = productsRes?.products || [];
|
||||
const norm = (s) => (s || "").toLowerCase().replace(/[^a-z0-9]/g, "");
|
||||
const normHw = norm(hwType);
|
||||
const match = products.find(
|
||||
(p) => norm(p.name) === normHw || norm(p.sku) === normHw ||
|
||||
norm(p.name).includes(normHw) || normHw.includes(norm(p.name))
|
||||
);
|
||||
if (match) setHwProduct(match);
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
api.get(`/equipment/notes?device_id=${id}`).then((data) => {
|
||||
const issues = (data.notes || []).filter(
|
||||
(n) => (n.category === "issue" || n.category === "action_item") && n.status !== "completed"
|
||||
@@ -1809,9 +1829,8 @@ export default function DeviceDetail() {
|
||||
: null;
|
||||
const randomPlaybacks = playbackPlaceholderForId(id || device.device_id || device.id);
|
||||
|
||||
const hwImageMap = { VesperPlus: "/devices/VesperPlus.png" };
|
||||
const hwVariant = "VesperPlus";
|
||||
const hwImage = hwImageMap[hwVariant] || hwImageMap.VesperPlus;
|
||||
const hwVariant = hwProduct?.name || "VesperPlus";
|
||||
const hwImage = hwProduct?.photo_url ? `/api${hwProduct.photo_url}` : "/devices/VesperPlus.png";
|
||||
|
||||
const locationCard = (
|
||||
<section className="device-section-card">
|
||||
|
||||
Reference in New Issue
Block a user