Skip to content

Commit 3351ccb

Browse files
committed
fix: guard hackathon detail schema access
1 parent e4d5075 commit 3351ccb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

pages/hackathon/[id].tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ import {
5656
compactSummaryOf,
5757
dateKeyOf,
5858
daysBetween,
59+
firstTextOf,
5960
formatMoment,
6061
formatPeriod,
6162
isPublicForm,
6263
normalizeAgendaType,
6364
previewText,
65+
textListOf,
6466
} from '../../components/Activity/Hackathon/utility';
6567

6668
interface HackathonDetailProps {
@@ -79,9 +81,10 @@ export const getServerSideProps = compose<{ id: string }>(
7981
cache(),
8082
errorLogger,
8183
async ({ params }) => {
82-
const activity = await new ActivityModel().getOne(params!.id);
84+
if (!params?.id) return { notFound: true, props: {} };
8385

84-
const { appId, tableIdMap } = activity.databaseSchema;
86+
const activity = await new ActivityModel().getOne(params!.id);
87+
const { appId, tableIdMap } = activity.databaseSchema || {};
8588

8689
if (!appId || !tableIdMap) return { notFound: true, props: {} };
8790

@@ -122,7 +125,7 @@ const HackathonDetail: FC<HackathonDetailProps> = observer(({ activity, hackatho
122125
{ people, organizations, agenda, prizes, templates, projects } = hackathon;
123126
const { forms } = databaseSchema;
124127
const formMap = (forms || {}) as Partial<Record<FormGroupKey, TableFormView[]>>;
125-
const summaryText = (summary as string) || '';
128+
const summaryText = textListOf(summary).join(' · ') || firstTextOf(summary);
126129
const agendaItems = [...agenda].sort(
127130
({ startedAt: left }, { startedAt: right }) =>
128131
new Date((left as string) || 0).getTime() - new Date((right as string) || 0).getTime(),

0 commit comments

Comments
 (0)