Skip to content

Commit 2afcaaa

Browse files
committed
Updated Projects Flow
1 parent 828ff67 commit 2afcaaa

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/pages/Projects.jsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,6 @@ const Projects = () => {
2929
error: projectsError,
3030
} = useGetProjects();
3131

32-
// Initialize project data and hooks
33-
useEffect(() => {
34-
// Simplified loading logic to avoid extra state updates
35-
if (!projectsLoading) {
36-
setIsLoading(false);
37-
}
38-
39-
// Check for direct project link in URL
40-
const urlParams = new URLSearchParams(location.search);
41-
const projectId = urlParams.get('project');
42-
if (projectId && projectsData && projectsData.length > 0) {
43-
handleViewDetails(projectId);
44-
}
45-
}, [projectsLoading, projectsData, location.search, handleViewDetails]);
46-
4732
// Project filtering hook
4833
const {
4934
filteredProjects,
@@ -66,7 +51,7 @@ const Projects = () => {
6651
returnToGallery,
6752
} = useProjectDetail();
6853

69-
// Handle view project details with proper navigation
54+
// Handle view project details with proper navigation - DEFINE THIS BEFORE useEffect
7055
const handleViewDetails = useCallback(
7156
(projectId, action = 'page') => {
7257
if (action === 'reset') {
@@ -91,6 +76,21 @@ const Projects = () => {
9176
[navigate, resetFilters, openProjectModal, projectsData, viewProjectDetails]
9277
);
9378

79+
// Initialize project data and hooks - NOW handleViewDetails EXISTS when this runs
80+
useEffect(() => {
81+
// Simplified loading logic to avoid extra state updates
82+
if (!projectsLoading) {
83+
setIsLoading(false);
84+
}
85+
86+
// Check for direct project link in URL
87+
const urlParams = new URLSearchParams(location.search);
88+
const projectId = urlParams.get('project');
89+
if (projectId && projectsData && projectsData.length > 0) {
90+
handleViewDetails(projectId);
91+
}
92+
}, [projectsLoading, projectsData, location.search, handleViewDetails]);
93+
9494
// Handle back to gallery
9595
const handleBackToGallery = () => {
9696
// Update URL to remove project parameter

0 commit comments

Comments
 (0)