diff --git a/wwwroot/driver/js/detail-penjemputan-non-tps.js b/wwwroot/driver/js/detail-penjemputan-non-tps.js index 1804d59..387cc08 100644 --- a/wwwroot/driver/js/detail-penjemputan-non-tps.js +++ b/wwwroot/driver/js/detail-penjemputan-non-tps.js @@ -215,6 +215,31 @@ document.addEventListener('DOMContentLoaded', async function() { const DETAIL_DATA_URL = "/driver/json/detail-penjemputan-non-tps.json"; 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() { tpsData = [{ name: DEFAULT_TPS_NAME, @@ -540,7 +565,7 @@ document.addEventListener('DOMContentLoaded', async function() { if (displayWaktu) displayWaktu.value = formatted; getLocationUpdate(); - saveState(); + scheduleAutoSave(); } function reverseGeocode(lat, lng) { @@ -562,7 +587,7 @@ document.addEventListener('DOMContentLoaded', async function() { if (latInput) latInput.value = lat; if (lngInput) lngInput.value = lng; } - saveState(); + scheduleAutoSave(); }) .catch(() => { tps.latitude = lat; @@ -576,7 +601,7 @@ document.addEventListener('DOMContentLoaded', async function() { if (latInput) latInput.value = lat; if (lngInput) lngInput.value = lng; } - saveState(); + scheduleAutoSave(); }); } @@ -943,7 +968,7 @@ document.addEventListener('DOMContentLoaded', async function() { formatWeightDisplay(totalAnorganik); if (grandTotalResiduDisplay) grandTotalResiduDisplay.textContent = formatWeightDisplay(totalResidu); - saveState(); + scheduleAutoSave(); } function getTimbanganUploadStateMarkup(hasFile, isUploaded, hasValidWeight) { @@ -1250,7 +1275,7 @@ document.addEventListener('DOMContentLoaded', async function() { if (itemIndex >= 0 && tps.timbangan[itemIndex]) { tps.timbangan[itemIndex].uploaded = false; refreshTimbanganUploadState(item); - saveState(); + scheduleAutoSave(); } } });