// Woodbury Operator — Messages. Registers window.MessagesScreen. (function () { const NS = window.WoodburyPropertiesDesignSystem_7290ca; const { Card, Button, Avatar, Input, Modal, Select, Textarea } = NS; const THREADS = [ { name: "Efua Asante", avatar: "../../assets/images/av-efua.jpg", preview: "The unit is making a loud grinding noise…", time: "2h", unread: 2, site: "Lashibi Townhouses · House 5" }, { name: "Kofi Mensah", avatar: "../../assets/images/av-kofi.jpg", preview: "Thank you, I'll sign the renewal today.", time: "5h", unread: 0, site: "Lashibi Townhouses · House 1" }, { name: "Ama Osei", avatar: "../../assets/images/av-ama.jpg", preview: "Can we schedule the inspection for Friday?", time: "1d", unread: 0, site: "Cantonments City · Apt 5A" }, { name: "Yaw Boateng", avatar: "../../assets/images/av-yaw.jpg", preview: "Application documents attached.", time: "2d", unread: 0, site: "Mirage · Apartment B3" }, { name: "Nana Adjei", avatar: "../../assets/images/av-nana.jpg", preview: "Water pressure is back to normal now.", time: "3d", unread: 0, site: "Onehive Tse Addo · Unit 101" }, ]; const SEED = { "Efua Asante": [ { me: false, text: "Good morning, the AC in House 5 is making a loud grinding noise and isn't cooling.", time: "09:12" }, { me: false, text: "It started last night. Could someone come take a look today?", time: "09:12" }, { me: true, text: "Akwaaba Efua — sorry to hear that. I've notified the HVAC team and marked it urgent.", time: "09:31" }, { me: false, text: "Thank you so much, that's a relief!", time: "09:40" }, ], }; function MessagesScreen() { const [active, setActive] = React.useState(THREADS[0]); const [convos, setConvos] = React.useState(SEED); const [draft, setDraft] = React.useState(""); const [compose, setCompose] = React.useState(false); const scrollRef = React.useRef(null); const msgs = convos[active.name] || []; React.useEffect(() => { if (scrollRef.current) scrollRef.current.scrollTop = scrollRef.current.scrollHeight; }, [msgs.length, active]); const send = () => { const text = draft.trim(); if (!text) return; const t = new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); setConvos((c) => ({ ...c, [active.name]: [...(c[active.name] || []), { me: true, text, time: t }] })); setDraft(""); }; return (