feat(study): 암기카드 학습 — 학습 중 '이 카드 이상해요' 버튼(검수함 복귀)

사용자 의도 정정: 신고 버튼은 퀴즈가 아니라 암기카드 학습(cards-study) 안에 필요했음.

- 복습·그냥공부 카드 우상단에 '이 카드 이상해요' 버튼. PATCH /study-cards/{id} {needs_review:true} → flagged_by='user' → 학습 큐에서 빠지고 검수함(/study/cards-review)으로 복귀. 신고 후 advance()로 다음 카드.
- 카드 backend(update_card needs_review set)는 기존 — 프론트 1파일만.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hyungi
2026-06-07 14:46:56 +09:00
parent 4e784a1fbc
commit 4e9548a8c0
@@ -16,7 +16,7 @@
import { goto } from '$app/navigation';
import { api } from '$lib/api';
import { addToast } from '$lib/stores/toast';
import { ArrowLeft, Repeat, Layers, Eye, BookOpen } from 'lucide-svelte';
import { ArrowLeft, Repeat, Layers, Eye, BookOpen, Flag } from 'lucide-svelte';
import Button from '$lib/components/ui/Button.svelte';
import Skeleton from '$lib/components/ui/Skeleton.svelte';
import EmptyState from '$lib/components/ui/EmptyState.svelte';
@@ -140,6 +140,23 @@
}
}
// 학습 중 카드 내용이 이상하면 검수함(cards-review)으로 되돌림 (needs_review=true → 학습 큐에서 빠짐).
let flagBusy = $state(false);
async function flagCard() {
if (!current || flagBusy || busy) return;
flagBusy = true;
const c = current;
try {
await api(`/study-cards/${c.id}`, { method: 'PATCH', body: JSON.stringify({ needs_review: true }) });
addToast('success', '검수함으로 보냈어요 — 이 카드는 학습에서 빠집니다');
advance();
} catch (err) {
addToast('error', err?.detail || '신고 처리 실패');
} finally {
flagBusy = false;
}
}
function setCramFilter(f) {
if (fmtFilter === f) return;
fmtFilter = f;
@@ -294,9 +311,20 @@
<!-- 카드 -->
<div class="flex flex-1 flex-col">
<div class="flex flex-1 flex-col rounded-card border border-default bg-surface p-5">
<span
class="self-start rounded-full px-2.5 py-0.5 text-[10px] font-bold text-white {current.format === 'cloze' ? 'bg-accent' : 'bg-domain-engineering'}"
>{current.format}</span>
<div class="flex items-center justify-between gap-2">
<span
class="rounded-full px-2.5 py-0.5 text-[10px] font-bold text-white {current.format === 'cloze' ? 'bg-accent' : 'bg-domain-engineering'}"
>{current.format}</span>
<button
type="button"
onclick={flagCard}
disabled={flagBusy || busy}
class="flex items-center gap-1 text-[11px] text-faint transition-colors hover:text-warning disabled:opacity-50"
title="카드 내용이 이상하면 검수함으로 보냅니다"
>
<Flag size={12} /> 이 카드 이상해요
</button>
</div>
<div class="mt-3 text-[10px] font-bold uppercase tracking-wide text-faint">
앞 — {current.format === 'qa' ? '질문' : '회상'}