1 import { DateTime } from "luxon";
2 import { MessageWithNames } from "../repository/mail";
4 export function renderMailroom(mail: MessageWithNames[], msg?: MessageWithNames): string {
6 <div hx-trigger="every 600s" hx-get="/poll/mailroom" hx-swap-oob="true" id="main">
7 <h2 data-augmented-ui="tl-clip bl-clip none">Mail</h2>
17 <tr class="${msg.read_at === 0 ? 'unread': 'read'}" >
18 <td>${msg.username}</td>
20 <a href="#" hx-trigger="click" hx-get="/messages/${msg.id}" hx-target="#individual-message">
24 <td>${DateTime.fromMillis(msg.sent_at)}</td>
25 <td>${msg.read_at === 0 ? 'Unread' : DateTime.fromMillis(msg.read_at)}</td>
30 <div id="individual-message">${msg ? renderMessage(msg) : ''}</div>
35 export function renderMessage(msg: MessageWithNames): string {
40 <td>${msg.username}</td>
44 <td>${DateTime.fromMillis(msg.sent_at)}</td>
48 <td>${msg.subject}</td>
51 <th valign="top">Message</th>
52 <td>${msg.message}</td>