feat(cortex): add intake_navigeer navigation handler (E5.S2)
- Add intake intents to action-parser schema and routing - Add navigation handler in command-center for intake_navigeer intent - Navigate to patient intakes page with toast feedback - Update bouwplan: E5 now complete (6/7 epics done) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,11 +17,13 @@
|
||||
*/
|
||||
|
||||
import { useEffect, useCallback, useRef } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { AnimatePresence } from 'framer-motion';
|
||||
import { useCortexStore } from '@/stores/cortex-store';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
|
||||
import { useMediaQuery } from '@/hooks/use-media-query';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { ContextBar } from './context-bar';
|
||||
import { OfflineBanner } from './offline-banner';
|
||||
import { NudgeToast } from './nudge-toast';
|
||||
@@ -31,14 +33,30 @@ import { ArtifactArea } from '../artifacts/artifact-area';
|
||||
import { getArtifactTitle } from '../artifacts/artifact-container';
|
||||
import { routeIntentToArtifact } from '@/lib/cortex/action-parser';
|
||||
import { isFeatureEnabled } from '@/lib/config/feature-flags';
|
||||
import type { ExtractedEntities } from '@/lib/cortex/types';
|
||||
|
||||
// Intake tab mapping for navigation
|
||||
const INTAKE_TAB_PATHS: Record<string, string> = {
|
||||
contacts: 'contacts',
|
||||
kindcheck: 'kindcheck',
|
||||
risk: 'risk',
|
||||
anamnese: 'anamnese',
|
||||
examination: 'examination',
|
||||
rom: 'rom',
|
||||
diagnosis: 'diagnosis',
|
||||
behandeladvies: 'behandeladvies',
|
||||
};
|
||||
|
||||
export function CommandCenter() {
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
const {
|
||||
closeAllArtifacts,
|
||||
openArtifacts,
|
||||
openArtifact,
|
||||
pendingAction,
|
||||
setPendingAction,
|
||||
activePatient,
|
||||
// Nudge state (E4)
|
||||
suggestions,
|
||||
acceptSuggestion,
|
||||
@@ -87,11 +105,55 @@ export function CommandCenter() {
|
||||
}, [handleKeyDown]);
|
||||
|
||||
// E3.S6 + E4.S2: Handle pending actions from chat (artifact opening)
|
||||
// E5.S2: Handle intake_navigeer navigation
|
||||
useEffect(() => {
|
||||
if (!pendingAction) return;
|
||||
|
||||
console.log('[CommandCenter] Processing pending action:', pendingAction);
|
||||
|
||||
// E5.S2: Handle intake_navigeer intent - navigate instead of opening artifact
|
||||
if (pendingAction.intent === 'intake_navigeer') {
|
||||
const entities = pendingAction.entities as ExtractedEntities;
|
||||
const navigationTarget = entities.navigationTarget;
|
||||
|
||||
if (!activePatient) {
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: 'Geen patiënt geselecteerd',
|
||||
description: 'Selecteer eerst een patiënt om te navigeren.',
|
||||
});
|
||||
setPendingAction(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// For now, we need an intake ID. Try to get it from entities or navigate to intakes list
|
||||
const tabPath = navigationTarget ? INTAKE_TAB_PATHS[navigationTarget] : null;
|
||||
|
||||
if (tabPath) {
|
||||
// Navigate to the patient's intakes page with a toast
|
||||
// Note: Full navigation to specific intake tab requires intakeId
|
||||
// For MVP, navigate to patient intakes page
|
||||
const url = `/epd/patients/${activePatient.id}/intakes`;
|
||||
|
||||
toast({
|
||||
title: 'Navigeren...',
|
||||
description: `Naar ${navigationTarget} sectie`,
|
||||
});
|
||||
|
||||
console.log('[CommandCenter] Navigating to:', url, 'target:', navigationTarget);
|
||||
router.push(url);
|
||||
} else {
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
title: 'Navigatie mislukt',
|
||||
description: 'Onbekende sectie. Probeer: risico, diagnose, anamnese.',
|
||||
});
|
||||
}
|
||||
|
||||
setPendingAction(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if action has artifact data
|
||||
if (pendingAction.artifact) {
|
||||
const { type, prefill } = pendingAction.artifact;
|
||||
@@ -130,7 +192,7 @@ export function CommandCenter() {
|
||||
}
|
||||
|
||||
setPendingAction(null);
|
||||
}, [pendingAction, openArtifact, setPendingAction]);
|
||||
}, [pendingAction, openArtifact, setPendingAction, activePatient, router, toast]);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-screen overflow-hidden">
|
||||
|
||||
Reference in New Issue
Block a user