Merge branch 'refactor/favs' into 'master'

refactor: everything

See merge request gk1623/drp-48!31

Co-authored-by: Barf-Vader <47476490+Barf-Vader@users.noreply.github.com>
This commit is contained in:
Ling, Alex
2025-06-16 20:36:42 +00:00
6 changed files with 44 additions and 13 deletions

View File

@@ -80,7 +80,7 @@
}}
class="feedbackContainer"
>
<h1 class="submitHeader">Submit Feedback</h1>
<h1 class="submitHeader">Update Tags</h1>
<div class="compulsoryTags">
<div class="compulsoryContainer">

View File

@@ -114,7 +114,7 @@
.compulsoryContainer {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(3.75rem, 1fr));
grid-template-columns: repeat(auto-fit, minmax(3.7rem, 1fr));
gap: 0.3rem;
font-size: 0.8rem;
}

View File

@@ -18,7 +18,7 @@ export const availableStudySpaceTags = [
"Air conditioned",
"Cold",
"PCs",
"Cringe"
"Rodent-ridden"
];
export const volumeTags = ["Silent", "Some Noise", "Loud"];

View File

@@ -99,6 +99,33 @@
})
);
const sortedByOpenNow = $derived(
filteredStudySpaces.toSorted((a, b) => {
const now = new Date();
const time = now.toTimeString().slice(0, 5);
const today = now.getDay();
let openUntil = [0, 0] as number[];
for (const [index, day] of [a, b].entries()) {
const timingsPerDay = collectTimings(day.study_space_hours);
for (const timing of timingsPerDay[today]) {
if (timing.open_today_status === true) {
openUntil[index] = 24 * 60;
break;
} else if (timing.open_today_status === false) {
break;
} else {
const opensFor = timeUntilClosing(timing.opens_at, timing.closes_at, time);
if (opensFor) {
openUntil[index] = opensFor;
break;
}
}
}
}
return openUntil[1] - openUntil[0];
})
);
const sortedStudySpaces = $derived(
sortNear
? filteredStudySpaces.toSorted((a, b) => {
@@ -122,7 +149,7 @@
);
return aDistance - bDistance;
})
: filteredStudySpaces
: sortedByOpenNow
);
// Open now
@@ -170,10 +197,18 @@
<a href="/space/new/edit">
<img src={crossUrl} alt="new" class="new-space" />
</a>
{/if}
{#if adminMode}
<span class="checkReports">
<Button href="/space/reports" type="link" style="red">Check Reports</Button>
</span>
{/if}
{#if session}
<button class="fav-button" onclick={() => (showFavourites = !showFavourites)} type="button">
{showFavourites ? "All spaces" : "My favourites"}
</button>
{/if}
<div class="filterWrapper">
<Button type="link" href="/filter?{searchParams}">
<span class="search">
@@ -185,11 +220,6 @@
</Navbar>
<main>
{#if adminMode}
<div class="checkReports">
<Button href="/space/reports" type="link" style="red">Check Reports</Button>
</div>
{/if}
{#each sortedStudySpaces as studySpace (studySpace.id)}
{@const imgUrl =
studySpace.study_space_images.length > 0
@@ -256,7 +286,8 @@
grid-column: 1 / -1;
display: flex;
flex-direction: column;
font-size: 1.2rem;
font-size: 1rem;
margin-left: 0.5rem;
}
.fav-button {

View File

@@ -68,8 +68,8 @@
const { Map } = await loader.importLibrary("maps");
const { AdvancedMarkerElement } = await loader.importLibrary("marker");
const map = new Map(sortMapElem, {
center: { lat: 53.6, lng: -1.56 },
zoom: 5,
center: { lat: 51.5087393, lng: -0.1667442 },
zoom: 10,
mapId: "9f4993cd3fb1504d495821a5"
});
marker = new AdvancedMarkerElement({

View File

@@ -187,7 +187,7 @@
isFeedbackPromptVisible = true;
}}
>
Help categorise this space
Update Tags
</button>
<div class="actions">