From 7fd7fa28ff535e85b6c7f71f7e93ade379f39e14 Mon Sep 17 00:00:00 2001 From: nicoagostini Date: Wed, 21 May 2025 13:56:56 -0700 Subject: [PATCH] fix/Router after editing fixed to plan/PlanId --- src/public/scripts/editPlanModals.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/public/scripts/editPlanModals.js b/src/public/scripts/editPlanModals.js index 55f9909..5c25837 100644 --- a/src/public/scripts/editPlanModals.js +++ b/src/public/scripts/editPlanModals.js @@ -49,8 +49,10 @@ document.addEventListener('DOMContentLoaded', () => { const result = await response.json(); if (response.ok && result.success) { - // alert('Plan updated successfully!'); // Optional: show an alert - window.location.href = `/plans/<%= plan._id %>`; // Redirect to plan detail page + const actionUrl = form.action; + const urlParts = actionUrl.split('/'); + const planId = urlParts[urlParts.length - 2]; + window.location.href = `/plans/${planId}`; } else { errorMessagesDiv.textContent = result.message || 'An error occurred while updating the plan.'; errorMessagesDiv.style.display = 'block';