You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
8.5 KiB
TypeScript

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// frontend/components/life/TodayModule.tsx — 오늘 (통합 코칭 히어로 + 3영역 스냅샷 + 리마인더)
"use client";
import { Icon } from "@/components/Icon";
import { Ring } from "./Ring";
import { won } from "./SubRow";
import type { LifeProps } from "./types";
export function TodayModule({ health, finance, knowledge, go }: LifeProps) {
if (!health || !finance || !knowledge) return <div className="card">불러오는 중…</div>;
const h = health;
const f = finance;
const k = knowledge;
const nextSub = f.subs[0];
const pendingHabits = h.habits.filter((x) => x.done < x.total);
return (
<>
<div className="coach-hero">
<div className="ch-ava">
<Icon name="spark" />
</div>
<div className="ch-main">
<div className="ch-eyebrow">아리 라이프 코치 · 오늘 아침</div>
<h1>오늘의 컨디션은 좋아요. 활동만 조금 더 챙기면 완벽해요 ☀️</h1>
<p>
어젯밤 <b>7시간 12분</b> 푹 주무셨고 수면 점수는 86점이에요. 다만 어제{" "}
<b>물 섭취가 절반</b>에 그쳤으니 오후에 리마인더를 넣어뒀어요. 이번 달 소비는 지난달보다{" "}
<b>8% 적고</b> 순항 중이지만, <b>이틀 뒤 Netflix·Spotify 결제</b>가 함께 빠져나가요.
저장하신 <b>‘AI 에이전트 설계’ 글</b>은 오후 미팅과 연결돼 요약해뒀어요.
</p>
</div>
</div>
<div className="lgrid">
{/* 건강 스냅샷 */}
<div className="col-4">
<div className="card" style={{ cursor: "pointer" }} onClick={() => go("health")}>
<div className="card-head">
<div className="c-ic bg-coral">
<Icon name="heart" />
</div>
<div className="c-h">
<b>건강 &amp; 웰니스</b>
<span>활동·수면·습관</span>
</div>
<span className="c-act">
<Icon name="arrow" />
</span>
</div>
<div className="rings3">
{h.rings.map((r) => (
<Ring key={r.label} r={r} />
))}
</div>
<div className="sleep-note" style={{ marginTop: 14 }}>
물 마시기 <b>5/8잔</b> · 오후 3시 리마인더가 예정돼 있어요.
</div>
</div>
</div>
{/* 금융 스냅샷 */}
<div className="col-4">
<div className="card" style={{ cursor: "pointer" }} onClick={() => go("finance")}>
<div className="card-head">
<div className="c-ic bg-blue">
<Icon name="wallet" />
</div>
<div className="c-h">
<b>금융 &amp; 소비</b>
<span>6월 예산</span>
</div>
<span className="c-act">
<Icon name="arrow" />
</span>
</div>
<div className="budget-top">
<span className="bt-spent" style={{ fontSize: 26 }}>
{won(f.budget.spent)}
</span>
<span className="bt-of">/ {won(f.budget.limit)}</span>
</div>
<span className="budget-delta t-green">
<Icon name="trending" />
지난달보다 8% 절약
</span>
<div className="budget-gauge">
<i style={{ width: f.budget.pct + "%" }} />
</div>
{nextSub && (
<div className="sub-row soon" style={{ marginTop: 14 }}>
<div className={"su-ic bg-" + nextSub.tone}>
<Icon name={nextSub.icon as Parameters<typeof Icon>[0]["name"]} />
</div>
<div className="su-main">
<b>{nextSub.name}</b>
<span>다음 결제</span>
</div>
<div className="su-when">
<div className="sw-date">{nextSub.date}</div>
<div className="sw-in">{nextSub.in_days}일 뒤</div>
</div>
<div className="su-amt">{won(nextSub.amt)}</div>
</div>
)}
</div>
</div>
{/* 지식 스냅샷 */}
<div className="col-4">
<div className="card" style={{ cursor: "pointer" }} onClick={() => go("knowledge")}>
<div className="card-head">
<div className="c-ic bg-violet">
<Icon name="brain" />
</div>
<div className="c-h">
<b>지식 &amp; 학습</b>
<span>제2의 뇌</span>
</div>
<span className="c-act">
<Icon name="arrow" />
</span>
</div>
<div
className="kn-search"
style={{ padding: "11px 14px", borderWidth: 1 }}
onClick={(e) => {
e.stopPropagation();
go("knowledge");
}}
>
<Icon name="spark" />
<span style={{ flex: 1, fontSize: 13.5, color: "var(--faint)" }}>
저장한 것에 물어보기…
</span>
</div>
<div className="scraps" style={{ marginTop: 12 }}>
{k.items.slice(0, 2).map((it) => (
<div
key={it.id}
style={{
display: "flex",
gap: 10,
alignItems: "center",
padding: "9px 0",
borderTop: "1px solid var(--line)",
}}
>
<div
className={"sc-ic bg-" + it.tone}
style={{
width: 30,
height: 30,
borderRadius: 9,
display: "grid",
placeItems: "center",
flexShrink: 0,
}}
>
<Icon name={it.icon as Parameters<typeof Icon>[0]["name"]} />
</div>
<div style={{ minWidth: 0 }}>
<b
style={{
fontSize: 12.5,
fontWeight: 600,
display: "block",
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
{it.title}
</b>
<span style={{ fontSize: 10.5, color: "var(--muted)" }}>
{it.src} · {it.time}
</span>
</div>
</div>
))}
</div>
</div>
</div>
{/* 오늘의 리마인더 */}
<div className="col-12">
<div className="card">
<div className="card-head">
<div className="c-ic bg-amber">
<Icon name="bell" />
</div>
<div className="c-h">
<b>오늘의 리마인더</b>
<span>아리가 챙기고 있는 것들</span>
</div>
</div>
<div className="lgrid" style={{ gap: 11 }}>
{pendingHabits.map((hb) => (
<div className="col-4" key={hb.id}>
<div className="insight">
<div className={"in-ic bg-" + hb.tone}>
<Icon name={hb.icon as Parameters<typeof Icon>[0]["name"]} />
</div>
<div className="in-main">
<b>{hb.title}</b>
<p>
{hb.at} · {hb.done}/{hb.total} 완료
</p>
</div>
</div>
</div>
))}
{nextSub && (
<div className="col-4">
<div className="insight alert">
<div className="in-ic">
<Icon name="repeat" />
</div>
<div className="in-main">
<b>구독 결제 임박</b>
<p>
{nextSub.date} {nextSub.name} {won(nextSub.amt)} 결제 예정
</p>
</div>
</div>
</div>
)}
</div>
</div>
</div>
</div>
</>
);
}