// Woodbury Resident — Requests (list + detail + new). Registers window.RRequests. (function () { const NS = window.WoodburyPropertiesDesignSystem_7290ca; const { Card, CardHeader, Button, Badge, IconTile, Eyebrow, Modal, Select, Textarea, Input } = NS; function Tracker({ stage }) { const S = window.WBR.stages; return (
{S.map((s, i) => { const done = i < stage, active = i === stage; return (
{s}
{i < S.length - 1 &&
} ); })}
); } function RRequests({ focusId, onClear }) { const R = window.WBR; const loadingList = window.WBRuseLoad(); const [extra, setExtra] = React.useState([]); const [form, setForm] = React.useState({ title: "", cat: "Plumbing", priority: "Medium", desc: "" }); const myRequests = [...extra, ...R.requests]; const submitRequest = () => { const id = "MR-" + Math.floor(2100 + Math.random() * 800); const iconMap = { "Plumbing": "droplet", "HVAC / Cooling": "wind", "Electrical": "zap", "Appliances": "wifi", "Structural": "home", "General": "wrench" }; const rec = { id, title: form.title || "New request", cat: form.cat, icon: iconMap[form.cat] || "wrench", stage: 0, priority: form.priority, tone: form.priority === "Urgent" ? "danger" : form.priority === "Medium" ? "accent" : "success", desc: form.desc || "", vendor: "Awaiting assignment", reported: "Just now", log: [{ icon: "wrench", tone: "brand", title: "Request submitted", body: "You reported this issue.", time: "Just now" }] }; setExtra((l) => [rec, ...l]); // Bridge to the operator portal (same-origin localStorage channel). try { const key = "wb_portal_requests"; const q = JSON.parse(localStorage.getItem(key) || "[]"); q.unshift({ id, title: rec.title, cat: form.cat, priority: form.priority, unit: R.resident.unit, property: R.resident.property, resident: R.resident.name, reported: "Just now" }); localStorage.setItem(key, JSON.stringify(q)); } catch (e) {} // Write-through to the dev backend (resident -> operator bridge via dev.api). if (window.WBRsubmitRequest) window.WBRsubmitRequest({ title: rec.title, cat: form.cat, priority: form.priority, desc: form.desc, icon: rec.icon }); setForm({ title: "", cat: "Plumbing", priority: "Medium", desc: "" }); setNw(false); window.WBRToast("Request submitted — the office has been notified"); }; const [sel, setSel] = React.useState(focusId || null); const [nw, setNw] = React.useState(false); React.useEffect(() => { if (focusId) { setSel(focusId); onClear && onClear(); } }, [focusId]); const current = myRequests.find((r) => r.id === sel); if (current) { return (
setSel(null)}>Back} />
{current.priority} priority
Assigned to {current.vendor}
= 4 ? "success" : current.tone === "danger" ? "danger" : "warning"} dot={current.stage >= 4}>{R.stages[current.stage]}
{current.log.map((e, i) => { const tones = { danger: ["var(--danger-bg)", "var(--danger)"], brand: ["var(--walnut-100)", "var(--walnut-700)"], accent: ["rgba(194,125,72,0.14)", "var(--terracotta-600)"], success: ["var(--success-bg)", "var(--success)"] }[e.tone] || ["var(--cream-100)", "var(--gray-500)"]; return (
{i < current.log.length - 1 &&
}
{e.title}{e.time}

{e.body}

); })}
Details

{current.desc}

Need to add something?
{current.stage < 4 && }
); } return (
setNw(true)}>New Request} /> {myRequests.length}} /> {loadingList ? : myRequests.length === 0 ? ( setNw(true)}>New Request} /> ) : myRequests.map((r, i) => (
setSel(r.id)} style={{ display: "flex", gap: 14, alignItems: "center", padding: "18px 24px", borderTop: i ? "1px solid var(--border)" : "none", cursor: "pointer" }}> = 4 ? "success" : r.tone} size={44} />
{r.title}
{r.id} · {r.cat} · reported {r.reported}
= 4 ? "success" : r.tone === "danger" ? "danger" : "warning"} dot={r.stage >= 4}>{R.stages[r.stage]}
))}
setNw(false)} icon="wrench" title="New Maintenance Request" subtitle="Tell us what needs fixing in your unit." footer={}>
setForm((f) => ({ ...f, title: e.target.value }))} />
setForm((f) => ({ ...f, priority: e.target.value }))} options={["Low", "Medium", "Urgent"]} containerStyle={{ flex: 1 }} />