Add Disconnect button to Strava section of upload modal

This commit is contained in:
Davide Scaini
2026-05-10 17:12:55 +02:00
parent 1eaf5c4e0b
commit 14313ec59c
+25
View File
@@ -402,6 +402,11 @@ try {
class="flex-1 py-1.5 px-3 rounded-lg text-xs bg-zinc-800 hover:bg-zinc-700 text-zinc-400 hover:text-zinc-200 transition-colors"
title="Clear sync point — next sync re-checks all Strava activities"
>Hard reset</button>
<button
id="strava-disconnect-modal-btn"
class="flex-1 py-1.5 px-3 rounded-lg text-xs bg-zinc-800 hover:bg-red-900 text-zinc-400 hover:text-red-300 transition-colors"
title="Disconnect from Strava — you will need to reconnect via OAuth"
>Disconnect</button>
</div>
</div>
<p id="strava-status" class="mt-3 text-xs text-center" style="min-height: 1.25rem"></p>
@@ -934,6 +939,26 @@ try {
stravaResetSoftBtn.addEventListener('click', () => stravaReset('soft'));
stravaResetHardBtn.addEventListener('click', () => stravaReset('hard'));
document.getElementById('strava-disconnect-modal-btn')?.addEventListener('click', async () => {
if (!confirm('Disconnect from Strava? You will need to reconnect via OAuth to re-enable sync.')) return;
try {
const r = await fetch(`${editUrl}/api/strava/disconnect`, { method: 'POST', credentials: 'include' });
if (r.ok) {
stravaStatus.textContent = 'Disconnected.';
stravaStatus.style.color = '#4ade80';
stravaConnect.style.display = '';
stravaSync.style.display = 'none';
} else {
const d = await r.json();
stravaStatus.textContent = d.detail ?? 'Failed to disconnect.';
stravaStatus.style.color = '#f87171';
}
} catch {
stravaStatus.textContent = 'Could not reach server.';
stravaStatus.style.color = '#f87171';
}
});
// ── Strava ZIP upload ─────────────────────────────────────────────────
function doZipUpload(file) {
if (!file) return;