-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] Project list of Home page based on Group API & model
[fix] some UI detail bugs [fix] webpack building bug (vercel/next.js#28774)
- Loading branch information
Showing
11 changed files
with
537 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { NewData, ListModel, Stream } from 'mobx-restful'; | ||
import { TableCellLink, TableCellValue, TableRecordList } from 'lark-ts-sdk'; | ||
|
||
import { client } from './Base'; | ||
import { normalizeText, createListStream } from './Lark'; | ||
|
||
export type Group = Record< | ||
| 'id' | ||
| 'name' | ||
| 'type' | ||
| 'fullName' | ||
| 'tags' | ||
| 'startDate' | ||
| 'leader' | ||
| 'members' | ||
| 'summary' | ||
| 'document' | ||
| 'email' | ||
| 'link' | ||
| 'codeLink' | ||
| 'logo', | ||
TableCellValue | ||
>; | ||
|
||
export class GroupModel extends Stream<Group>(ListModel) { | ||
client = client; | ||
baseURI = 'group'; | ||
|
||
normalize = ({ | ||
id, | ||
fields: { link, codeLink, email, ...fields }, | ||
}: TableRecordList<Group>['data']['items'][number]): Group => ({ | ||
...fields, | ||
id: id!, | ||
link: normalizeText(link as TableCellLink), | ||
codeLink: normalizeText(codeLink as TableCellLink), | ||
email: normalizeText(email as TableCellLink), | ||
}); | ||
|
||
async *openStream(filter: NewData<Group>) { | ||
for await (const { total, items } of createListStream<Group>( | ||
this.client, | ||
this.baseURI, | ||
filter, | ||
)) { | ||
this.totalCount = total; | ||
|
||
yield* items?.map(this.normalize) || []; | ||
} | ||
} | ||
} | ||
|
||
export default new GroupModel(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { buildURLData, parseURLData } from 'web-utility'; | ||
import { DataObject } from 'mobx-restful'; | ||
import { TableRecordList } from 'lark-ts-sdk'; | ||
import { NextApiResponse } from 'next'; | ||
|
||
import { safeAPI } from '../base'; | ||
import { lark, makeFilter } from '../../../models/Lark'; | ||
import { Group } from '../../../models/Group'; | ||
|
||
const LARK_BITABLE_ID = process.env.LARK_BITABLE_ID!, | ||
LARK_BITABLE_GROUP_ID = process.env.LARK_BITABLE_GROUP_ID!; | ||
|
||
export default safeAPI( | ||
async ( | ||
{ method, url }, | ||
response: NextApiResponse<TableRecordList<Group>['data']>, | ||
) => { | ||
switch (method) { | ||
case 'GET': { | ||
const biTable = await lark.getBITable(LARK_BITABLE_ID); | ||
|
||
const table = await biTable.getTable<Group>(LARK_BITABLE_GROUP_ID), | ||
{ page_size, page_token, ...filter } = parseURLData( | ||
url!, | ||
) as DataObject; | ||
|
||
const { body } = await lark.client.get<TableRecordList<Group>>( | ||
`${table!.baseURI}/records?${buildURLData({ | ||
page_size, | ||
page_token, | ||
filter: makeFilter(filter), | ||
})}`, | ||
); | ||
response.json(body!.data); | ||
} | ||
} | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
991f1c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for kaiyuanshe ready!
✅ Preview
https://kaiyuanshe-mft1hdis1-techquery.vercel.app
Built with commit 991f1c6.
This pull request is being automatically deployed with vercel-action