From b4ea5927759e289a22e36567653e1102d0c75955 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Wed, 27 Aug 2025 13:29:15 -0400 Subject: [PATCH] archive backend --- backend/src/routes/applications.js | 2 +- .../src/pages/Applications/Applications.js | 44 ++----------------- 2 files changed, 5 insertions(+), 41 deletions(-) diff --git a/backend/src/routes/applications.js b/backend/src/routes/applications.js index 0398500..af941a0 100644 --- a/backend/src/routes/applications.js +++ b/backend/src/routes/applications.js @@ -885,7 +885,7 @@ router.put('/plans/:id/status', validateParams(idParamSchema), async (req, res, const planId = req.params.id; const { status } = req.body; - if (!['planned', 'in_progress', 'completed', 'cancelled'].includes(status)) { + if (!['planned', 'in_progress', 'completed', 'cancelled', 'archived'].includes(status)) { throw new AppError('Invalid status', 400); } diff --git a/frontend/src/pages/Applications/Applications.js b/frontend/src/pages/Applications/Applications.js index 238c68a..b85fd9b 100644 --- a/frontend/src/pages/Applications/Applications.js +++ b/frontend/src/pages/Applications/Applications.js @@ -216,36 +216,9 @@ const Applications = () => { } try { - // Try different possible status values that might work for archiving - const possibleArchiveStatuses = ['archived', 'hidden', 'inactive', 'done']; - - for (const status of possibleArchiveStatuses) { - try { - await applicationsAPI.updatePlanStatus(applicationId, status); - toast.success('Application archived successfully'); - fetchApplications(); // Refresh the list - return; - } catch (statusError) { - // Continue to next status if this one fails - console.log(`Status '${status}' failed, trying next...`); - } - } - - // If all status updates fail, we need to use a different approach - // Let's try updating the plan with a custom archived flag - const planResponse = await applicationsAPI.getPlan(applicationId); - const planData = planResponse.data.data.plan; - - // Update the plan with an archived flag - await applicationsAPI.updatePlan(applicationId, { - ...planData, - archived: true, - notes: planData.notes ? `${planData.notes} [ARCHIVED]` : '[ARCHIVED]' - }); - + await applicationsAPI.updatePlanStatus(applicationId, 'archived'); toast.success('Application archived successfully'); fetchApplications(); // Refresh the list - } catch (error) { console.error('Failed to archive application:', error); toast.error('Failed to archive application'); @@ -256,21 +229,12 @@ const Applications = () => { const filteredAndSortedApplications = React.useMemo(() => { let filtered = applications.filter(app => { // Hide archived applications unless specifically viewing archived ones - const isArchived = app.archived === true || - app.notes?.includes('[ARCHIVED]') || - ['archived', 'hidden', 'inactive', 'done'].includes(app.status); - - if (isArchived && filters.status !== 'archived') { + if (app.status === 'archived' && filters.status !== 'archived') { return false; } - // If filtering for archived, only show archived items - if (filters.status === 'archived' && !isArchived) { - return false; - } - - // Status filter (excluding archived since we handle it separately) - if (filters.status !== 'all' && filters.status !== 'archived' && app.status !== filters.status) { + // Status filter + if (filters.status !== 'all' && app.status !== filters.status) { return false; }