feat(dashboard): route conversations and media
This commit is contained in:
1 parent
768470204b
commit
20fa83f245
2 files changed
+27
-2
No files matched your search
@@ -2,6 +2,8 @@ import { createBrowserRouter, type RouteObject } from 'react-router-dom';
|
||||
import { AppShell } from './app-shell.js';
|
||||
import { OverviewPage } from '../features/overview/overview-page.js';
|
||||
import { PlaceholderPage } from '../features/placeholder-page.js';
|
||||
import { ConversationRoute } from '../features/conversations/conversation-route.js';
|
||||
import { MediaPage } from '../features/media/media-page.js';
|
||||
|
||||
export function createDashboardRoutes(): RouteObject[] {
|
||||
return [
|
||||
@@ -10,8 +12,9 @@ export function createDashboardRoutes(): RouteObject[] {
|
||||
element: <AppShell />,
|
||||
children: [
|
||||
{ index: true, element: <OverviewPage /> },
|
||||
{ path: 'conversations', element: <PlaceholderPage title="Conversations" description="Review conversations, drafts, and replies." /> },
|
||||
{ path: 'media', element: <PlaceholderPage title="Media" description="Browse private media and monitor syncs." /> },
|
||||
{ path: 'conversations', element: <ConversationRoute /> },
|
||||
{ path: 'conversations/:conversationId', element: <ConversationRoute /> },
|
||||
{ path: 'media', element: <MediaPage /> },
|
||||
{ path: 'performance', element: <PlaceholderPage title="Performance" description="Understand response and strategy performance." /> },
|
||||
{ path: 'operations', element: <PlaceholderPage title="Operations" description="Inspect jobs, events, logs, and diagnostics." /> },
|
||||
{ path: 'settings', element: <PlaceholderPage title="Settings" description="Manage runtime behavior and Reddit access." /> },
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { ConversationsPage } from './conversations-page.js';
|
||||
|
||||
export function ConversationRoute() {
|
||||
const navigate = useNavigate();
|
||||
const { conversationId } = useParams<{ conversationId: string }>();
|
||||
|
||||
function selectConversation(nextConversationId: string | null) {
|
||||
void navigate(
|
||||
nextConversationId
|
||||
? `/conversations/${encodeURIComponent(nextConversationId)}`
|
||||
: '/conversations',
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ConversationsPage
|
||||
selectedConversationId={conversationId ?? null}
|
||||
onSelectedConversationChange={selectConversation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user