Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remaining spots #2019

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PARTICIPANTS_DIRECTORY } from '$lib/participants/participant-schema';
import type { PageServerLoad } from './$types';
import { loadParticipantJsonFilePaths, loadParticipants } from '$lib/participants/participants';

export const load: PageServerLoad = async (): Promise<{
fridayParticipants: number;
saturdayParticipants: number;
}> => {
try {
const participantsFilePaths = await loadParticipantJsonFilePaths(PARTICIPANTS_DIRECTORY);

const participants = await loadParticipants(participantsFilePaths);

const fridayParticipants = participants.filter((p) => p.when.friday).length;
const saturdayParticipants = participants.filter((p) => p.when.saturday).length;

return { fridayParticipants, saturdayParticipants };
} catch (err) {
console.error('Loading of participants failed:', err);
throw err;
}
};
8 changes: 8 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import Partners from '$lib/sponsoring/Partners.svelte';
import Sponsors from '$lib/sponsoring/Sponsors2024.svelte';
import Schedule from './Schedule.svelte';
import type { PageData } from './$types';

export let data: PageData;

const countdown = writable<string>('');
const registrationState = writable<'not-yet' | 'closed' | 'open'>(getRegistrationState());
Expand Down Expand Up @@ -73,6 +76,11 @@
<p>Registration is closed, we're full!</p>
{:else}
<p><a href="{base}/registration">Registration is open!</a></p>
<p>Grab your spot!</p>
<p>Friday: <strong>{100 - data.fridayParticipants}</strong> spots left</p>
<p>
Saturday: <strong>{100 - data.saturdayParticipants}</strong> spots left
</p>
{/if}
</InfoBox>
<InfoBox title="Where?">
Expand Down
4 changes: 2 additions & 2 deletions src/routes/participants/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@
type="button"
on:click={setFridayOrUnset}
class:isActive={$participantsFilter === fridayFilter}
>Friday ({participants.filter(fridayFilter).length} participants)</button
>Friday ({participants.filter(fridayFilter).length} / 100 participants)</button
>
<button
type="button"
on:click={setSaturdayOrUnset}
class:isActive={$participantsFilter === saturdayFilter}
>Saturday ({participants.filter(saturdayFilter).length} participants)</button
>Saturday ({participants.filter(saturdayFilter).length} / 100 participants)</button
>
</div>

Expand Down