fix fetch link, add filterItineraryByCase method
This commit is contained in:
parent
2e163d526c
commit
b42b1ea410
@ -2,7 +2,7 @@ export function filterAddressesByCase() {
|
||||
if (!document.getElementById('case-filter').value) {
|
||||
return;
|
||||
}
|
||||
fetch('/index.php/api/filter-address-by-case/' + document.getElementById('case-filter').value, {
|
||||
fetch('/api/filter-address-by-case/' + document.getElementById('case-filter').value, {
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
@ -47,3 +47,52 @@ export function filterAddressesByCase() {
|
||||
});
|
||||
}
|
||||
|
||||
export function filterItineraryByCase() {
|
||||
let caseId = null;
|
||||
let startDate = null;
|
||||
let endDate = null;
|
||||
|
||||
if (document.getElementById('case-filter').value) {
|
||||
caseId = document.getElementById('case-filter').value;
|
||||
}
|
||||
|
||||
if (document.getElementById('start-date-filter').value) {
|
||||
startDate = document.getElementById('start-date-filter').value;
|
||||
}
|
||||
|
||||
if (document.getElementById('end-date-filter').value) {
|
||||
endDate = document.getElementById('end-date-filter').value;
|
||||
}
|
||||
|
||||
fetch('/api/filter-itinerary-by-case', {
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
caseId: caseId,
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
const itineraryList = document.getElementById('itineraryList');
|
||||
itineraryList.innerHTML = '';
|
||||
console.log(result);
|
||||
|
||||
result.forEach(i => {
|
||||
itineraryList.innerHTML += `
|
||||
<tr>
|
||||
<td>${i.date}</td>
|
||||
<td>${i.case}</td>
|
||||
<td>${i.origin.name}</td>
|
||||
<td>${i.destination.name}</td>
|
||||
<td>${i.duration}</td>
|
||||
<td>${i.distance}</td>
|
||||
<td></td>
|
||||
</tr>`;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user