Drop-Off & Pickup Point Locator

Drop-Off & Pickup Point Locator

Find convenient locations near you.

${selectedLocation.address}

Operating Hours:

${selectedLocation.hours}

` : `

Select a location to see details

Click on an item from the list on the left.

`; dashboardContent.innerHTML = `
    ${locationsListHtml}
${detailsHtml}
`; attachDashboardListeners(); lucide.createIcons(); }; const attachDashboardListeners = () => { document.getElementById('search-input').addEventListener('input', e => { appData.filters.search = e.target.value; renderDashboard(); }); document.getElementById('type-filter').addEventListener('change', e => { appData.filters.type = e.target.value; renderDashboard(); }); document.querySelectorAll('.location-item').forEach(item => { item.addEventListener('click', e => { appData.selectedLocationId = parseInt(e.currentTarget.dataset.id); renderDashboard(); }); }); }; const renderConfig = () => { const configContent = document.getElementById('content-configuration'); if (!configContent) return; const locationsHtml = appData.locations.map(loc => `
`).join(''); configContent.innerHTML = `

Manage Locations

${locationsHtml}
`; attachConfigListeners(); }; const attachConfigListeners = () => { document.getElementById('add-loc-btn').addEventListener('click', () => { const newId = appData.locations.length > 0 ? Math.max(...appData.locations.map(l => l.id)) + 1 : 1; appData.locations.push({ id: newId, name: 'New Location', address: '', hours: '', type: 'Locker' }); renderConfig(); lucide.createIcons(); }); document.getElementById('locations-container').addEventListener('click', e => { if (e.target.closest('.remove-loc-btn')) { const locId = parseInt(e.target.closest('.remove-loc-btn').dataset.id); appData.locations = appData.locations.filter(l => l.id !== locId); renderConfig(); } }); document.getElementById('update-btn').addEventListener('click', handleConfigUpdate); }; const handleConfigUpdate = () => { appData.locations = Array.from(document.querySelectorAll('.location-row')).map(row => { const id = parseInt(row.querySelector('input').dataset.id); return { id, name: row.querySelector('[data-field="name"]').value, address: row.querySelector('[data-field="address"]').value, type: row.querySelector('[data-field="type"]').value, hours: row.querySelector('[data-field="hours"]').value, }; }); appData.selectedLocationId = null; // Deselect renderDashboard(); alert('Locations saved!'); switchTab(0); }; const generatePdf = () => { // For this tool, the PDF will be a list of the currently filtered locations. const pdfContent = document.createElement('div'); pdfContent.innerHTML = `

Drop-Off & Pickup Locations

Generated on ${new Date().toLocaleDateString()}

${document.getElementById('locations-list').innerHTML}
`; pdfContent.querySelectorAll('li').forEach(li => { li.classList.add('p-4', 'border-b'); li.style.backgroundColor = 'white'; // Remove hover/active styles }); document.body.appendChild(pdfContent); loadingOverlay.style.display = 'flex'; html2canvas(pdfContent, { scale: 2 }) .then(canvas => { const { jsPDF } = window.jspdf; const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight); pdf.save('pickup-locations.pdf'); loadingOverlay.style.display = 'none'; document.body.removeChild(pdfContent); }).catch(err => { loadingOverlay.style.display = 'none'; document.body.removeChild(pdfContent); }); }; // --- TAB NAVIGATION & INITIALIZATION --- const switchTab = (tabIndex) => { activeTabIndex = tabIndex; document.querySelectorAll('.tab-btn').forEach((btn, i) => btn.classList.toggle('active', i === tabIndex)); document.querySelectorAll('.tab-content').forEach((content, i) => content.classList.toggle('hidden', i !== tabIndex)); updateNavButtons(); }; const updateNavButtons = () => { prevTabBtn.disabled = activeTabIndex === 0; nextTabBtn.disabled = activeTabIndex === tabIdentifiers.length - 1; }; const initializeUI = () => { const tabs = [ { name: 'Location Finder', id: 'locator-dashboard' }, { name: 'Configuration', id: 'configuration' } ]; tabIdentifiers = tabs.map(t => t.id); tabsContainer.innerHTML = tabs.map(tab => ``).join(''); mainContent.innerHTML = tabs.map(tab => `
`).join(''); tabs.forEach((tab, index) => document.getElementById(`tab-${tab.id}`).addEventListener('click', () => switchTab(index))); renderDashboard(); renderConfig(); switchTab(0); }; initializeUI(); prevTabBtn.addEventListener('click', () => { if (activeTabIndex > 0) switchTab(activeTabIndex - 1); }); nextTabBtn.addEventListener('click', () => { if (activeTabIndex < tabIdentifiers.length - 1) switchTab(activeTabIndex + 1); }); });
Scroll to Top