// Woodbury Operator — Maintenance board. Registers window.MaintenanceScreen. (function () { const NS = window.WoodburyPropertiesDesignSystem_7290ca; const { Card, CardHeader, Button, Badge, StatCard, IconTile, Modal, Input, Select, Textarea } = NS; const TICKETS = [ { unit: "House 1 — AC Leak", asset: "Lashibi Townhouses", meta: "Reported 2 hours ago · HVAC team notified", icon: "wind", tone: "danger", badge: "Urgent", badgeTone: "danger", vendor: "AirCool HVAC Services" }, { unit: "Villa 7 — Roof Tile Repair", asset: "Cantonments City", meta: "Scheduled for tomorrow · Roofer assigned", icon: "home", tone: "accent", badge: "Medium", badgeTone: "warning", vendor: "Kojo Roofing & Works" }, { unit: "Flat 2B — Geyser Fault", asset: "Mirage", meta: "Parts ordered · ETA 3 days", icon: "flame", tone: "sunken", badge: "In Progress", badgeTone: "success", vendor: "Mensah Plumbing Co." }, { unit: "Villa 12 — Gate Remote Sync", asset: "Lashibi Townhouses", meta: "Low priority · Backlog", icon: "door-closed", tone: "sunken", badge: "Backlog", badgeTone: "neutral", vendor: "Unassigned" }, { unit: "Unit 8 — Water Pressure", asset: "Onehive Tse Addo", meta: "Resident follow-up requested", icon: "droplet", tone: "sunken", badge: "Medium", badgeTone: "warning", vendor: "Mensah Plumbing Co." }, ]; function MaintenanceScreen() { const [modal, setModal] = React.useState(null); // 'new' | {type:'view'|'assign', ticket} const [ntProp, setNtProp] = React.useState(window.WB_SITES[0]); const [ntUnit, setNtUnit] = React.useState(""); const close = () => setModal(null); const vendorNames = window.WB_DATA.vendors.map((v) => v.name); // Requests submitted from the resident portal (same-origin localStorage bridge). const portal = window.WBreadPortalRequests().map((p) => ({ unit: (p.unit || "Unit") + " — " + p.title, asset: p.property || "", meta: "From resident portal · " + (p.resident || "Resident") + " · " + (p.reported || "just now"), icon: { "Plumbing": "droplet", "HVAC / Cooling": "wind", "Electrical": "zap", "Appliances": "wifi", "Structural": "home", "General": "wrench" }[p.cat] || "wrench", tone: p.priority === "Urgent" ? "danger" : p.priority === "Medium" ? "accent" : "sunken", badge: p.priority === "Urgent" ? "Urgent" : p.priority === "Medium" ? "Medium" : "Low", badgeTone: p.priority === "Urgent" ? "danger" : p.priority === "Medium" ? "warning" : "neutral", vendor: "Unassigned", fromPortal: true, })); const QUEUE = [...portal, ...TICKETS]; const openNew = () => { const p = window.WB_SITES[0]; setNtProp(p); setNtUnit(window.WBunitsFor(p, false)[0] || ""); setModal({ type: "new" }); }; React.useEffect(() => { const f = window.WBFocus; if (f && f.kind === "ticket") { const t = TICKETS.find((x) => x.unit === f.key); if (t) { window.WB_ACTIVE_TICKET = { unit: t.unit, asset: t.asset, icon: t.icon, badge: t.badge, badgeTone: t.badgeTone, vendor: t.vendor, vendorTrade: (window.WB_DATA.vendors.find((v) => v.name === t.vendor) || {}).trade || "Contractor", vendorPhone: (window.WB_DATA.vendors.find((v) => v.name === t.vendor) || {}).phone || "+233 …", tenant: "Kofi Mensah", tenantUnit: t.unit.split(" — ")[0], reported: "18 Aug 2026 · 09:12", reportDate: "20 Aug 2026", priority: t.badge, stageIndex: t.badge === "In Progress" ? 3 : t.vendor === "Unassigned" ? 0 : 1, description: t.meta }; window.WBNavigate && window.WBNavigate("TicketDetail"); } window.WBFocus = null; } else if (f && f.kind === "new-ticket") { setModal({ type: "new" }); window.WBFocus = null; } }, []); return (