fix: organisateur IA — apply tag utilise syncNoteLabels au lieu de properties
- applyTag faisait un PATCH sur /api/notes/[id]/properties avec { tags: [...] }
mais l'API properties attend { properties: { propId: value } }
- Maintenant: PATCH /api/ai/organize-notebook qui appelle syncNoteLabels()
- Les tags sont appliqués comme LABELS (système existant) sur les notes
- Merge avec labels existants (n'écrase pas)
This commit is contained in:
@@ -1068,7 +1068,8 @@ export function HomeClient({
|
||||
>
|
||||
<Wand2 size={14} />
|
||||
<span>{t('structuredViews.organizer') || 'Organiser'}</span>
|
||||
</button>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{searchParams.get('notebook') && (
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
@@ -53,15 +53,14 @@ export function NotebookOrganizerDialog({
|
||||
|
||||
const applyTag = async (tagName: string, noteIds: string[]) => {
|
||||
try {
|
||||
for (const noteId of noteIds) {
|
||||
await fetch(`/api/notes/${noteId}/properties`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ tags: [tagName] }),
|
||||
}).catch(() => {})
|
||||
}
|
||||
const res = await fetch('/api/ai/organize-notebook', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ action: 'apply_tag', tagName, noteIds, notebookId }),
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed')
|
||||
setAppliedTags(prev => new Set(prev).add(tagName))
|
||||
toast.success(t('wizard.tagApplied') || `Tag "${tagName}" appliqué à ${noteIds.length} notes`)
|
||||
toast.success(t('structuredViews.tagApplied') || `Tag "${tagName}" appliqué à ${noteIds.length} notes`)
|
||||
} catch {
|
||||
toast.error('Erreur')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user