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'
|
'use client'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
|
import { useNotebooks } from '@/context/notebooks-context'
|
||||||
|
|
||||||
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
|
||||||
import { useRouter, useSearchParams } from 'next/navigation'
|
import { useRouter, useSearchParams } from 'next/navigation'
|
||||||
@@ -80,12 +81,14 @@ const WAVE_COLORS: Record<number, { border: string; bg: string; text: string }>
|
|||||||
export function BrainstormPage() {
|
export function BrainstormPage() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const peek = useNotePeek()
|
const peek = useNotePeek()
|
||||||
|
const { notebooks } = useNotebooks()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
const { t, language } = useLanguage()
|
const { t, language } = useLanguage()
|
||||||
const { data: authSession } = useSession()
|
const { data: authSession } = useSession()
|
||||||
const urlSessionId = searchParams.get('session')
|
const urlSessionId = searchParams.get('session')
|
||||||
const urlSeed = searchParams.get('seed')
|
const urlSeed = searchParams.get('seed')
|
||||||
const urlSourceNoteId = searchParams.get('sourceNoteId')
|
const urlSourceNoteId = searchParams.get('sourceNoteId')
|
||||||
|
const urlNotebookId = searchParams.get('notebookId')
|
||||||
const urlInviteToken = searchParams.get('invite')
|
const urlInviteToken = searchParams.get('invite')
|
||||||
|
|
||||||
const [seedInput, setSeedInput] = useState('')
|
const [seedInput, setSeedInput] = useState('')
|
||||||
@@ -242,17 +245,25 @@ export function BrainstormPage() {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConvert = async (idea: BrainstormIdea) => {
|
const handleConvert = async (idea: BrainstormIdea, targetNotebookId: string | null = urlNotebookId) => {
|
||||||
try {
|
try {
|
||||||
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: null })
|
const result = await convertIdea.mutateAsync({ ideaId: idea.id, notebookId: targetNotebookId })
|
||||||
if (result?.id) {
|
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', {
|
toast.success(t('brainstorm.noteCreatedIn') || 'Note created', {
|
||||||
description: result.title || idea.title,
|
description: `${result.title || idea.title} → 📁 ${nbName}`,
|
||||||
action: {
|
action: {
|
||||||
label: t('notePeek.openFully') || 'Open',
|
label: t('brainstorm.openNotebook') || 'Open notebook',
|
||||||
onClick: () => router.push(`/home?openNote=${result.id}`),
|
onClick: () => {
|
||||||
|
if (result.notebookId) router.push(`/home?notebook=${result.notebookId}`)
|
||||||
|
else router.push('/home')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
duration: 10000,
|
duration: 15000,
|
||||||
})
|
})
|
||||||
peek.open(result.id)
|
peek.open(result.id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { type ReactNode } from 'react'
|
import { type ReactNode } from 'react'
|
||||||
import { motion, AnimatePresence, useReducedMotion } from 'motion/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 { useLanguage } from '@/lib/i18n'
|
||||||
import type { Note } from '@/lib/types'
|
import type { Note } from '@/lib/types'
|
||||||
import { NotePeekContent } from './note-peek-content'
|
import { NotePeekContent } from './note-peek-content'
|
||||||
@@ -77,6 +77,15 @@ export function NotePeekPanel({
|
|||||||
renderContent(note, blockId)
|
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">
|
<h2 className="text-xl font-serif font-medium text-ink dark:text-dark-ink mb-6">
|
||||||
{note.title || t('notePeek.untitled') || 'Untitled'}
|
{note.title || t('notePeek.untitled') || 'Untitled'}
|
||||||
</h2>
|
</h2>
|
||||||
|
|||||||
@@ -3076,7 +3076,8 @@
|
|||||||
"noNotebook": "No notebook",
|
"noNotebook": "No notebook",
|
||||||
"launching": "Launching…",
|
"launching": "Launching…",
|
||||||
"launch": "Brainstorm",
|
"launch": "Brainstorm",
|
||||||
"noteCreatedIn": "Note created in"
|
"noteCreatedIn": "Note created in",
|
||||||
|
"openNotebook": "Open notebook"
|
||||||
},
|
},
|
||||||
"byokSettings": {
|
"byokSettings": {
|
||||||
"title": "Your API keys (BYOK)",
|
"title": "Your API keys (BYOK)",
|
||||||
|
|||||||
@@ -3080,7 +3080,8 @@
|
|||||||
"noNotebook": "Aucun carnet",
|
"noNotebook": "Aucun carnet",
|
||||||
"launching": "Lancement…",
|
"launching": "Lancement…",
|
||||||
"launch": "Brainstormer",
|
"launch": "Brainstormer",
|
||||||
"noteCreatedIn": "Note créée dans"
|
"noteCreatedIn": "Note créée dans",
|
||||||
|
"openNotebook": "Ouvrir le carnet"
|
||||||
},
|
},
|
||||||
"byokSettings": {
|
"byokSettings": {
|
||||||
"title": "Vos clés API (BYOK)",
|
"title": "Vos clés API (BYOK)",
|
||||||
|
|||||||
Reference in New Issue
Block a user