Skip to content

Commit 07fe075

Browse files
committed
[add] Award model & placeholder page
1 parent f57c0bf commit 07fe075

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ NEXT_PUBLIC_LARK_WIKI_URL = https://open-source-bazaar.feishu.cn/wiki/space/7052
99
NEXT_PUBLIC_LARK_BITABLE_ID = PNOGbGqhPacsHOsvJqHctS77nje
1010
NEXT_PUBLIC_ACTIVITY_TABLE_ID = tblREEMxDOECZZrK
1111
NEXT_PUBLIC_PROJECT_TABLE_ID = tblGnY6Hm0nTSBR9
12+
NEXT_PUBLIC_AWARD_TABLE_ID = tblmYd5V5BMngAp2
1213

1314
NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/

models/Award.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { BiDataQueryOptions, BiDataTable, BiSearch, TableCellValue } from 'mobx-lark';
2+
3+
import { larkClient } from './Base';
4+
import { AwardTableId, LarkBitableId } from './configuration';
5+
6+
export type Award = Record<
7+
| 'awardName'
8+
| `nominee${'Name' | 'Desc'}`
9+
| 'videoUrl'
10+
| 'reason'
11+
| 'nominator'
12+
| 'createdAt'
13+
| 'votes',
14+
TableCellValue
15+
>;
16+
17+
export class AwardModel extends BiDataTable<Award>() {
18+
client = larkClient;
19+
20+
queryOptions: BiDataQueryOptions = { text_field_as_array: false };
21+
22+
constructor(appId = LarkBitableId, tableId = AwardTableId) {
23+
super(appId, tableId);
24+
}
25+
}
26+
27+
export class SearchAwardModel extends BiSearch<Award>(AwardModel) {
28+
searchKeys = ['awardName', 'nomineeName', 'nomineeDesc', 'reason', 'nominator'];
29+
}

models/System.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BaseModel, DataObject, Filter, ListModel, toggle } from 'mobx-restful';
44
import { Constructor } from 'web-utility';
55

66
import { SearchActivityModel } from './Activity';
7+
import { SearchAwardModel } from './Award';
78
import { ownClient } from './Base';
89
import { OrganizationModel } from './Organization';
910
import { SearchProjectModel } from './Project';
@@ -24,6 +25,7 @@ export class SystemModel extends BaseModel {
2425
searchMap = {
2526
activity: SearchActivityModel,
2627
project: SearchProjectModel,
28+
award: SearchAwardModel,
2729
NGO: OrganizationModel,
2830
} as Record<string, Constructor<SearchModel<DataObject>>>;
2931

models/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ export const LarkWikiId = pathname.split('/').pop()!;
3636

3737
export const LarkBitableId = process.env.NEXT_PUBLIC_LARK_BITABLE_ID!,
3838
ActivityTableId = process.env.NEXT_PUBLIC_ACTIVITY_TABLE_ID!,
39-
ProjectTableId = process.env.NEXT_PUBLIC_PROJECT_TABLE_ID!;
39+
ProjectTableId = process.env.NEXT_PUBLIC_PROJECT_TABLE_ID!,
40+
AwardTableId = process.env.NEXT_PUBLIC_AWARD_TABLE_ID!;

pages/award/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { cache, compose, errorLogger } from 'next-ssr-middleware';
2+
import { FC } from 'react';
3+
4+
import { Award, AwardModel } from '../../models/Award';
5+
6+
export const getServerSideProps = compose(cache(), errorLogger, async () => {
7+
const awards = await new AwardModel().getAll();
8+
9+
return { props: { awards } };
10+
});
11+
12+
const AwardPage: FC<{ awards: Award[] }> = ({ awards }) => {
13+
return <></>;
14+
};
15+
16+
export default AwardPage;

0 commit comments

Comments
 (0)