dashbaord
This commit is contained in:
@@ -1,14 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Navigate } from 'react-router-dom';
|
||||||
|
|
||||||
const ApplicationPlan = () => {
|
const ApplicationPlan = () => {
|
||||||
return (
|
// Redirect legacy route to the Applications page with the plan modal open
|
||||||
<div className="p-6">
|
return <Navigate to="/applications?new=plan" replace />;
|
||||||
<h1 className="text-2xl font-bold text-gray-900 mb-6">Plan Application</h1>
|
|
||||||
<div className="card">
|
|
||||||
<p className="text-gray-600">Application planning coming soon...</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ApplicationPlan;
|
export default ApplicationPlan;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
MapPinIcon,
|
MapPinIcon,
|
||||||
@@ -22,6 +23,8 @@ import ApplicationViewModal from '../../components/Applications/ApplicationViewM
|
|||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
const Applications = () => {
|
const Applications = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [showPlanForm, setShowPlanForm] = useState(false);
|
const [showPlanForm, setShowPlanForm] = useState(false);
|
||||||
const [applications, setApplications] = useState([]);
|
const [applications, setApplications] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -57,6 +60,18 @@ const Applications = () => {
|
|||||||
fetchPlanningData();
|
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 () => {
|
const fetchApplications = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await applicationsAPI.getPlans();
|
const response = await applicationsAPI.getPlans();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const Dashboard = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Plan Application',
|
name: 'Plan Application',
|
||||||
href: '/applications/plan',
|
href: '/applications?new=plan',
|
||||||
icon: CalendarDaysIcon,
|
icon: CalendarDaysIcon,
|
||||||
description: 'Schedule a treatment',
|
description: 'Schedule a treatment',
|
||||||
color: 'bg-green-500',
|
color: 'bg-green-500',
|
||||||
|
|||||||
Reference in New Issue
Block a user