Skip to content

Commit

Permalink
feat: include google_place_id in LocationResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
SchutteJan committed Jul 24, 2024
1 parent 7afa357 commit f039fff
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
2 changes: 2 additions & 0 deletions backend/src/db/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub async fn get_bars(conn: &DbConn) -> Result<Vec<LocationResponse>, Error> {
id,
name,
description,
google_place_id,
coordinates,
imageurl,
address_line,
Expand Down Expand Up @@ -53,6 +54,7 @@ pub async fn get_bars_with_visits(
locations::id,
locations::name,
locations::description,
locations::google_place_id,
locations::coordinates,
locations::imageurl,
locations::address_line,
Expand Down
2 changes: 2 additions & 0 deletions backend/src/models/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct LocationResponse {
pub id: i32,
pub name: String,
pub description: Option<String>,
pub google_place_id: Option<String>,
pub coordinates: Point,
pub imageurl: Option<String>,
pub address_line: String,
Expand Down Expand Up @@ -89,6 +90,7 @@ impl From<&Location> for LocationResponse {
id: l.id,
name: l.name.clone(),
description: l.description.clone(),
google_place_id: l.google_place_id.clone(),
coordinates: l.coordinates,
imageurl: l.imageurl.clone(),
visited_at: None,
Expand Down
45 changes: 30 additions & 15 deletions frontend/src/lib/BarItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,39 @@
}
</script>

<article class="bar-item">
<img alt={bar.name} class="bar-image" src={bar.imageurl ?? placeholder} />
<div class="bar-content">
<h3>{bar.name}</h3>
<article>
<details>
<summary class="bar-item">
<img alt={bar.name} class="bar-image" src={bar.imageurl ?? placeholder} />
<div class="bar-content">
<h3>{bar.name}</h3>

<p>
{bar.address_line} •
<span class="area">{bar.area_name ? bar.area_name : 'Unknown Area'}</span>
</p>
<p>
{bar.address_line} •
<span class="area">{bar.area_name ? bar.area_name : 'Unknown Area'}</span>
</p>

{#if isLoggedIn}
{#if bar.visited_at}
<span data-tooltip={visitString()} class="checkmark"><Checkmark /></span>
{#if isLoggedIn}
{#if bar.visited_at}
<span data-tooltip={visitString()} class="checkmark"><Checkmark /></span>
{:else}
<button on:click={handleVisitBar} class="visit-button outline">Check in</button>
{/if}
{/if}
</div>
</summary>
<hr />
<p>
{#if bar.description}
{bar.description}
{:else}
<button on:click={handleVisitBar} class="visit-button outline">Check in</button>
<i>No description available.</i>
{/if}
{/if}
</div>
</p>
<a target="_blank" href="https://www.google.com/maps/place/?q=place_id:{bar.google_place_id}"
>Open in Maps 🡵</a
>
</details>
</article>

<style>
Expand All @@ -57,7 +72,6 @@
.bar-image {
width: 6rem;
height: 6rem;
margin: 0 var(--pico-block-spacing-horizontal);
border-radius: var(--pico-border-radius);
max-width: 100%;
object-fit: cover;
Expand All @@ -66,6 +80,7 @@
.bar-content {
flex-grow: 1;
margin-left: var(--pico-block-spacing-horizontal);
}
.visit-button {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/models/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface LocationResponse {
area_name?: string | null
coordinates: Point
description?: string | null
google_place_id?: string | null
id: number
imageurl?: string | null
name: string
Expand Down

0 comments on commit f039fff

Please sign in to comment.