feat: clickable character cards, default character, rename Archivio → Libreria

- CharacterList: entire card is clickable to enter edit mode
- CharacterList: uses ConfirmModal for delete (replaces browser confirm)
- CharacterList: action buttons stop propagation to avoid double-nav
- ContentPage: auto-selects first active character as default
- Rename "Archivio Contenuti" → "Libreria Contenuti" everywhere
- Mobile-safe grid for character cards

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michele
2026-04-06 01:26:38 +02:00
parent 8c68004a5e
commit 72c5379706
3 changed files with 37 additions and 16 deletions

View File

@@ -69,14 +69,22 @@ export default function ContentPage() {
api.get('/characters/').then(d => {
setCharacters(d)
setCharsLoading(false)
// Auto-select default character (first active one)
const activeChars = d.filter(c => c.is_active)
const defaultChar = activeChars.length > 0 ? String(activeChars[0].id) : ''
// One-click flow: pre-fill from URL params
const urlTopic = searchParams.get('topic')
const urlCharacter = searchParams.get('character')
if (urlTopic && d.length > 0) {
const charId = urlCharacter || String(d[0].id)
const charId = urlCharacter || defaultChar
setForm(prev => ({ ...prev, character_id: charId, topic_hint: urlTopic }))
autoGenerateRef.current = true
setSearchParams({}, { replace: true }) // clean URL
setSearchParams({}, { replace: true })
} else if (defaultChar) {
// Pre-select default character
setForm(prev => ({ ...prev, character_id: prev.character_id || defaultChar }))
}
}).catch(() => setCharsLoading(false))
}, [])
@@ -205,7 +213,7 @@ export default function ContentPage() {
Definisci un brief editoriale, scegli piattaforma e tipo, poi genera. L'AI terrà conto del tono e dei topic del personaggio selezionato.
</p>
<Link to="/content/archive" style={{ fontSize: '0.8rem', color: 'var(--accent)', whiteSpace: 'nowrap', textDecoration: 'none', fontWeight: 600 }}>
Archivio
Libreria
</Link>
</div>
</div>