feat(web): screens from docs/mock — focus flow, today, meds, doctor, profile
- /flow renders the dialog engine's current step as a mock screen (consent,
age, onboarding and scales with progress, mood 0–10, free text, dose
reminder, crisis with hotlines and breathing, safety plan), so every
engine scenario gets the design without duplicating its logic
- today / meds / doctor / profile / messages tabs; navy sidebar and
emergency rail on desktop, emergency block and tab bar on phones
- API: GET /me/{token}/today (today's doses, week marks, next visit, demo
clock time); demo ЕМИАС sign-in seeds the persona's synthetic profile and
prescription from the dashboard fixtures
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { api } from "../api/client";
|
||||
import type { TodayPlan } from "../api/types";
|
||||
import { useDialog } from "../dialog/DialogContext";
|
||||
import { useSession } from "../session/SessionContext";
|
||||
|
||||
/** The patient's plan for today; refreshed whenever the dialog moves (a dose answered, a check-in done). */
|
||||
export function useToday(): { plan: TodayPlan | null; failed: boolean } {
|
||||
const { session } = useSession();
|
||||
const { pending } = useDialog();
|
||||
const [plan, setPlan] = useState<TodayPlan | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!session) return;
|
||||
let alive = true;
|
||||
api
|
||||
.today(session.token)
|
||||
.then((p) => {
|
||||
if (!alive) return;
|
||||
setPlan(p);
|
||||
setFailed(false);
|
||||
})
|
||||
.catch(() => alive && setFailed(true));
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [session, pending]);
|
||||
|
||||
return { plan, failed };
|
||||
}
|
||||
|
||||
const MONTHS = ["января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"];
|
||||
const WEEKDAYS = ["воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"];
|
||||
|
||||
/** "12 марта, вторник" — from an ISO date, no timezone shift. */
|
||||
export function humanDate(iso: string): string {
|
||||
const [y, m, d] = iso.split("-").map(Number);
|
||||
const wd = new Date(Date.UTC(y, m - 1, d)).getUTCDay();
|
||||
return `${d} ${MONTHS[m - 1]}, ${WEEKDAYS[wd]}`;
|
||||
}
|
||||
Reference in New Issue
Block a user