dashbaord
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
|
||||
const ApplicationPlan = () => {
|
||||
return (
|
||||
<div className="p-6">
|
||||
<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>
|
||||
);
|
||||
// Redirect legacy route to the Applications page with the plan modal open
|
||||
return <Navigate to="/applications?new=plan" replace />;
|
||||
};
|
||||
|
||||
export default ApplicationPlan;
|
||||
@@ -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();
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user