Skip to content

Commit 0211cca

Browse files
committed
Apply latest PR review feedback
1 parent 77bbdfb commit 0211cca

4 files changed

Lines changed: 20 additions & 35 deletions

File tree

components/Activity/Hackathon/HackathonActionHub.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, type PropsWithChildren } from 'react';
1+
import type { FC, PropsWithChildren } from 'react';
22
import { Col, Container, Row } from 'react-bootstrap';
33

44
import { HackathonHeroAction } from './HackathonHero';

components/Activity/Hackathon/HackathonAwards.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { Container } from 'react-bootstrap';
55
import { LarkImage } from '../../LarkImage';
66
import styles from './HackathonAwards.module.less';
77

8-
export type HackathonAwardsMeta<Value = string> = Record<'label', string> & {
8+
export interface HackathonAwardsMeta<Value = string> {
9+
label: string;
910
value: Value;
10-
};
11+
}
1112

1213
export interface HackathonPrizeItem {
1314
description: string;

pages/api/Lark/document/copy/[...slug].ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@ const router = createKoaRouter(import.meta.url);
1111

1212
router.post('/:type/:id', safeAPI, verifyJWT, async (context: Context) => {
1313
const { type, id } = context.params,
14-
{ name, parentToken, ownerType, ownerId } = Reflect.get(
15-
context.request,
16-
'body',
17-
);
14+
{ name, parentToken, ownerType, ownerId } = Reflect.get(context.request, 'body');
1815

1916
const copiedFile =
2017
type === 'wiki'
2118
? await lark.copyFile(`${type as 'wiki'}/${id}`, name, parentToken)
22-
: await lark.copyFile(
23-
`${type as LarkDocumentPathType}/${id}`,
24-
name,
25-
parentToken,
26-
);
19+
: await lark.copyFile(`${type as LarkDocumentPathType}/${id}`, name, parentToken);
2720

28-
const newId = copiedFile.token;
21+
const newId = 'token' in copiedFile ? copiedFile.token : copiedFile.node_token;
2922

3023
if (ownerType && ownerId)
3124
try {

pages/hackathon/[id].tsx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)