fix/Router after editing fixed to plan/PlanId
This commit is contained in:
1 parent
163cb73b9d
commit
7fd7fa28ff
1 file changed
+4
-2
@@ -49,8 +49,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
|
||||||
if (response.ok && result.success) {
|
if (response.ok && result.success) {
|
||||||
// alert('Plan updated successfully!'); // Optional: show an alert
|
const actionUrl = form.action;
|
||||||
window.location.href = `/plans/<%= plan._id %>`; // Redirect to plan detail page
|
const urlParts = actionUrl.split('/');
|
||||||
|
const planId = urlParts[urlParts.length - 2];
|
||||||
|
window.location.href = `/plans/${planId}`;
|
||||||
} else {
|
} else {
|
||||||
errorMessagesDiv.textContent = result.message || 'An error occurred while updating the plan.';
|
errorMessagesDiv.textContent = result.message || 'An error occurred while updating the plan.';
|
||||||
errorMessagesDiv.style.display = 'block';
|
errorMessagesDiv.style.display = 'block';
|
||||||
|
|||||||
Reference in new issue
Block a user