@@ -173,35 +173,26 @@ export const getServerSideProps = compose<{ id: string }>(
173173 errorLogger ,
174174 async ( { params } ) => {
175175 const activity = await new ActivityModel ( ) . getOne ( params ! . id ) ;
176- const { appId , tableIdMap } = ( activity . databaseSchema ||
177- { } ) as BiTableSchema ;
176+ const schema = activity . databaseSchema as Partial < BiTableSchema > | undefined ;
177+ const tableIdMap = schema ?. tableIdMap as Partial < Record < RequiredTableKey , string > > | undefined ;
178178
179- if ( ! appId || ! tableIdMap ) return { notFound : true , props : { } } ;
179+ if ( ! schema ?. appId || ! tableIdMap ) return { notFound : true , props : { } } ;
180180
181- for ( const key of RequiredTableKeys )
182- if ( ! tableIdMap [ key ] ) return { notFound : true , props : { } } ;
181+ for ( const key of RequiredTableKeys ) if ( ! tableIdMap [ key ] ) return { notFound : true , props : { } } ;
183182
184- const [ people , organizations , agenda , prizes , templates , projects ] =
185- await Promise . all ( [
186- new PersonModel ( appId , tableIdMap . Person ) . getAll ( ) ,
187- new OrganizationModel ( appId , tableIdMap . Organization ) . getAll ( ) ,
188- new AgendaModel ( appId , tableIdMap . Agenda ) . getAll ( ) ,
189- new PrizeModel ( appId , tableIdMap . Prize ) . getAll ( ) ,
190- new TemplateModel ( appId , tableIdMap . Template ) . getAll ( ) ,
191- new ProjectModel ( appId , tableIdMap . Project ) . getAll ( ) ,
192- ] ) ;
183+ const [ people , organizations , agenda , prizes , templates , projects ] = await Promise . all ( [
184+ new PersonModel ( schema . appId , tableIdMap . Person ) . getAll ( ) ,
185+ new OrganizationModel ( schema . appId , tableIdMap . Organization ) . getAll ( ) ,
186+ new AgendaModel ( schema . appId , tableIdMap . Agenda ) . getAll ( ) ,
187+ new PrizeModel ( schema . appId , tableIdMap . Prize ) . getAll ( ) ,
188+ new TemplateModel ( schema . appId , tableIdMap . Template ) . getAll ( ) ,
189+ new ProjectModel ( schema . appId , tableIdMap . Project ) . getAll ( ) ,
190+ ] ) ;
193191
194192 return {
195193 props : {
196194 activity,
197- hackathon : {
198- people,
199- organizations,
200- agenda,
201- prizes,
202- templates,
203- projects,
204- } ,
195+ hackathon : { people, organizations, agenda, prizes, templates, projects } ,
205196 } ,
206197 } ;
207198 } ,
0 commit comments