diff --git a/frontend/src/lib/MapBarItem.svelte b/frontend/src/lib/MapBarItem.svelte index 2a50538..1475220 100644 --- a/frontend/src/lib/MapBarItem.svelte +++ b/frontend/src/lib/MapBarItem.svelte @@ -2,10 +2,11 @@ import type { LocationResponse, WhoResponse } from '../models/schemas' import { user } from '$lib/stores' import Checkmark from './Checkmark.svelte' - import { visitBar } from '../api/bars' + import { visitBar, deleteVisit } from '../api/bars' export let bar: LocationResponse export let onVisitCallback: CallableFunction + export let onDeleteVisitCallback: CallableFunction let isLoggedIn: boolean = false @@ -13,11 +14,16 @@ isLoggedIn = value !== undefined }) - function handleVisitBar() { - if (bar.visited_at) { - // TODO: Remove visit - return + function handleDeleteBarVisit() { + if (confirm(`Are you sure you want to remove your visit to ${bar.name}?`)) { + deleteVisit(bar.id).then(() => { + bar.visited_at = null + onDeleteVisitCallback() + }) } + } + + function handleVisitBar() { visitBar(bar.id).then(() => { bar.visited_at = new Date().toISOString() onVisitCallback() @@ -32,7 +38,9 @@ {#if isLoggedIn}