Skip to content

Commit ba51623

Browse files
committed
fix: require valid hackathon detail form links
1 parent 79c8b39 commit ba51623

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

pages/hackathon/[id].tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,26 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
225225
.join(',');
226226

227227
const formGroups = FormButtonBar.flatMap<FormGroupView>(key => {
228-
const list = (formMap[key] || []).filter(isPublicForm);
228+
const links = (formMap[key] || []).filter(isPublicForm).flatMap(({ name, shared_url }) =>
229+
shared_url
230+
? [
231+
{
232+
label: name as string,
233+
href: shared_url,
234+
external: true as const,
235+
},
236+
]
237+
: [],
238+
);
229239

230-
return list[0]
240+
return links[0]
231241
? [
232242
{
233243
key,
234244
eyebrow: buildFormSectionMeta(i18n)[key].eyebrow,
235245
title: buildFormSectionMeta(i18n)[key].title,
236246
description: buildFormSectionMeta(i18n)[key].description,
237-
links: list.map(({ name, shared_url }) => ({
238-
label: name as string,
239-
href: shared_url,
240-
external: true as const,
241-
})),
247+
links,
242248
},
243249
]
244250
: [];
@@ -250,7 +256,7 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
250256
const heroPrimaryAction = primaryForm
251257
? {
252258
label: heroPrimaryActionLabel,
253-
href: primaryForm.links[0].href,
259+
href: primaryForm.links[0]!.href,
254260
external: true as const,
255261
}
256262
: { label: t('event_description'), href: '#overview' };
@@ -400,7 +406,7 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
400406
primaryForm
401407
? {
402408
label: primaryForm.title,
403-
href: primaryForm.links[0].href,
409+
href: primaryForm.links[0]!.href,
404410
external: true,
405411
}
406412
: undefined
@@ -415,7 +421,7 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
415421
secondaryForm
416422
? {
417423
label: secondaryForm.title,
418-
href: secondaryForm.links[0].href,
424+
href: secondaryForm.links[0]!.href,
419425
external: true,
420426
}
421427
: { label: t('agenda'), href: '#schedule' }

0 commit comments

Comments
 (0)