fix/Router after editing fixed to plan/PlanId

This commit is contained in:
nicoagostini committed 2025-05-21 13:56:56 -07:00
1 parent 163cb73b9d
commit 7fd7fa28ff
1 file changed
+4 -2
+4 -2
View File
@@ -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';