diff --git a/frontend/src/pages/Applications/ApplicationPlan.js b/frontend/src/pages/Applications/ApplicationPlan.js index 98c2f2b..7cbc197 100644 --- a/frontend/src/pages/Applications/ApplicationPlan.js +++ b/frontend/src/pages/Applications/ApplicationPlan.js @@ -1,14 +1,9 @@ import React from 'react'; +import { Navigate } from 'react-router-dom'; const ApplicationPlan = () => { - return ( -
-

Plan Application

-
-

Application planning coming soon...

-
-
- ); + // Redirect legacy route to the Applications page with the plan modal open + return ; }; -export default ApplicationPlan; \ No newline at end of file +export default ApplicationPlan; diff --git a/frontend/src/pages/Applications/Applications.js b/frontend/src/pages/Applications/Applications.js index bcd53a4..549153a 100644 --- a/frontend/src/pages/Applications/Applications.js +++ b/frontend/src/pages/Applications/Applications.js @@ -1,4 +1,5 @@ import React, { useState, useEffect } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; import { PlusIcon, MapPinIcon, @@ -22,6 +23,8 @@ import ApplicationViewModal from '../../components/Applications/ApplicationViewM import toast from 'react-hot-toast'; const Applications = () => { + const location = useLocation(); + const navigate = useNavigate(); const [showPlanForm, setShowPlanForm] = useState(false); const [applications, setApplications] = useState([]); const [loading, setLoading] = useState(true); @@ -57,6 +60,18 @@ const Applications = () => { fetchPlanningData(); }, []); + // Open plan modal based on query param (?new=plan) + useEffect(() => { + const params = new URLSearchParams(location.search); + const shouldOpen = params.get('new') === 'plan'; + if (shouldOpen && !showPlanForm) { + setShowPlanForm(true); + // Clean URL so refresh doesn't keep reopening + navigate('/applications', { replace: true }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [location.search]); + const fetchApplications = async () => { try { const response = await applicationsAPI.getPlans(); diff --git a/frontend/src/pages/Dashboard/Dashboard.js b/frontend/src/pages/Dashboard/Dashboard.js index 7e333b3..2901869 100644 --- a/frontend/src/pages/Dashboard/Dashboard.js +++ b/frontend/src/pages/Dashboard/Dashboard.js @@ -35,7 +35,7 @@ const Dashboard = () => { }, { name: 'Plan Application', - href: '/applications/plan', + href: '/applications?new=plan', icon: CalendarDaysIcon, description: 'Schedule a treatment', color: 'bg-green-500',