전수 E2E 순회·소유자 결정 6건 구현·디자인 감사 반영
- 전수 순회: IA 전 라우트 412개 기능 인벤토리를 체크리스트 백로그로 관리 (docs/ops/e2e-full-sweep-2026-07-27.md), 신규 full-sweep 스펙 10파일 추가. RED→GREEN으로 결함 12건 수정: 관리자 무한 렌더 프리즈(TanStack autoReset 루프), 복수 코호트 저장 유실, 페르소나 보관 503(SQL 컬럼 모호성), PII 과잉 마스킹, /admin/ai watchdog 오탐 오버레이, 모바일 겹침 2건, 설정 스크롤 스파이, 온보딩 전화번호 무검증, 리뷰 조사·난도 라벨, pending 피드백 등. - 소유자 결정 구현: 설정 아바타 변경, 동의 철회·재동의 전체 흐름, 신규 학습자 기초 우선 추천, 학생 분석 테이블 가상화(@tanstack/react-virtual), 저작 모드 죽은 레일 정리, 감정 밸런스 타임라인 차트(deep turn_valence + 결정론 파생 폴백). - 디자인 감사(142차): 라이트 팔레트 AA 대비, 다크 토큰 별칭 통일, 미정의 CSS 변수 정리, 한글 keep-all 전역화, 탭 타깃 24px, LCP preconnect. - 검증: npm run e2e 병렬 432 수집 GREEN + 직렬 49/49 exit 0, 백엔드 pytest 421, gateway 29, typecheck/build/design-ssot/dead-code/중복 게이트 통과, layout-visual-gate 15/15, session-layout 8/8. 상세는 SSOT 대시보드 142~144차 노트.
This commit is contained in:
parent
0ae94499f2
commit
4511383cd9
55 changed files with 9333 additions and 573 deletions
|
|
@ -15,6 +15,7 @@ import { roleLabel, useAuth } from "../lib/auth";
|
|||
import {
|
||||
adminApi,
|
||||
adminEngineApi,
|
||||
apiUrl,
|
||||
userApi,
|
||||
type AdminHealthResponse,
|
||||
type AdminEngineConfigResponse,
|
||||
|
|
@ -108,6 +109,18 @@ function formatTicketDate(value?: number | null): string {
|
|||
}).format(new Date(value * 1000));
|
||||
}
|
||||
|
||||
/** 동의 시각 표기 — 감사 추적을 위해 연도까지 포함한다. */
|
||||
function formatConsentDate(value?: number | null): string {
|
||||
if (!value) return "-";
|
||||
return new Intl.DateTimeFormat("ko-KR", {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
}).format(new Date(value * 1000));
|
||||
}
|
||||
|
||||
function SettingsLoadingState({
|
||||
children,
|
||||
testId,
|
||||
|
|
@ -189,11 +202,13 @@ function completeNotificationPreferences(
|
|||
}
|
||||
|
||||
export default function Settings() {
|
||||
const { user } = useAuth();
|
||||
const { user, refresh, acceptConsent, withdrawConsent } = useAuth();
|
||||
const role = user?.role ?? "learner";
|
||||
const isAdmin = role === "admin";
|
||||
const [dark, setDark] = useTheme();
|
||||
const [activeSection, setActiveSection] = useState("account");
|
||||
// goSection의 스무스 스크롤 동안 IntersectionObserver가 활성 섹션을 되돌리지 않게 억제한다.
|
||||
const spySuppressUntilRef = useRef(0);
|
||||
|
||||
const [profile, setProfile] = useState<UserProfileResponse | null>(null);
|
||||
const [displayName, setDisplayName] = useState(user?.name ?? "");
|
||||
|
|
@ -221,6 +236,15 @@ export default function Settings() {
|
|||
const affiliationDirtyRef = useRef(false);
|
||||
const engineConfigRef = useRef<AdminEngineConfigResponse | null>(null);
|
||||
const loadSettingsRequestRef = useRef(0);
|
||||
// 아바타 업로드 — 온보딩과 같은 계약(3MB, PNG/JPEG/WebP)을 설정에서도 쓴다.
|
||||
const avatarInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const [uploadingAvatar, setUploadingAvatar] = useState(false);
|
||||
const [avatarError, setAvatarError] = useState("");
|
||||
// 실습 동의 관리 — 철회는 인라인 2단계 확인을 거친다.
|
||||
const [consentConfirming, setConsentConfirming] = useState(false);
|
||||
const [consentBusy, setConsentBusy] = useState(false);
|
||||
const [consentWithdrawn, setConsentWithdrawn] = useState(false);
|
||||
const [consentError, setConsentError] = useState("");
|
||||
|
||||
const flashSaved = (key: string) => {
|
||||
setSavedKey(key);
|
||||
|
|
@ -312,6 +336,7 @@ export default function Settings() {
|
|||
const base: NavItem[] = [
|
||||
{ id: "account", label: "계정", icon: "users" },
|
||||
{ id: "support", label: "지원 요청", icon: "review" },
|
||||
{ id: "consent", label: "동의", icon: "check" },
|
||||
{ id: "appearance", label: "테마", icon: "settings" },
|
||||
{ id: "notify", label: "알림", icon: "info" },
|
||||
{ id: "voice", label: "음성", icon: "mic" },
|
||||
|
|
@ -323,18 +348,34 @@ export default function Settings() {
|
|||
}, [isAdmin]);
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const visible = entries
|
||||
.filter((entry) => entry.isIntersecting)
|
||||
.sort((a, b) => b.intersectionRatio - a.intersectionRatio)[0];
|
||||
if (visible?.target.id) {
|
||||
setActiveSection(visible.target.id.replace(/^set-/, ""));
|
||||
// 활성 규칙: 뷰포트 상단 18~38% 밴드에 걸친 섹션 중 가장 아래(=방금 지나친 헤딩).
|
||||
// 비율 우세 방식은 scroll-margin 정렬 지점이 밴드 하단 근처인 모바일에서
|
||||
// 직전 섹션이 계속 이겨 마지막 섹션이 활성화되지 않는다(결함 로그 #17).
|
||||
const pickActiveSection = () => {
|
||||
const bandTop = window.innerHeight * 0.18;
|
||||
const bandBottom = window.innerHeight * 0.38;
|
||||
let winner: { id: string; top: number } | null = null;
|
||||
for (const item of navItems) {
|
||||
const section = document.getElementById(`set-${item.id}`);
|
||||
if (!section) continue;
|
||||
const rect = section.getBoundingClientRect();
|
||||
if (rect.top > bandBottom || rect.bottom < bandTop) continue;
|
||||
if (!winner || rect.top > winner.top) {
|
||||
winner = { id: item.id, top: rect.top };
|
||||
}
|
||||
}
|
||||
if (winner) setActiveSection(winner.id);
|
||||
};
|
||||
const observer = new IntersectionObserver(
|
||||
() => {
|
||||
if (Date.now() < spySuppressUntilRef.current) return;
|
||||
pickActiveSection();
|
||||
},
|
||||
{
|
||||
rootMargin: "-18% 0px -62% 0px",
|
||||
threshold: [0.2, 0.55],
|
||||
// 0 임계값이 없으면 긴 섹션(모바일)은 밴드 대비 비율이 0.2에 못 미쳐
|
||||
// 콜백이 아예 오지 않는다(결함 로그 #17).
|
||||
threshold: [0, 0.2, 0.55],
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -343,7 +384,22 @@ export default function Settings() {
|
|||
if (section) observer.observe(section);
|
||||
}
|
||||
|
||||
return () => observer.disconnect();
|
||||
// 마지막 섹션은 짧은 뷰포트에서 활성 밴드(18~38%)에 도달하지 못한다.
|
||||
// 스크롤 컨테이너가 바닥에 닿으면 마지막 섹션을 활성으로 처리한다(결함 로그 #17).
|
||||
const scroller = document.querySelector(".vg-main");
|
||||
const onScroll = () => {
|
||||
if (!scroller || Date.now() < spySuppressUntilRef.current) return;
|
||||
if (scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 4) {
|
||||
const last = navItems[navItems.length - 1];
|
||||
if (last) setActiveSection(last.id);
|
||||
}
|
||||
};
|
||||
scroller?.addEventListener("scroll", onScroll, { passive: true });
|
||||
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
scroller?.removeEventListener("scroll", onScroll);
|
||||
};
|
||||
}, [navItems]);
|
||||
|
||||
const visibleNotifications = useMemo(
|
||||
|
|
@ -380,6 +436,7 @@ export default function Settings() {
|
|||
);
|
||||
|
||||
const goSection = (id: string) => {
|
||||
spySuppressUntilRef.current = Date.now() + 900;
|
||||
setActiveSection(id);
|
||||
document.getElementById(`set-${id}`)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
};
|
||||
|
|
@ -406,6 +463,58 @@ export default function Settings() {
|
|||
flashSaved("account");
|
||||
};
|
||||
|
||||
/** 아바타 업로드 → PATCH /users/me 저장 → 톱바·레일 아바타 갱신. */
|
||||
const uploadAvatar = async (file: File | null) => {
|
||||
if (!file || uploadingAvatar) return;
|
||||
setUploadingAvatar(true);
|
||||
setAvatarError("");
|
||||
try {
|
||||
const uploaded = await userApi.uploadAvatar(file);
|
||||
const next = await userApi.updateMe({ avatar_url: uploaded.avatar_url });
|
||||
setProfile(next);
|
||||
await refresh();
|
||||
flashSaved("account");
|
||||
} catch (err) {
|
||||
console.warn("[settings] avatar upload failed", err);
|
||||
setAvatarError("아바타 업로드에 실패했습니다. PNG, JPG, WebP 파일을 3MB 이하로 올려 주세요.");
|
||||
} finally {
|
||||
setUploadingAvatar(false);
|
||||
}
|
||||
};
|
||||
|
||||
/** 실습 동의 철회 확정 — DELETE /auth/consent, learner 전용. */
|
||||
const confirmWithdrawConsent = async () => {
|
||||
if (consentBusy) return;
|
||||
setConsentBusy(true);
|
||||
setConsentError("");
|
||||
try {
|
||||
await withdrawConsent();
|
||||
setConsentWithdrawn(true);
|
||||
setConsentConfirming(false);
|
||||
} catch (err) {
|
||||
console.warn("[settings] consent withdraw failed", err);
|
||||
setConsentError(err instanceof Error ? err.message : "실습 동의 철회에 실패했습니다.");
|
||||
} finally {
|
||||
setConsentBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
/** 실습 동의 재동의 — POST /auth/consent, 회기 시작 화면과 같은 계약. */
|
||||
const reacceptConsent = async () => {
|
||||
if (consentBusy) return;
|
||||
setConsentBusy(true);
|
||||
setConsentError("");
|
||||
try {
|
||||
await acceptConsent();
|
||||
setConsentWithdrawn(false);
|
||||
} catch (err) {
|
||||
console.warn("[settings] consent accept failed", err);
|
||||
setConsentError(err instanceof Error ? err.message : "실습 동의 저장에 실패했습니다.");
|
||||
} finally {
|
||||
setConsentBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const savePreferences = async (key: string) => {
|
||||
if (!preferencesReady || !preferences) return;
|
||||
const notifications = completeNotificationPreferences(preferences.notifications);
|
||||
|
|
@ -453,6 +562,10 @@ export default function Settings() {
|
|||
const accountName = displayName || profile?.email || user?.name || user?.email || "사용자";
|
||||
const accountEmail = profile?.email ?? user?.email ?? "";
|
||||
const initials = accountName.trim().slice(0, 1).toUpperCase();
|
||||
// 프로필이 먼저 도착하면 프로필 값을, 아니면 auth 스토어의 절대화된 URL을 쓴다.
|
||||
const avatarSrc = profile?.avatar_url ? apiUrl(profile.avatar_url) : user?.avatarUrl ?? "";
|
||||
const isLearner = role === "learner";
|
||||
const consentAt = user?.consentAt ?? null;
|
||||
const engineHasRequiredFields = engineConfig
|
||||
? engineConfig.engine_url.trim().length > 0 && engineConfig.model.trim().length > 0
|
||||
: false;
|
||||
|
|
@ -490,7 +603,7 @@ export default function Settings() {
|
|||
|
||||
<div className={surfaceClassName("vg-set__rail-card", { variant: "inset" })} aria-label="계정 요약">
|
||||
<div className="vg-set__rail-avatar" aria-hidden="true">
|
||||
{initials}
|
||||
{avatarSrc ? <img src={avatarSrc} alt="" /> : initials}
|
||||
</div>
|
||||
<div className="vg-set__rail-copy">
|
||||
<div className="vg-set__rail-name">{accountName}</div>
|
||||
|
|
@ -541,7 +654,7 @@ export default function Settings() {
|
|||
|
||||
<div className={surfaceClassName("vg-set__profile", { variant: "inset", flat: true })}>
|
||||
<div className="vg-set__avatar" aria-hidden="true">
|
||||
{initials}
|
||||
{avatarSrc ? <img src={avatarSrc} alt="" /> : initials}
|
||||
</div>
|
||||
<div className="vg-set__profile-meta">
|
||||
<div className="n">{accountName}</div>
|
||||
|
|
@ -551,8 +664,25 @@ export default function Settings() {
|
|||
{affiliation ? <Badge tone="neutral">{affiliation}</Badge> : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="vg-set__avatar-actions">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => avatarInputRef.current?.click()}
|
||||
disabled={loading || uploadingAvatar}
|
||||
>
|
||||
{uploadingAvatar ? "업로드 중" : avatarSrc ? "아바타 변경" : "아바타 올리기"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{avatarError ? (
|
||||
<div className="vg-set__state vg-set__state--warn" role="alert">
|
||||
<span className="vg-set__state-dot" aria-hidden="true" />
|
||||
<span>{avatarError}</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="vg-set__field-grid vg-set__field-grid--account">
|
||||
<div className={surfaceClassName("vg-set__field", { variant: "inset", flat: true })}>
|
||||
<div className="vg-set__field-copy">
|
||||
|
|
@ -626,6 +756,21 @@ export default function Settings() {
|
|||
저장
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 숨은 아바타 file input — 계정 텍스트 입력들의 DOM 순서(0=표시 이름)를
|
||||
흔들지 않도록 섹션 마지막에 둔다. 버튼이 ref 로 클릭을 위임한다. */}
|
||||
<input
|
||||
ref={avatarInputRef}
|
||||
type="file"
|
||||
accept="image/png,image/jpeg,image/webp"
|
||||
className="vg-set__avatar-input"
|
||||
aria-label="아바타 이미지"
|
||||
disabled={loading || uploadingAvatar}
|
||||
onChange={(event) => {
|
||||
void uploadAvatar(event.currentTarget.files?.[0] ?? null);
|
||||
event.currentTarget.value = "";
|
||||
}}
|
||||
/>
|
||||
</Panel>
|
||||
|
||||
<Panel id="set-support" className="vg-set__group vg-set__group--wide">
|
||||
|
|
@ -819,6 +964,118 @@ export default function Settings() {
|
|||
</Panel>
|
||||
) : null}
|
||||
|
||||
<Panel id="set-consent" className="vg-set__group vg-set__group--compact">
|
||||
<div className="vg-set__group-head">
|
||||
<div>
|
||||
<div className="vg-set__group-title">동의</div>
|
||||
<div className="vg-set__group-desc">실습 동의와 약관 동의 이력을 확인하고 관리합니다.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="vg-set__opt-grid">
|
||||
<div className={surfaceClassName("vg-set__opt", { variant: "inset", flat: true })}>
|
||||
<div className="vg-set__opt-text">
|
||||
<div className="l">실습 동의</div>
|
||||
<div className="h" data-testid="settings-consent-practice">
|
||||
{!isLearner
|
||||
? "학습자 전용 항목입니다. 실습 동의는 학습자 계정에서만 관리합니다."
|
||||
: consentAt != null
|
||||
? `동의 시각 ${formatConsentDate(consentAt)}`
|
||||
: "미동의 상태입니다."}
|
||||
</div>
|
||||
</div>
|
||||
{!isLearner ? (
|
||||
<Badge tone="neutral">학습자 전용</Badge>
|
||||
) : consentAt != null && !consentConfirming ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setConsentConfirming(true)}
|
||||
disabled={consentBusy}
|
||||
>
|
||||
실습 동의 철회
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className={surfaceClassName("vg-set__opt", { variant: "inset", flat: true })}>
|
||||
<div className="vg-set__opt-text">
|
||||
<div className="l">이용약관</div>
|
||||
<div className="h">
|
||||
{profileReady && profile
|
||||
? `버전 ${profile.terms_version || "-"} · 동의 ${formatConsentDate(profile.terms_agreed_at)}`
|
||||
: "동의 이력을 확인하는 중입니다."}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={surfaceClassName("vg-set__opt", { variant: "inset", flat: true })}>
|
||||
<div className="vg-set__opt-text">
|
||||
<div className="l">개인정보 처리방침</div>
|
||||
<div className="h">
|
||||
{profileReady && profile
|
||||
? `버전 ${profile.privacy_version || "-"} · 동의 ${formatConsentDate(profile.privacy_agreed_at)}`
|
||||
: "동의 이력을 확인하는 중입니다."}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{consentError ? (
|
||||
<div className="vg-set__state vg-set__state--warn" role="alert">
|
||||
<span className="vg-set__state-dot" aria-hidden="true" />
|
||||
<span>{consentError}</span>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isLearner && consentAt != null && consentConfirming ? (
|
||||
<div className={surfaceClassName("vg-set__consent-block", { variant: "inset", flat: true })}>
|
||||
<span>정말 철회할까요? 철회하면 새 회기 시작과 음성 연습이 즉시 차단됩니다.</span>
|
||||
<div className="vg-set__consent-actions">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger"
|
||||
onClick={() => void confirmWithdrawConsent()}
|
||||
disabled={consentBusy}
|
||||
>
|
||||
{consentBusy ? "철회 중" : "철회 확정"}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => setConsentConfirming(false)}
|
||||
disabled={consentBusy}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isLearner && consentAt == null ? (
|
||||
<div className={surfaceClassName("vg-set__consent-block", { variant: "inset", flat: true })}>
|
||||
{consentWithdrawn ? (
|
||||
<span role="status">
|
||||
새 회기 시작과 음성 연습이 차단됩니다. 아래 버튼 또는 회기 시작 화면에서
|
||||
다시 동의할 수 있습니다.
|
||||
</span>
|
||||
) : (
|
||||
<span>실습 동의가 없어 새 회기 시작과 음성 연습이 차단된 상태입니다.</span>
|
||||
)}
|
||||
<div className="vg-set__consent-actions">
|
||||
<Button
|
||||
size="sm"
|
||||
leading={<Icon name="check" size={14} />}
|
||||
onClick={() => void reacceptConsent()}
|
||||
disabled={consentBusy}
|
||||
>
|
||||
{consentBusy ? "저장 중" : "다시 동의"}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</Panel>
|
||||
|
||||
<Panel id="set-appearance" className="vg-set__group vg-set__group--compact">
|
||||
<div className="vg-set__group-head">
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue