diff --git a/frontend/src/api/bars.ts b/frontend/src/api/bars.ts index ccdd3f6..b6f02a7 100644 --- a/frontend/src/api/bars.ts +++ b/frontend/src/api/bars.ts @@ -8,6 +8,9 @@ export async function get_bars(): Promise { export async function visitBar(id: number): Promise { return fetch(get_api_base_url() + '/visit/bar/' + id, { - method: 'POST' + method: 'POST', + headers: { + Accept: 'application/json' + } }) } diff --git a/frontend/src/lib/BarItem.svelte b/frontend/src/lib/BarItem.svelte index aa1e5e0..cba4e05 100644 --- a/frontend/src/lib/BarItem.svelte +++ b/frontend/src/lib/BarItem.svelte @@ -3,6 +3,7 @@ import { localDate } from '$lib/time' import { user } from '$lib/stores' import { visitBar } from '../api/bars' + import Checkmark from './Checkmark.svelte' export let bar: LocationResponse export let isLoggedIn: boolean = false @@ -10,8 +11,12 @@ const placeholder = 'https://images.jan.tf/ecmAqc89DiQEu0HlPMBcNxDFyigWMJI-xUJCNJAbklQ/fill/512/512/no/1/bG9jYWw6Ly8vYmFyLXBsYWNlaG9sZGVyLnBuZw.jpg' - function handleVisitBar(id: number) { - visitBar(id).then(() => { + function handleVisitBar() { + if (bar.visited_at) { + // TODO: Remove visit + return + } + visitBar(bar.id).then(() => { bar.visited_at = new Date().toISOString() }) } @@ -22,11 +27,19 @@

{bar.name}

{bar.description ?? 'No Description'}

- {#if bar.visited_at && isLoggedIn} -

Visited on: {localDate(bar.visited_at)}

- {:else if isLoggedIn} + {#if isLoggedIn}

- +

{/if}
@@ -51,4 +64,30 @@ object-fit: cover; align-self: center; } + + .bar-content { + flex-grow: 1; + } + + .visit-button { + border-radius: 999rem; + padding: 0.5rem 0.75rem 0.5rem 0.75rem; + float: right; + color: var(--pico-color-zinc-200); + border-color: var(--pico-color-zinc-200); + } + + .visit-button.visited { + color: var(--pico-color-green-400); + border-color: var(--pico-color-green-400); + cursor: auto; + } + + .checkmark { + width: 1em; + display: inline-block; + vertical-align: middle; + margin-right: 2px; + margin-bottom: 0.1em; + } diff --git a/frontend/src/lib/Checkmark.svelte b/frontend/src/lib/Checkmark.svelte new file mode 100644 index 0000000..c224baa --- /dev/null +++ b/frontend/src/lib/Checkmark.svelte @@ -0,0 +1,105 @@ + + +{#if success} + + + + +{:else} + + + + + +{/if} + + diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index da4dd58..fa20180 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -1,5 +1,6 @@