fix: Fixed favourites to not show up when a user hasn't been logged in
Co-Authored-By: Tadios Temesgen <tt2022@ic.ac.uk>
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
imgSrc: string;
|
imgSrc: string;
|
||||||
href?: string;
|
href?: string;
|
||||||
isFavourite: boolean;
|
isFavourite: boolean;
|
||||||
onToggleFavourite: () => void;
|
|
||||||
|
onToggleFavourite?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { space, hours, alt, imgSrc, href, isFavourite, onToggleFavourite }: Props = $props();
|
const { space, hours, alt, imgSrc, href, isFavourite, onToggleFavourite }: Props = $props();
|
||||||
@@ -21,9 +22,11 @@
|
|||||||
<!-- <img src={imgSrc} {alt} /> -->
|
<!-- <img src={imgSrc} {alt} /> -->
|
||||||
<div class="image-container">
|
<div class="image-container">
|
||||||
<img src={imgSrc} {alt} />
|
<img src={imgSrc} {alt} />
|
||||||
|
{#if onToggleFavourite}
|
||||||
<div class="fav-button">
|
<div class="fav-button">
|
||||||
<Favourite {isFavourite} {onToggleFavourite} />
|
<Favourite {isFavourite} {onToggleFavourite} />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<h1>{space.location}</h1>
|
<h1>{space.location}</h1>
|
||||||
|
|||||||
@@ -232,7 +232,7 @@
|
|||||||
space={studySpace}
|
space={studySpace}
|
||||||
hours={studySpace.study_space_hours}
|
hours={studySpace.study_space_hours}
|
||||||
isFavourite={favouriteIds.includes(studySpace.id)}
|
isFavourite={favouriteIds.includes(studySpace.id)}
|
||||||
onToggleFavourite={() => handleToggleFavourite(studySpace.id)}
|
onToggleFavourite={session ? () => handleToggleFavourite(studySpace.id) : undefined}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -122,11 +122,15 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<main>
|
<main>
|
||||||
<Carousel urls={imgUrls} />
|
<Carousel urls={imgUrls} />
|
||||||
<div class="titleContainer">
|
<div class="nameContainer">
|
||||||
<div class="nameContainer">{space.location}</div>
|
<div class="locationContainer">{space.location}</div>
|
||||||
|
{#await supabase.auth.getSession() then resp}
|
||||||
|
{#if resp.data.session}
|
||||||
<div class="title-fav">
|
<div class="title-fav">
|
||||||
<Favourite {isFavourite} onToggleFavourite={handleToggleFavourite} />
|
<Favourite {isFavourite} onToggleFavourite={handleToggleFavourite} />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
{#if space.description != null && space.description.length > 0}
|
{#if space.description != null && space.description.length > 0}
|
||||||
<p class="descContainer">
|
<p class="descContainer">
|
||||||
@@ -223,12 +227,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nameContainer {
|
.nameContainer {
|
||||||
z-index: 10;
|
display: flex;
|
||||||
display: block;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.6rem;
|
padding: 0.6rem;
|
||||||
margin-top: -0.5rem;
|
margin-top: -0.5rem;
|
||||||
object-position: center;
|
|
||||||
background-color: #49bd85;
|
background-color: #49bd85;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-size: 2.8rem;
|
font-size: 2.8rem;
|
||||||
@@ -338,12 +343,12 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
color: #eaffeb;
|
color: #eaffeb;
|
||||||
}
|
}
|
||||||
.titleContainer {
|
/* .titleContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: -0.5rem 0 1rem;
|
margin: -0.5rem 0 1rem;
|
||||||
}
|
} */
|
||||||
.title-fav {
|
.title-fav {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
background: rgba(0, 0, 0, 0.4);
|
background: rgba(0, 0, 0, 0.4);
|
||||||
|
|||||||
Reference in New Issue
Block a user