diff --git a/app/sites/[id]/journeys/page.tsx b/app/sites/[id]/journeys/page.tsx index 95a4ee5..25ebb3a 100644 --- a/app/sites/[id]/journeys/page.tsx +++ b/app/sites/[id]/journeys/page.tsx @@ -5,15 +5,15 @@ import { useParams } from 'next/navigation' import { getDateRange, formatDate } from '@ciphera-net/ui' import { Select, DatePicker } from '@ciphera-net/ui' import SankeyDiagram from '@/components/journeys/SankeyDiagram' -import TopPathsTable from '@/components/journeys/TopPathsTable' import { JourneysSkeleton, useMinimumLoading, useSkeletonFade } from '@/components/skeletons' import { useDashboard, useJourneyTransitions, - useJourneyTopPaths, useJourneyEntryPoints, } from '@/lib/swr/dashboard' +const DEPTH_STEPS = [2, 3, 4, 5, 6, 7, 8, 9, 10] + function getThisWeekRange(): { start: string; end: string } { const today = new Date() const dayOfWeek = today.getDay() @@ -38,12 +38,11 @@ export default function JourneysPage() { const [depth, setDepth] = useState(3) const [entryPath, setEntryPath] = useState('') + const sliderIndex = DEPTH_STEPS.indexOf(depth) + const { data: transitionsData, isLoading: transitionsLoading } = useJourneyTransitions( siteId, dateRange.start, dateRange.end, depth, 1, entryPath || undefined ) - const { data: topPaths, isLoading: topPathsLoading } = useJourneyTopPaths( - siteId, dateRange.start, dateRange.end, 20, 1, entryPath || undefined - ) const { data: entryPoints } = useJourneyEntryPoints(siteId, dateRange.start, dateRange.end) const { data: dashboard } = useDashboard(siteId, dateRange.start, dateRange.end) @@ -65,6 +64,8 @@ export default function JourneysPage() { if (showSkeleton) return + const totalSessions = transitionsData?.total_sessions ?? 0 + return (
{/* Header */} @@ -115,53 +116,72 @@ export default function JourneysPage() { />
- {/* Controls */} -
-
- - setDepth(Number(e.target.value))} - className="w-32 accent-brand-orange" - /> - {depth} + {/* Single card: toolbar + chart */} +
+ {/* Toolbar */} +
+
+ {/* Depth slider */} +
+
+ 2 steps + + {depth} steps deep + + 10 steps +
+ setDepth(DEPTH_STEPS[parseInt(e.target.value)])} + aria-label="Journey depth" + aria-valuetext={`${depth} steps deep`} + className="w-full h-2 bg-neutral-200 rounded-lg appearance-none cursor-pointer dark:bg-neutral-700 accent-brand-orange focus:outline-none focus:ring-2 focus:ring-brand-orange focus:ring-offset-2" + /> +
+ + {/* Entry point + Reset */} +
+ setEntryPath(value)} - options={entryPointOptions} - /> + {/* Sankey Diagram */} +
+ setEntryPath(path)} + /> +
- {(depth !== 3 || entryPath) && ( - + {/* Footer */} + {totalSessions > 0 && ( +
+ {totalSessions.toLocaleString()} sessions tracked +
)}
- {/* Sankey Diagram */} -
- setEntryPath(path)} - /> -
- - {/* Top Paths */} - - {/* Date Picker Modal */}