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>
This commit is contained in:
@@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from 'next/server'
|
||||
import { Prisma } from '@prisma/client'
|
||||
import { auth } from '@/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { getOrCreateDeckForNotebook } from '@/lib/flashcards/deck-utils'
|
||||
import type { FlashcardStyle } from '@/lib/flashcards/generate-flashcards'
|
||||
|
||||
interface CardInput {
|
||||
@@ -35,7 +34,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
let notebookId: string | null = null
|
||||
let fallbackDeckName: string | undefined
|
||||
let noteName = 'Sans titre'
|
||||
if (noteId) {
|
||||
const note = await prisma.note.findFirst({
|
||||
where: { id: noteId, userId: session.user.id },
|
||||
@@ -45,14 +44,13 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'Note not found' }, { status: 404 })
|
||||
}
|
||||
notebookId = note.notebookId
|
||||
if (!notebookId) {
|
||||
fallbackDeckName = note.title?.trim() || 'General'
|
||||
}
|
||||
noteName = note.title?.trim() || 'Sans titre'
|
||||
}
|
||||
|
||||
let deckId = deckIdInput
|
||||
if (!deckId) {
|
||||
if (noteId) {
|
||||
// Chercher un deck déjà créé pour CETTE note spécifique
|
||||
const existingFromNote = await prisma.flashcard.findFirst({
|
||||
where: { noteId, deck: { userId: session.user.id } },
|
||||
select: { deckId: true },
|
||||
@@ -62,10 +60,9 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
if (!deckId) {
|
||||
const deck = await getOrCreateDeckForNotebook({
|
||||
userId: session.user.id,
|
||||
notebookId,
|
||||
manualName: fallbackDeckName,
|
||||
// Créer un nouveau deck nommé d'après la note (pas le carnet)
|
||||
const deck = await prisma.flashcardDeck.create({
|
||||
data: { userId: session.user.id, notebookId, name: noteName },
|
||||
})
|
||||
deckId = deck.id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user