11import { useEffect , useRef } from 'react' ;
2- import { useDispatch , useSelector } from 'react-redux' ;
32import { Outlet , useLocation } from 'react-router-dom' ;
43import { AppShell } from '@mantine/core' ;
54import { spacing } from '@/designTokens' ;
6- import { useIngredientReset } from '@/hooks/useIngredientReset' ;
7- import { clearFlow } from '@/reducers/flowReducer' ;
8- import { RootState } from '@/store' ;
95import { cacheMonitor } from '@/utils/cacheMonitor' ;
106import HeaderNavigation from './shared/HomeHeader' ;
117import LegacyBanner from './shared/LegacyBanner' ;
128import Sidebar from './Sidebar' ;
139
1410export default function Layout ( ) {
15- const dispatch = useDispatch ( ) ;
16- const { currentFrame, currentFlow } = useSelector ( ( state : RootState ) => state . flow ) ;
17- const { resetIngredient } = useIngredientReset ( ) ;
1811 const location = useLocation ( ) ;
1912 const previousLocation = useRef ( location . pathname ) ;
2013
21- // Log navigation events for cache monitoring and handle flow clearing
14+ // Log navigation events for cache monitoring
2215 useEffect ( ( ) => {
2316 const from = previousLocation . current ;
2417 const to = location . pathname ;
@@ -27,34 +20,10 @@ export default function Layout() {
2720 console . log ( '[Layout] ========== NAVIGATION DETECTED ==========' ) ;
2821 console . log ( '[Layout] From:' , from ) ;
2922 console . log ( '[Layout] To:' , to ) ;
30- console . log ( '[Layout] currentFlow:' , currentFlow ) ;
3123 cacheMonitor . logNavigation ( from , to ) ;
32-
33- // Clear flow and all ingredients when navigating away from /create routes
34- if ( currentFlow && from . includes ( '/create' ) && ! to . includes ( '/create' ) ) {
35- console . log ( '[Layout] Condition met: clearing flow and ingredients' ) ;
36- console . log ( '[Layout] - currentFlow exists:' , ! ! currentFlow ) ;
37- console . log ( '[Layout] - from.includes("/create"):' , from . includes ( '/create' ) ) ;
38- console . log ( '[Layout] - !to.includes("/create"):' , ! to . includes ( '/create' ) ) ;
39- dispatch ( clearFlow ( ) ) ;
40- console . log ( '[Layout] Dispatched clearFlow()' ) ;
41- resetIngredient ( 'report' ) ; // Cascades to clear all ingredients
42- console . log ( '[Layout] Called resetIngredient("report")' ) ;
43- } else {
44- console . log ( '[Layout] Condition NOT met - no clearing' ) ;
45- console . log ( '[Layout] - currentFlow exists:' , ! ! currentFlow ) ;
46- console . log ( '[Layout] - from.includes("/create"):' , from . includes ( '/create' ) ) ;
47- console . log ( '[Layout] - !to.includes("/create"):' , ! to . includes ( '/create' ) ) ;
48- }
49-
5024 previousLocation . current = to ;
5125 }
52- } , [ location . pathname , currentFlow , dispatch ] ) ;
53-
54- // If PolicyParameterSelectorFrame is active, let it manage its own layout completely
55- if ( currentFrame === 'PolicyParameterSelectorFrame' ) {
56- return < Outlet /> ;
57- }
26+ } , [ location . pathname ] ) ;
5827
5928 // Otherwise, render the normal layout with AppShell
6029 return (
0 commit comments