fix(brainstorm): notebookId URL param + lookup carnet + bouton 'Open notebook'
- brainstorm-page.tsx: lit urlNotebookId depuis URL params - useConvertIdea accepte targetNotebookId (hook mis à jour) - handleConvert prend le carnet ciblé en paramètre - URL notebookId propage via router.push depuis le modal de confirmation - toast inclut le nom du carnet et un bouton 'Open notebook' qui redirige vers /home?notebook=X - peek panel affiche un lien vers le carnet source en haut du titre - useNotebooks pour le lookup du nom depuis notebooks Vrai fix: les notes vont maintenant là où l'utilisateur a choisi, pas dans un carnet auto-créé sans qu'il s'en aperçoive.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use client'
|
||||
import { toast } from 'sonner'
|
||||
import { useNotebooks } from '@/context/notebooks-context'
|
||||
|
||||
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
||||
import { useRouter, useSearchParams } from 'next/navigation'
|
||||
@@ -80,12 +81,14 @@ const WAVE_COLORS: Record<number, { border: string; bg: string; text: string }>
|
||||
export function BrainstormPage() {
|
||||
const router = useRouter()
|
||||
const peek = useNotePeek()
|
||||
const { notebooks } = useNotebooks()
|
||||
const searchParams = useSearchParams()
|
||||
const { t, language } = useLanguage()
|
||||
const { data: authSession } = useSession()
|
||||
const urlSessionId = searchParams.get('session')
|
||||
const urlSeed = searchParams.get('seed')
|
||||
const urlSourceNoteId = searchParams.get('sourceNoteId')
|
||||
const urlNotebookId = searchParams.get('notebookId')
|
||||
const urlInviteToken = searchParams.get('invite')
|
||||
|
||||
const [seedInput, setSeedInput] = useState('')
|
||||
@@ -242,17 +245,25 @@ export function BrainstormPage() {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const handleConvert = async (idea: BrainstormIdea) => {
|
||||
const handleConvert = async (idea: BrainstormIdea, targetNotebookId: string | null = urlNotebookId) => {
|
||||
try {
|
||||
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: null })
|
||||
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: targetNotebookId })
|
||||
if (result?.id) {
|
||||
let nbName = 'carnet'
|
||||
if (result.notebookId) {
|
||||
const nb = notebooks.find(n => n.id === result.notebookId)
|
||||
nbName = nb?.name || 'carnet'
|
||||
}
|
||||
toast.success(t('brainstorm.noteCreatedIn') || 'Note created', {
|
||||
description: result.title || idea.title,
|
||||
description: `${result.title || idea.title} → 📁 ${nbName}`,
|
||||
action: {
|
||||
label: t('notePeek.openFully') || 'Open',
|
||||
onClick: () => router.push(`/home?openNote=${result.id}`),
|
||||
label: t('brainstorm.openNotebook') || 'Open notebook',
|
||||
onClick: () => {
|
||||
if (result.notebookId) router.push(`/home?notebook=${result.notebookId}`)
|
||||
else router.push('/home')
|
||||
},
|
||||
},
|
||||
duration: 10000,
|
||||
duration: 15000,
|
||||
})
|
||||
peek.open(result.id)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { type ReactNode } from 'react'
|
||||
import { motion, AnimatePresence, useReducedMotion } from 'motion/react'
|
||||
import { X, Maximize2, Loader2 } from 'lucide-react'
|
||||
import { X, Maximize2, Loader2, FolderOpen } from 'lucide-react'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
import type { Note } from '@/lib/types'
|
||||
import { NotePeekContent } from './note-peek-content'
|
||||
@@ -77,6 +77,15 @@ export function NotePeekPanel({
|
||||
renderContent(note, blockId)
|
||||
) : (
|
||||
<>
|
||||
{note.notebookId && (
|
||||
<a
|
||||
href={`/home?notebook=${note.notebookId}`}
|
||||
className="inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest text-brand-accent hover:text-brand-accent/70 transition-colors mb-2 cursor-pointer"
|
||||
>
|
||||
<FolderOpen size={11} />
|
||||
{t('brainstorm.openNotebook') || 'Open notebook'}
|
||||
</a>
|
||||
)}
|
||||
<h2 className="text-xl font-serif font-medium text-ink dark:text-dark-ink mb-6">
|
||||
{note.title || t('notePeek.untitled') || 'Untitled'}
|
||||
</h2>
|
||||
|
||||
@@ -3076,7 +3076,8 @@
|
||||
"noNotebook": "No notebook",
|
||||
"launching": "Launching…",
|
||||
"launch": "Brainstorm",
|
||||
"noteCreatedIn": "Note created in"
|
||||
"noteCreatedIn": "Note created in",
|
||||
"openNotebook": "Open notebook"
|
||||
},
|
||||
"byokSettings": {
|
||||
"title": "Your API keys (BYOK)",
|
||||
|
||||
@@ -3080,7 +3080,8 @@
|
||||
"noNotebook": "Aucun carnet",
|
||||
"launching": "Lancement…",
|
||||
"launch": "Brainstormer",
|
||||
"noteCreatedIn": "Note créée dans"
|
||||
"noteCreatedIn": "Note créée dans",
|
||||
"openNotebook": "Ouvrir le carnet"
|
||||
},
|
||||
"byokSettings": {
|
||||
"title": "Vos clés API (BYOK)",
|
||||
|
||||
Reference in New Issue
Block a user