update: fixing non tps

main
muamars 2026-03-17 16:49:34 +07:00
parent b95e93d3c2
commit 0390d630b3
1 changed files with 30 additions and 5 deletions

View File

@ -215,6 +215,31 @@ document.addEventListener('DOMContentLoaded', async function() {
const DETAIL_DATA_URL = "/driver/json/detail-penjemputan-non-tps.json"; const DETAIL_DATA_URL = "/driver/json/detail-penjemputan-non-tps.json";
const DEFAULT_TPS_NAME = "Lokasi Pengangkutan 1"; const DEFAULT_TPS_NAME = "Lokasi Pengangkutan 1";
function isBrowserFile(file) {
return file instanceof File;
}
function resolveStoredPhoto(file) {
return isBrowserFile(file) ? file : null;
}
function getStoredPhotoUrl(file) {
if (isBrowserFile(file)) return URL.createObjectURL(file);
if (typeof file === 'string') return file;
return '';
}
function getStoredPhotoName(file, defaultName = 'Foto') {
if (isBrowserFile(file)) return file.name;
if (typeof file === 'string') return file.split('/').pop() || defaultName;
return defaultName;
}
function getStoredPhotoSize(file) {
if (isBrowserFile(file)) return file.size;
return 0;
}
function initializeLocation() { function initializeLocation() {
tpsData = [{ tpsData = [{
name: DEFAULT_TPS_NAME, name: DEFAULT_TPS_NAME,
@ -540,7 +565,7 @@ document.addEventListener('DOMContentLoaded', async function() {
if (displayWaktu) displayWaktu.value = formatted; if (displayWaktu) displayWaktu.value = formatted;
getLocationUpdate(); getLocationUpdate();
saveState(); scheduleAutoSave();
} }
function reverseGeocode(lat, lng) { function reverseGeocode(lat, lng) {
@ -562,7 +587,7 @@ document.addEventListener('DOMContentLoaded', async function() {
if (latInput) latInput.value = lat; if (latInput) latInput.value = lat;
if (lngInput) lngInput.value = lng; if (lngInput) lngInput.value = lng;
} }
saveState(); scheduleAutoSave();
}) })
.catch(() => { .catch(() => {
tps.latitude = lat; tps.latitude = lat;
@ -576,7 +601,7 @@ document.addEventListener('DOMContentLoaded', async function() {
if (latInput) latInput.value = lat; if (latInput) latInput.value = lat;
if (lngInput) lngInput.value = lng; if (lngInput) lngInput.value = lng;
} }
saveState(); scheduleAutoSave();
}); });
} }
@ -943,7 +968,7 @@ document.addEventListener('DOMContentLoaded', async function() {
formatWeightDisplay(totalAnorganik); formatWeightDisplay(totalAnorganik);
if (grandTotalResiduDisplay) if (grandTotalResiduDisplay)
grandTotalResiduDisplay.textContent = formatWeightDisplay(totalResidu); grandTotalResiduDisplay.textContent = formatWeightDisplay(totalResidu);
saveState(); scheduleAutoSave();
} }
function getTimbanganUploadStateMarkup(hasFile, isUploaded, hasValidWeight) { function getTimbanganUploadStateMarkup(hasFile, isUploaded, hasValidWeight) {
@ -1250,7 +1275,7 @@ document.addEventListener('DOMContentLoaded', async function() {
if (itemIndex >= 0 && tps.timbangan[itemIndex]) { if (itemIndex >= 0 && tps.timbangan[itemIndex]) {
tps.timbangan[itemIndex].uploaded = false; tps.timbangan[itemIndex].uploaded = false;
refreshTimbanganUploadState(item); refreshTimbanganUploadState(item);
saveState(); scheduleAutoSave();
} }
} }
}); });