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.
97 lines
3.1 KiB
TypeScript
97 lines
3.1 KiB
TypeScript
// frontend/components/life/ModuleRail.tsx — 좌측 모듈 레일 + 연결된 데이터 소스
|
|
"use client";
|
|
import { Icon } from "@/components/Icon";
|
|
import type { ConnectorSourceOut, LifeDomain, IconName } from "@/lib/types";
|
|
import type { Mod, Toast } from "./types";
|
|
|
|
const MODULES: { id: Mod; label: string; sub: string; icon: IconName; tone: string }[] = [
|
|
{ id: "today", label: "오늘의 라이프", sub: "통합 코칭", icon: "spark", tone: "coral" },
|
|
{ id: "health", label: "건강 & 웰니스", sub: "활동·수면·습관", icon: "heart", tone: "coral" },
|
|
{ id: "finance", label: "금융 & 소비", sub: "예산·구독·자산", icon: "wallet", tone: "blue" },
|
|
{ id: "knowledge", label: "지식 & 학습", sub: "제2의 뇌", icon: "brain", tone: "violet" },
|
|
{ id: "connect", label: "연결", sub: "외부 데이터 소스", icon: "link", tone: "green" },
|
|
];
|
|
|
|
export function ModuleRail({
|
|
mod,
|
|
onPick,
|
|
sources,
|
|
onToast,
|
|
}: {
|
|
mod: Mod;
|
|
onPick: (m: Mod) => void;
|
|
sources?: Record<LifeDomain, ConnectorSourceOut[]>;
|
|
onToast: Toast;
|
|
}) {
|
|
// 원본 638행: health 전체 + finance 앞2 + knowledge 앞2 만 레일에 표시
|
|
const railSources: ConnectorSourceOut[] = sources
|
|
? [
|
|
...(sources.health ?? []),
|
|
...(sources.finance ?? []).slice(0, 2),
|
|
...(sources.knowledge ?? []).slice(0, 2),
|
|
]
|
|
: [];
|
|
|
|
return (
|
|
<aside className="subnav">
|
|
{MODULES.map((m) => (
|
|
<button
|
|
key={m.id}
|
|
className={"mod-row t-" + m.tone + (mod === m.id ? " on" : "")}
|
|
onClick={() => onPick(m.id)}
|
|
aria-current={mod === m.id ? "page" : undefined}
|
|
>
|
|
<div className="m-ic">
|
|
<Icon name={m.icon} />
|
|
</div>
|
|
<div className="m-txt">
|
|
<b>{m.label}</b>
|
|
<span>{m.sub}</span>
|
|
</div>
|
|
</button>
|
|
))}
|
|
|
|
<div className="sn-label">연결된 데이터</div>
|
|
<div className="src-list">
|
|
{railSources.map((s) => (
|
|
<button
|
|
className="src-row"
|
|
key={s.id}
|
|
onClick={() =>
|
|
onToast(
|
|
s.on ? `${s.name} 동기화 중…` : `${s.name} 연결 화면을 여는 중…`,
|
|
s.tone,
|
|
)
|
|
}
|
|
>
|
|
<span
|
|
className={"src-dot" + (s.on ? "" : " off")}
|
|
style={{ background: `var(--${s.tone})` }}
|
|
/>
|
|
<div className="src-info">
|
|
<b>{s.name}</b>
|
|
<span>{s.kind}</span>
|
|
</div>
|
|
<span className={"src-stat" + (s.on ? "" : " off")}>{s.on ? "연결됨" : "연결"}</span>
|
|
</button>
|
|
))}
|
|
<button
|
|
className="src-add"
|
|
onClick={() => onToast("데이터 소스 연결 화면을 여는 중…", "blue")}
|
|
>
|
|
<Icon name="plus" />
|
|
소스 연결하기
|
|
</button>
|
|
</div>
|
|
|
|
<div className="sn-foot">
|
|
<div className="av-lg">지</div>
|
|
<div className="txt">
|
|
<b>지우님</b>
|
|
<span>Pro 플랜 · 9개 소스</span>
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|