Loading your agreements…
Checking for pending documents…
Checking opt-out status…

🚫 Report Discrimination

Use this form to report discrimination based on race, color, national origin, religion, sex, sexual orientation, disability, or other protected characteristics. Anti-discrimination reports receive priority 24-hour review.

⚠️ No automatic action will be taken on the accused user. Our team will review your report and supporting evidence within 24 hours before deciding on any action. Emergency restrictions may be applied only if evidence suggests immediate safety risk.
`); doc.close(); setTimeout(() => w.print(), 500); } function printDocument() { const content = document.getElementById('modalContent').textContent; const title = document.getElementById('modalTitle').textContent; const meta = document.getElementById('modalMeta').textContent; const w = window.open('', '_blank'); w.document.write(`${title}

RigSpot, a DBA of Stow In Storage LLC

${title} β€” ${meta}

${content}
`); w.document.close(); setTimeout(() => w.print(), 500); } // ─── Accept document modal ──────────────────────────────────────────────────── async function openAcceptModal(docType, docVersion) { try { const res = await fetch(`/api/legal/documents/${docType}/version/${docVersion}`); const data = await res.json(); if (!data.success) return; pendingDoc = data.document; document.getElementById('acceptModalTitle').textContent = `Review & Sign: ${data.document.title}`; document.getElementById('acceptModalMeta').textContent = `Version ${docVersion} β€” Effective ${new Date(data.document.effective_date).toLocaleDateString()}`; document.getElementById('acceptDocContent').textContent = data.document.content_text; document.getElementById('acceptCheckbox').checked = false; // Show company field for fleet_admin / lot_owner const needsCompany = currentUser && ['fleet_admin', 'lot_owner'].includes(currentUser.user_type); document.getElementById('companyFieldGroup').style.display = needsCompany ? 'block' : 'none'; updateSigPreview(); document.getElementById('acceptModal').classList.add('open'); } catch(e) { console.error(e); } } function updateSigPreview() { if (!currentUser || !pendingDoc) return; const name = currentUser.full_name || currentUser.email; const company = document.getElementById('acceptCompanyName')?.value?.trim(); let sig; if (company) { sig = `I, ${name}, on behalf of ${company}, accept RigSpot's ${pendingDoc.title} (Version ${pendingDoc.version}).`; } else { sig = `I, ${name}, accept RigSpot's ${pendingDoc.title} (Version ${pendingDoc.version}).`; } document.getElementById('acceptSigPreview').textContent = sig + ' By checking this box and clicking Sign & Accept, I understand this constitutes a legally binding electronic signature under the E-SIGN Act.'; } document.getElementById('acceptCompanyName')?.addEventListener('input', updateSigPreview); async function submitAcceptance() { if (!pendingDoc) return; if (!document.getElementById('acceptCheckbox').checked) { showAlert('acceptAlert', 'error', 'Please check the acceptance box to confirm your electronic signature.'); return; } const btn = document.getElementById('acceptSubmitBtn'); btn.disabled = true; btn.textContent = 'Signing…'; const company = document.getElementById('acceptCompanyName')?.value?.trim() || null; try { const res = await fetch('/api/legal/accept', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ doc_type: pendingDoc.doc_type, doc_version: pendingDoc.version, on_behalf_of_company: company, context: 're_acceptance' }) }); const data = await res.json(); if (data.success) { closeModal('acceptModal'); await Promise.all([loadSignedDocs(), loadPendingDocs()]); pendingDoc = null; } else { showAlert('acceptAlert', 'error', data.message || 'Failed to record acceptance.'); } } catch(e) { showAlert('acceptAlert', 'error', 'Network error. Please try again.'); } btn.disabled = false; btn.textContent = 'Sign & Accept'; } // ─── Discrimination report ──────────────────────────────────────────────────── async function submitReport(e) { e.preventDefault(); const desc = document.getElementById('reportDesc').value.trim(); const accused = document.getElementById('accusedId').value.trim(); const evidence = document.getElementById('reportEvidence').value.trim(); if (desc.length < 20) { showAlert('reportAlert', 'error', 'Please provide a more detailed description (at least 20 characters).'); return; } const btn = e.target.querySelector('button[type=submit]'); btn.disabled = true; btn.textContent = 'Submitting…'; try { const res = await fetch('/api/reports/discrimination', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ accused_identifier: accused || undefined, description: desc, evidence_text: evidence || undefined }) }); const data = await res.json(); if (data.success) { document.getElementById('reportForm').style.display = 'none'; document.getElementById('reportSuccess').style.display = 'block'; document.getElementById('reportRef').textContent = `Report Reference: #${data.report_id}`; } else { showAlert('reportAlert', 'error', data.message || 'Failed to submit report.'); btn.disabled = false; btn.textContent = 'Submit Priority Report'; } } catch(e) { showAlert('reportAlert', 'error', 'Network error. Please try again.'); btn.disabled = false; btn.textContent = 'Submit Priority Report'; } } // ─── Utils ──────────────────────────────────────────────────────────────────── function switchTab(name, btn) { document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active')); btn.classList.add('active'); document.getElementById('tab-' + name).classList.add('active'); } function closeModal(id) { document.getElementById(id).classList.remove('open'); } function showAlert(id, type, msg) { const el = document.getElementById(id); el.className = 'alert ' + type; el.textContent = msg; el.style.display = 'block'; } function logout() { localStorage.removeItem('user_token'); localStorage.removeItem('token'); window.location.href = '/driver-login.html'; } // Close modals on overlay click document.querySelectorAll('.modal-overlay').forEach(overlay => { overlay.addEventListener('click', e => { if (e.target === overlay) overlay.classList.remove('open'); }); }); init();