Public: anyone can read this; the crew can change it.

The sample deals tell a realtor which message to approve first when the app opens for a demo #237

Parked opened this
Closed without merging

mason/deal-clock:mason/235-the-sample-deals-tell-a-realtor-which-me → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
5 files changed +31 −10
README.md +3 −2
@@ -46,8 +46,9 @@ looks like today.
4646 who made it. A "Date changed" notice is drafted for each party the date
4747 concerns. On 9 Orchard Row the appraisal has already been moved; open it to
4848 see where from and to, and why.
49 6. **Review and approve today's reminders.** Tap **Review** in the header. Each
50 unsent reminder shows the words it would send, already filled in, for a
49 6. **Review and approve today's reminders.** Tap **Review** in the header. The
50 reminder whose date falls soonest (overdue first) comes first, marked
51 **Start here**. Each unsent reminder shows the words it would send, already filled in, for a
5152 party such as the buyer Samuel Reyes. Edit them if you like, then **Send**,
5253 **Don't send** (it asks why) or **Tomorrow**. Send records your approval and
5354 offers **Open in Mail** or **Open in Messages**, which open your own app with
src/pages/review.ts +1 −1
@@ -102,7 +102,7 @@ function form(
102102 const invalid = (field: ReviewField): string => (error?.field === field ? ' aria-invalid="true"' : "");
103103 const skip = s.total - s.done > 1 ? reviewHref(s.q, s.at + 1, s.done) : "";
104104 return `<section class="card narrow">
105 <p class="eyebrow">${s.position} of ${s.total}</p>
105 <p class="eyebrow">${s.position} of ${s.total}${s.position === 1 && s.total > 1 ? ' <span class="badge" data-u="soon">Start here</span>' : ""}</p>
106106 <h1>Review today's reminders</h1>
107107 <p><a href="/deals/${draft.deal_id}">${escape(draft.address)}</a></p>
108108 <p><b>${escape(draft.label)}</b> <span class="muted">· ${escape(spoken(draft.due))} · ${escape(momentLabel(draft.moment, draft.lead_days))}${draft.held === null ? "" : ` · ${escape(heldFrom(draft.held))}`}</span></p>
src/reminders.ts +12
@@ -517,3 +517,15 @@ export const waitingCount = (deals: readonly DealView[], day: string, agent: Age
517517 (n, deal) => n + waitingIn(`${day}|${JSON.stringify(agent)}|${print(deal)}`, () => todaysDrafts([deal], day, agent).filter(unsent).length),
518518 0,
519519 );
520
521 /**
522 * The review page's order: the date that falls soonest first, overdue ahead of
523 * everything. A check-in or anniversary note hangs on a closing long past, so
524 * it ranks by the day it is sent, not the closing's date. Stable: ties keep
525 * the clock's order.
526 */
527 export const mostUrgentFirst = (queue: readonly Draft[]): Draft[] => {
528 const key = (d: Draft): string => (d.moment === "checkin" || d.moment === "anniversary" ? d.on : d.due);
529 const keys = new Map(queue.map((d) => [d, key(d)] as const));
530 return [...queue].sort((a, b) => (keys.get(a)! < keys.get(b)! ? -1 : keys.get(a)! > keys.get(b)! ? 1 : 0));
531 };
src/review.test.ts +13 −5
@@ -37,15 +37,13 @@ const post = (path: string, fields: Record<string, string>, headers: Record<stri
3737 };
3838 const keys = (s: ReturnType<typeof shown>) => ({ deadline: s.deadline, party: s.party, moment: s.moment, at: s.at, done: s.done, q: "" });
3939
40 test("the clock offers Review all, and the page's first draft is the clock's first row", async () => {
40 test("the clock offers Review all, and the page counts the clock's rows, starting at the most urgent", async () => {
4141 expect(await get("/")).toContain('href="/reminders/today">Review all</a>');
4242 const rows = await clockRows();
4343 const page = await get("/reminders/today");
4444 const first = shown(page);
45 const [deadline, name] = rows[0]!.split(":") as [string, string];
46 // A home anniversary note hangs on the deal's page, not on a date's sheet: the clock names no date for it.
47 if (deadline === "") expect(page).toContain(`<b>${name}</b>`);
48 else expect(first.deadline).toBe(deadline);
45 // The review page starts at the soonest date, which may not be the clock's first row, but it is one of them.
46 expect(rows.map((r) => r.split(":")[0])).toContain(first.deadline);
4947 expect(first.counter).toBe(`1/${rows.length}`);
5048 });
5149
@@ -212,3 +210,13 @@ test("Save contact takes an email and a phone together, and a bad phone keeps bo
212210 expect(after).toContain("[email protected]");
213211 expect(after).toContain("(555) 010-0199");
214212 });
213
214 test("the review page puts the soonest date first and marks it Start here, and only that one", async () => {
215 const page = await get("/reminders/today");
216 expect(page).toContain('<span class="badge" data-u="soon">Start here</span>');
217 expect(page.match(/Start here/g)?.length).toBe(1);
218 // The sample's overdue date ranks ahead of the rest: the first draft is the overdue follow-up.
219 expect(page).toContain("overdue");
220 const next = await get("/reminders/today?at=1");
221 expect(next).not.toContain("Start here");
222 });
src/routes.ts +2 −2
@@ -110,7 +110,7 @@ import { filePage } from "./pages/file.ts";
110110 import { timelinePage } from "./pages/timeline.ts";
111111 import { welcomePage } from "./pages/welcome.ts";
112112 import { failedCheck } from "./health.ts";
113 import { dueOn, remindsLine, todaysDrafts, unsent, waitingCount, type Agent, type Draft } from "./reminders.ts";
113 import { dueOn, mostUrgentFirst, remindsLine, todaysDrafts, unsent, waitingCount, type Agent, type Draft } from "./reminders.ts";
114114 import { token, tokensCss } from "./tokens.ts";
115115 import type { Who } from "./who.ts";
116116
@@ -602,7 +602,7 @@ const unconfirmed = (c: Context, path: string): Response =>
602602 function reviewQueue(c: Context, q: string): Result<Draft[]> {
603603 const deals = listDeals(c.db, c.who);
604604 if (!deals.ok) return deals;
605 return { ok: true, value: todaysDrafts(find(deals.value, q), dayOf(agentFor(c)), agentFor(c)).filter(unsent) };
605 return { ok: true, value: mostUrgentFirst(todaysDrafts(find(deals.value, q), dayOf(agentFor(c)), agentFor(c)).filter(unsent)) };
606606 }
607607
608608 /** Whose deals these are, read once per request however many times a page and its header ask. */

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs