archive backend

This commit is contained in:
Jake Kasper
2025-08-27 13:29:15 -04:00
parent 8421e692ec
commit b4ea592775
2 changed files with 5 additions and 41 deletions

View File

@@ -885,7 +885,7 @@ router.put('/plans/:id/status', validateParams(idParamSchema), async (req, res,
const planId = req.params.id; const planId = req.params.id;
const { status } = req.body; 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); throw new AppError('Invalid status', 400);
} }

View File

@@ -216,36 +216,9 @@ const Applications = () => {
} }
try { try {
// Try different possible status values that might work for archiving await applicationsAPI.updatePlanStatus(applicationId, 'archived');
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]'
});
toast.success('Application archived successfully'); toast.success('Application archived successfully');
fetchApplications(); // Refresh the list fetchApplications(); // Refresh the list
} catch (error) { } catch (error) {
console.error('Failed to archive application:', error); console.error('Failed to archive application:', error);
toast.error('Failed to archive application'); toast.error('Failed to archive application');
@@ -256,21 +229,12 @@ const Applications = () => {
const filteredAndSortedApplications = React.useMemo(() => { const filteredAndSortedApplications = React.useMemo(() => {
let filtered = applications.filter(app => { let filtered = applications.filter(app => {
// Hide archived applications unless specifically viewing archived ones // Hide archived applications unless specifically viewing archived ones
const isArchived = app.archived === true || if (app.status === 'archived' && filters.status !== 'archived') {
app.notes?.includes('[ARCHIVED]') ||
['archived', 'hidden', 'inactive', 'done'].includes(app.status);
if (isArchived && filters.status !== 'archived') {
return false; return false;
} }
// If filtering for archived, only show archived items // Status filter
if (filters.status === 'archived' && !isArchived) { if (filters.status !== 'all' && app.status !== filters.status) {
return false;
}
// Status filter (excluding archived since we handle it separately)
if (filters.status !== 'all' && filters.status !== 'archived' && app.status !== filters.status) {
return false; return false;
} }