elorasmus/public/js/views/triage.js
agent 0951f34a9d Add mobile-first web UI
Compare (duel with row-by-row comparison and thumb-reach pick bar), Ranking,
Triage (keep/drop pass, problem schools first), school detail with sources and
notes, Settings. Picks go to a localStorage outbox first and sync in the
background, so nothing is lost on a flaky connection. Light/dark themes,
installable to the home screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gXkMmmRRKLSnY6vQN3
2026-11-12 20:55:35 +00:00

85 lines
4.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Quick first pass: one school at a time, Keep or Drop. Schools with hard problems (language you
// don't speak, unrelated subject, unsafe country) come first, with the reasons shown.
import { html, bar } from '../ui.js';
import { shortName, place, languageFit, subjectFit, netCost, moneyRange, monthlyGrant, money } from '../metrics.js';
/** Reasons a school is probably not worth comparing. Empty = nothing obviously wrong. */
export function concerns(s, app) {
const out = [];
const lang = languageFit(s, app.settings.languages);
if (lang.status === 'fail') out.push(`Language: ${lang.text.replace('✗ ', '')}`);
const subj = subjectFit(s);
if (subj.rank <= 1) out.push(`Subject area: ${subj.text}`);
const c = app.data.countries?.[s.country];
if (c && c.stabilityScore <= 3) out.push(`Country stability ${c.stabilityScore}/10 (MFA: ${c.mfaAdvisory?.level})`);
const r = s.research;
if (r && r.safety.score <= 3) out.push(`City safety ${r.safety.score}/10`);
if (r && r.aiRobotics.access.score <= 2) out.push(`Few relevant courses for you (access ${r.aiRobotics.access.score}/10)`);
return out;
}
export function render(root, app) {
const all = app.data.schools.map((s) => ({ s, st: app.state.stats.get(s.code) }));
const queue = all
.filter(({ st }) => !st.reviewed && !st.dropped)
.map((x) => ({ ...x, why: concerns(x.s, app) }))
.sort((x, y) => y.why.length - x.why.length);
const done = all.length - queue.length;
if (!queue.length) {
root.innerHTML = String(html`
<section class="empty">
<h2>Triage done</h2>
<p>You've been through all ${all.length} schools. Now the comparisons do the rest.</p>
<a class="btn" href="#/">Start comparing</a>
</section>`);
return;
}
const { s, why } = queue[0];
const r = s.research;
const n = netCost(s, app.settings, app.data);
const g = monthlyGrant(s, app.settings, app.data);
root.innerHTML = String(html`
<section class="triage">
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="${all.length}" aria-valuenow="${done}">
<span>${done} / ${all.length} reviewed</span><i class="w${Math.round((done / all.length) * 10)}"></i>
</div>
<p class="muted small">Optional first pass. Drop the obvious no-gos so your picks go to real candidates. Problem schools come first.</p>
<article class="tcard">
<header>
<span class="flag" aria-hidden="true">${s.flag}</span>
<div><h2>${shortName(s)}</h2><p class="muted">${place(s)}</p></div>
</header>
${why.length ? html`<ul class="concerns">${why.map((w) => html`<li>${w}</li>`)}</ul>` : ''}
${r ? html`
<p>${r.summary}</p>
<dl class="tgrid">
<dt>AI research</dt><dd>${bar(r.aiRobotics.academic.score)}</dd>
<dt>Course access</dt><dd>${bar(r.aiRobotics.access.score)}</dd>
<dt>Social / calm</dt><dd>${r.social.score} / ${r.solitude.score}</dd>
<dt>Climb / hike / ocean</dt><dd>${r.nature.climbing.score} / ${r.nature.hiking.score} / ${r.nature.ocean.score}</dd>
<dt>CTU money</dt><dd>${money(g.eur, app.settings, app.data)}/mo</dd>
<dt>Out of pocket</dt><dd>${n ? moneyRange([n.lo, n.hi], app.settings, app.data, { compact: true }) : '–'}</dd>
</dl>
${r.watchouts.length ? html`<ul class="wo-list">${r.watchouts.slice(0, 3).map((w) => html`<li>${w}</li>`)}</ul>` : ''}`
: html`<p class="notice">Research pending: judge from the catalog for now, or keep it and decide later.</p>`}
<button type="button" class="link" data-action="open" data-slug="${s.slug}">All details</button>
</article>
</section>
<div class="actionbar" role="group" aria-label="Triage">
<div class="actionbar-main">
<button type="button" class="pick pick-drop" data-action="drop">Drop</button>
<button type="button" class="pick pick-keep" data-action="keep">Keep</button>
</div>
</div>`);
root.onclick = (e) => {
const t = e.target.closest('[data-action]');
if (!t) return;
if (t.dataset.action === 'drop') app.drop(s.code);
if (t.dataset.action === 'keep') app.review(s.code);
if (t.dataset.action === 'open') app.navigate(`#/school/${t.dataset.slug}`);
};
}