Skip to content

Commit

Permalink
#196: Fetch CV info for agenda
Browse files Browse the repository at this point in the history
  • Loading branch information
Espen Norderud committed Oct 24, 2023
1 parent 7460bfa commit 2ebfa58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/agenda/AgendaLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export let submission: ISubmission;
export let event: IEvent;
export let performance: IPerformance;
export let cvs: Cv[] = [];
export let cvs: Cv[];
let submissionTypeIcon = {
presentation: Megaphone,
Expand Down
12 changes: 10 additions & 2 deletions src/routes/arrangement/[arrangement]/agenda/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { error, redirect } from '@sveltejs/kit';
import type { IEvent } from '../../../../../model/event';
import type { PageServerLoad } from './$types';
import type { IAgendaPageLoadData } from '../../../../konferanser/[slug]/agenda/[submissionSlug]/+page.server';
import {fetchCvByEmail} from "$lib/server/cvpartnerClient";

export const prerender = false;
export const ssr = false;
Expand All @@ -26,13 +27,20 @@ export const load = (async ({ params, cookies, url }): Promise<IAgendaPageLoadDa

const performance = event.performances ? event.performances[0] : undefined;

if (!performance || !performance.submission) {
if (!performance?.submission) {
throw error(404, 'Fant ingen informasjon om agenda');
}

const cvPartnerData = (!(performance.submission.authors || []).length)
? []
: await Promise.all(
performance.submission.authors.map(async (author) => await fetchCvByEmail(author.email))
);

return {
event: event,
performance: performance,
submission: performance.submission
submission: performance.submission,
cvs: cvPartnerData
};
}) satisfies PageServerLoad;
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
export let data: IAgendaPageLoadData;
</script>

<AgendaLayout event={data.event} performance={data.performance} submission={data.submission} />
<AgendaLayout event={data.event} performance={data.performance} submission={data.submission} cvs={data.cvs} />

0 comments on commit 2ebfa58

Please sign in to comment.