diff --git a/apps/admin/src/pages/DashboardPage.jsx b/apps/admin/src/pages/DashboardPage.jsx index 2794be8..22c69ae 100644 --- a/apps/admin/src/pages/DashboardPage.jsx +++ b/apps/admin/src/pages/DashboardPage.jsx @@ -1,6 +1,7 @@ import { useEffect, useMemo, useState } from 'react'; import { NavLink, useNavigate, useParams } from 'react-router-dom'; import { useAuth } from '../auth/AuthContext.jsx'; +import { AdminContentTemplate, AdminDashboardPage, Card, Text } from '@flix/design-system/components'; import { createEvent, generateEventBranding, @@ -24,6 +25,8 @@ const defaultEventForm = { title: '', slug: '', description: '', + shortDescription: '', + longDescription: '', isActive: false, visibility: 'private', accessKey: '', @@ -34,6 +37,7 @@ const defaultEventForm = { textColor: '#f5f5f5', accentColor: '#e50914', logoUrl: '', + highlightVideoUrl: '', }; const defaultBrandingRequest = { @@ -45,6 +49,7 @@ const defaultBrandingRequest = { const defaultLessonForm = { title: '', + description: '', slug: '', videoProvider: 'youtube', videoId: '', @@ -79,7 +84,9 @@ const formatError = (error) => { const buildEventUpdatePayload = (form) => ({ title: form.title, slug: form.slug, - description: form.description, + description: form.shortDescription || form.description, + shortDescription: form.shortDescription || form.description, + longDescription: form.longDescription || form.description, isActive: form.isActive, visibility: form.visibility, accessKey: form.accessKey ? form.accessKey : null, @@ -94,15 +101,23 @@ const buildEventUpdatePayload = (form) => ({ accentColor: form.accentColor, }, logoUrl: form.logoUrl ? form.logoUrl : null, + highlightVideoUrl: form.highlightVideoUrl ? form.highlightVideoUrl : null, }); -const pageTitles = { - dashboard: 'Dashboard', - eventos: 'Eventos', - 'eventos-new': 'Eventos / Novo', - 'eventos-edit': 'Eventos / Editar', - aulas: 'Aulas', - quizzes: 'Quizzes', +const sectionDetails = { + dashboard: 'Visao geral operacional.', + eventos: 'Gestao de eventos e branding.', + 'eventos-new': 'Criacao de novos eventos.', + 'eventos-edit': 'Edicao de evento selecionado.', + aulas: 'Gestao de aulas e materiais.', + quizzes: 'Gestao de quizzes por aula.', +}; + +const isSectionActive = (currentSection, target) => { + if (target === 'eventos') { + return ['eventos', 'eventos-new', 'eventos-edit'].includes(currentSection); + } + return currentSection === target; }; export const DashboardPage = ({ section = 'dashboard' }) => { @@ -145,11 +160,13 @@ export const DashboardPage = ({ section = 'dashboard' }) => { [lessons, selectedLessonId], ); - const mapEventToForm = (item) => ({ - title: item.title ?? '', - slug: item.slug ?? '', - description: item.description ?? '', - isActive: Boolean(item.isActive), +const mapEventToForm = (item) => ({ + title: item.title ?? '', + slug: item.slug ?? '', + description: item.description ?? '', + shortDescription: item.shortDescription ?? item.description ?? '', + longDescription: item.longDescription ?? item.description ?? '', + isActive: Boolean(item.isActive), visibility: item.visibility ?? 'private', accessKey: item.accessKey ?? '', heroTitle: item.hero?.title ?? '', @@ -159,6 +176,7 @@ export const DashboardPage = ({ section = 'dashboard' }) => { textColor: item.visualStyle?.textColor ?? '#f5f5f5', accentColor: item.visualStyle?.accentColor ?? '#e50914', logoUrl: item.logoUrl ?? '', + highlightVideoUrl: item.highlightVideoUrl ?? '', }); const mapBrandingAssetsToForm = (baseForm, assets) => ({ @@ -292,7 +310,9 @@ export const DashboardPage = ({ section = 'dashboard' }) => { await createEvent(token, { title: eventForm.title, slug: eventForm.slug, - description: eventForm.description, + description: eventForm.shortDescription || eventForm.description, + shortDescription: eventForm.shortDescription || eventForm.description, + longDescription: eventForm.longDescription || eventForm.description, isActive: eventForm.isActive, visibility: eventForm.visibility, accessKey: eventForm.accessKey || undefined, @@ -307,6 +327,7 @@ export const DashboardPage = ({ section = 'dashboard' }) => { accentColor: eventForm.accentColor, }, logoUrl: eventForm.logoUrl || undefined, + highlightVideoUrl: eventForm.highlightVideoUrl || undefined, }); setStatus('Event created successfully.'); await fetchEvents(); @@ -496,6 +517,7 @@ export const DashboardPage = ({ section = 'dashboard' }) => { try { await createLesson(token, selectedEventId, { title: lessonForm.title, + description: lessonForm.description || undefined, slug: lessonForm.slug, videoProvider: lessonForm.videoProvider, videoId: lessonForm.videoId || undefined, @@ -527,6 +549,7 @@ export const DashboardPage = ({ section = 'dashboard' }) => { setLessonForm({ title: selectedLesson.title ?? '', + description: selectedLesson.description ?? '', slug: selectedLesson.slug ?? '', videoProvider: selectedLesson.videoProvider ?? 'youtube', videoId: selectedLesson.videoId ?? '', @@ -548,6 +571,7 @@ export const DashboardPage = ({ section = 'dashboard' }) => { try { await updateLesson(token, selectedEventId, selectedLessonId, { title: lessonForm.title, + description: lessonForm.description, slug: lessonForm.slug, videoProvider: lessonForm.videoProvider, videoId: lessonForm.videoId, @@ -732,78 +756,74 @@ export const DashboardPage = ({ section = 'dashboard' }) => { } }; + const navItems = [ + { label: 'Dashboard', href: '/dashboard', active: isSectionActive(section, 'dashboard') }, + { label: 'Eventos', href: '/eventos', active: isSectionActive(section, 'eventos') }, + { label: 'Aulas', href: '/aulas', active: isSectionActive(section, 'aulas') }, + { label: 'Quizzes', href: '/quizzes', active: isSectionActive(section, 'quizzes') }, + ]; + return ( -
-
-
-

{pageTitles[section] ?? 'Admin Content Operations'}

-

Fluxo administrativo orientado por rotas do workflow oficial.

-
- -
- - - -
-
-

Runtime

-

- API base URL: {getApiBaseUrl()} -

-

- Signed in as {session?.user?.username ?? 'admin'} -

-
- -
-

Feedback

- {status ?

{status}

:

No recent actions.

} - {error ?

{error}

: null} -
-
+ + +

+ API base URL: {getApiBaseUrl()} +

+

+ Signed in as {session?.user?.username ?? 'admin'} +

+ + )} + right={( + <> + {status ?

{status}

:

No recent actions.

} + {error ?

{error}

: null} + + )} + /> {section === 'dashboard' ? ( -
-
-

Command Center

+

Use o menu para operar cada etapa com foco por contexto.

Abrir Eventos Abrir Aulas Abrir Quizzes
-
-
-

Selecao Atual

+ + )} + right={( + <>

Evento: {selectedEvent?.title ?? 'Nenhum'}

Aula: {selectedLesson?.title ?? 'Nenhuma'}

-
-
+ + )} + /> ) : null} {isEventosSection ? ( -
-
-

Events + Branding

+
{ value={eventForm.description} onChange={(event) => setEventForm({ ...eventForm, description: event.target.value })} /> +