Files
Momento/memento-note/app/api/mobile/flashcards/review/route.ts
Antigravity 0fa8978395
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m32s
CI / Deploy production (on server) (push) Has been skipped
feat: mobile app complet + flashcards fixes + drag handle améliorations
Mobile app:
- Révision flashcards : liste decks, session flip-card SM-2, couleurs harmonisées web
- Génération flashcards depuis note (FlashcardSheet + route /api/mobile/flashcards/generate)
- Audio Whisper : hook useAudioRecorder reécrit, MicButton avec erreurs
- IA : AISheet (améliorer/clarifier/résumer), TitleSheet (titre automatique)
- Suppression note (soft delete + confirmation Alert)
- Note du jour : titre lisible + HTML (plus JSON TipTap brut)
- Parser TipTap→HTML côté mobile (tipTapToHtml)
- Icône 🎓 dans header note → génération flashcards
- Endpoint flashcardGenerate dans config.ts

Web fixes:
- Bug flashcards groupées par carnet → deck par note (migration + schema)
- Bug filtre 'cartes dues' ignoré (suppression fallback buildSessionQueue)
- Suppression UI création deck manuelle (inutile)
- Fix setViewType is not defined dans home-client.tsx

Drag handle menu:
- Fix : clearNodes() avant transformation (heading→liste/code/citation)
- Ajout : option 'Texte' (paragraphe) dans Transformer en
- Ajout : Monter / Descendre le bloc
- Ajout : Copier le contenu du bloc
- Fix : sous-menu hover stable (délai 200ms)
- Fix : Supprimer en rouge via classe --danger (plus :first-child)
- i18n : nouvelles clés dans 15 locales

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 18:49:40 +00:00

41 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { NextRequest, NextResponse } from 'next/server'
import prisma from '@/lib/prisma'
import { getMobileUserId } from '@/lib/mobile-auth'
import { computeSm2Update } from '@/lib/flashcards/sm2'
export async function POST(req: NextRequest) {
const userId = getMobileUserId(req)
if (!userId) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
const body = await req.json()
const cardId = typeof body.cardId === 'string' ? body.cardId : null
const grade = typeof body.grade === 'number' ? body.grade : null
if (!cardId || grade === null || grade < 1 || grade > 4) {
return NextResponse.json({ error: 'cardId and grade (14) required' }, { status: 400 })
}
const card = await prisma.flashcard.findFirst({
where: { id: cardId, deck: { userId } },
select: { id: true, interval: true, easinessFactor: true },
})
if (!card) return NextResponse.json({ error: 'Card not found' }, { status: 404 })
const { easinessFactor, interval, nextReviewAt } = computeSm2Update(grade, {
easinessFactor: card.easinessFactor,
interval: card.interval,
})
await prisma.$transaction([
prisma.flashcard.update({
where: { id: cardId },
data: { easinessFactor, interval, nextReviewAt },
}),
prisma.flashcardReview.create({
data: { cardId, grade, reviewedAt: new Date() },
}),
])
return NextResponse.json({ ok: true, nextReviewAt, interval })
}