fix(trip): redirect to plan tab when active tab's addon is disabled
If a user's last visited tab belongs to an addon that gets disabled while they are away, re-opening the trip now resets the active tab to 'plan' instead of rendering the inaccessible addon page. Closes #441
This commit is contained in:
@@ -137,6 +137,14 @@ export default function TripPlannerPage(): React.ReactElement | null {
|
|||||||
return saved || 'plan'
|
return saved || 'plan'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const validTabIds = TRIP_TABS.map(t => t.id)
|
||||||
|
if (!validTabIds.includes(activeTab)) {
|
||||||
|
setActiveTab('plan')
|
||||||
|
sessionStorage.setItem(`trip-tab-${tripId}`, 'plan')
|
||||||
|
}
|
||||||
|
}, [enabledAddons])
|
||||||
|
|
||||||
const handleTabChange = (tabId: string): void => {
|
const handleTabChange = (tabId: string): void => {
|
||||||
setActiveTab(tabId)
|
setActiveTab(tabId)
|
||||||
sessionStorage.setItem(`trip-tab-${tripId}`, tabId)
|
sessionStorage.setItem(`trip-tab-${tripId}`, tabId)
|
||||||
|
|||||||
Reference in New Issue
Block a user