FIX_SalesTracker7
This commit is contained in:
parent
6387d2ef79
commit
294cb0b163
@ -461,6 +461,7 @@ function closeModal(id) {
|
||||
selectedType = 'Call';
|
||||
$('#typeButtons .d_activity_type').removeClass('active');
|
||||
$('#typeButtons .d_activity_type[data-type="Call"]').addClass('active');
|
||||
fetchActivities(); // now i called because of Refresh the page .......
|
||||
}
|
||||
|
||||
// Specific cleanup for "Complete" modal (hidden follow-up sections)
|
||||
@ -652,7 +653,6 @@ async function fetchActivities(isLoadMore = false) {
|
||||
|
||||
// 2. Detail Logic
|
||||
async function viewDetail(id) {
|
||||
console.log("i am here");
|
||||
lead_id = id;
|
||||
let res = await fetch(`${API}/leads/${id}`);
|
||||
let json = await res.json();
|
||||
@ -740,6 +740,7 @@ function renderCard(opps) {
|
||||
|
||||
function renderTimeline(acts) {
|
||||
const cont = document.getElementById('timelineContainer');
|
||||
|
||||
|
||||
if (acts.length === 0) {
|
||||
cont.classList.add('no-line');
|
||||
@ -786,6 +787,7 @@ function renderTimeline(acts) {
|
||||
}
|
||||
|
||||
function openActivityModal() {
|
||||
|
||||
document.getElementById('act_owner').value = global_lead_assigned_to;
|
||||
document.getElementById('act_owner').dispatchEvent(new Event('change'));
|
||||
document.getElementById('act_lead_id').value = lead_id;
|
||||
@ -908,7 +910,7 @@ document.getElementById('activityForm').onsubmit = async (e) => {
|
||||
toastr.success('Activity Created Successfully');
|
||||
closeModal('activityModal');
|
||||
if (flag === "frompopup") {
|
||||
viewDetail(document.getElementById('act_lead_id').value);
|
||||
viewDetail(actLead);
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
@ -1607,7 +1607,7 @@ if (btnSaveContact) {
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
const result = await res.json(); // Get the response body
|
||||
const contactResult = await res.json(); // Get the response body
|
||||
|
||||
if (res.ok) {
|
||||
// Clear inputs
|
||||
@ -1620,16 +1620,16 @@ if (btnSaveContact) {
|
||||
|
||||
// Create the HTML string
|
||||
let contactHtml = `
|
||||
<div class="contact-card d-flex justify-content-between align-items-center mb-2 p-2"
|
||||
<div class="contact-card d-flex justify-content-between align-items-center mb-2 p-3"
|
||||
style="background: #f8f8f8; border-radius: 8px;"
|
||||
data-id="${result.data.contact_id}">
|
||||
data-id="${contactResult.data.contact_id}">
|
||||
<div>
|
||||
<div class="fw-bold">${result.data.name}</div>
|
||||
<div class="text-muted">${result.data.mobile}</div>
|
||||
<div class="fw-bold">${contactResult.data.name}</div>
|
||||
<div class="text-muted">${contactResult.data.mobile}</div>
|
||||
</div>
|
||||
<button type="button"
|
||||
class="btn btn-danger btn-sm btnRemoveContact"
|
||||
data-id="${result.data.contact_id}">
|
||||
data-id="${contactResult.data.contact_id}">
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
@ -1637,19 +1637,19 @@ if (btnSaveContact) {
|
||||
|
||||
// <button type="button"
|
||||
// class="btn btn-secondary btn-sm btnEditContact"
|
||||
// data-id="${result.data.contact_id}">
|
||||
// data-id="${contactResult.data.contact_id}">
|
||||
// Update
|
||||
// </button>
|
||||
// Append to container using Vanilla JS
|
||||
document.getElementById('savedContactsContainer').insertAdjacentHTML('beforeend', contactHtml);
|
||||
toastr.success('Contact saved successfully');
|
||||
} else {
|
||||
let err = await res.json();
|
||||
|
||||
if (res.status === 400) {
|
||||
let errorMessages = "";
|
||||
let seenMessages = [];
|
||||
if (err.messages) {
|
||||
Object.entries(err.messages).forEach(([field, message]) => {
|
||||
if (contactResult.messages) {
|
||||
Object.entries(contactResult.messages).forEach(([field, message]) => {
|
||||
let inputElement = $('[name="' + field + '"]');
|
||||
|
||||
if (inputElement.length > 0) {
|
||||
@ -1673,11 +1673,11 @@ if (btnSaveContact) {
|
||||
});
|
||||
toastr.error(errorMessages, 'Validation Error', { allowHtml: true });
|
||||
} else {
|
||||
toastr.warning(err.message || 'Validation failed', 'Warning');
|
||||
toastr.warning(contactResult.message || 'Validation failed', 'Warning');
|
||||
}
|
||||
}
|
||||
else {
|
||||
toastr.error(err.message || 'Error adding lead');
|
||||
toastr.error(contactResult.message || 'Error adding lead');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user