Skip to content

Commit d124e21

Browse files
authored
成员看板 (#347)
1 parent c8243a0 commit d124e21

File tree

4 files changed

+181
-3
lines changed

4 files changed

+181
-3
lines changed

pages/member/[name].tsx

+166-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
11
import { text2color } from 'idea-react';
22
import { marked } from 'marked';
3+
import { textJoin } from 'mobx-i18n';
34
import { observer } from 'mobx-react';
45
import { compose, errorLogger, translator } from 'next-ssr-middleware';
56
import { Component } from 'react';
67
import { Badge, Breadcrumb, Col, Container, Image, Row } from 'react-bootstrap';
78
import { formatDate } from 'web-utility';
89

10+
import { ActivityCard } from '../../components/Activity/Card';
11+
import { ArticleCard } from '../../components/Article/Card';
912
import { CommentBox } from '../../components/Base/CommentBox';
1013
import { LarkImage } from '../../components/Base/LarkImage';
14+
import { CommunityCard } from '../../components/Community/CommunityCard';
15+
import { GroupCard } from '../../components/Department/Card';
16+
import { MeetingCard } from '../../components/Governance/MeetingCard';
1117
import { PageHead } from '../../components/Layout/PageHead';
18+
import { OrganizationCard } from '../../components/Organization/Card';
19+
import { Activity, SearchActivityModel } from '../../models/Activity';
1220
import { i18n, t } from '../../models/Base/Translation';
21+
import { Community, SearchCommunityModel } from '../../models/Community';
22+
import { SearchNGOModel } from '../../models/Community/Organization';
23+
import {
24+
Organization,
25+
SearchOrganizationModel,
26+
} from '../../models/Community/Organization';
27+
import { Meeting, SearchMeetingModel } from '../../models/Governance/Meeting';
1328
import { Personnel, PersonnelModel } from '../../models/Personnel';
29+
import {
30+
Department,
31+
SearchDepartmentModel,
32+
} from '../../models/Personnel/Department';
1433
import { Person, PersonModel } from '../../models/Personnel/Person';
15-
34+
import { Article, SearchArticleModel } from '../../models/Product/Article';
1635
interface PersonDetailPageProps {
1736
person: Person;
1837
personnels: Personnel[];
38+
articles: Article[];
39+
departments: Department[];
40+
meetings: Meeting[];
41+
activitys: Activity[];
42+
communitys: Community[];
43+
organizations: Organization[];
44+
NGOs: Organization[];
1945
}
2046

2147
export const getServerSideProps = compose<{ name: string }, PersonDetailPage>(
@@ -31,8 +57,38 @@ export const getServerSideProps = compose<{ name: string }, PersonDetailPage>(
3157
recipient: name,
3258
});
3359

60+
const [
61+
departments,
62+
meetings,
63+
articles,
64+
activitys,
65+
communitys,
66+
organizations,
67+
NGOs,
68+
] = await Promise.all([
69+
new SearchDepartmentModel().getSearchList(name + ''),
70+
new SearchMeetingModel().getSearchList(name + ''),
71+
new SearchArticleModel().getSearchList(name + ''),
72+
new SearchActivityModel().getSearchList(name + ''),
73+
new SearchCommunityModel().getSearchList(name + ''),
74+
new SearchOrganizationModel().getSearchList(name + ''),
75+
new SearchNGOModel().getSearchList(name + ''),
76+
]);
77+
78+
const searchResults = {
79+
person,
80+
personnels,
81+
departments,
82+
meetings,
83+
articles,
84+
activitys,
85+
communitys,
86+
organizations,
87+
NGOs,
88+
};
89+
3490
return {
35-
props: JSON.parse(JSON.stringify({ person, personnels })),
91+
props: JSON.parse(JSON.stringify(searchResults)),
3692
};
3793
},
3894
);
@@ -137,8 +193,108 @@ export default class PersonDetailPage extends Component<PersonDetailPageProps> {
137193
</li>
138194
);
139195

196+
renderArticle = (articles: Article[]) => (
197+
<details>
198+
<summary>{textJoin(t('related'), t('article'))}</summary>
199+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
200+
{articles.map(article => (
201+
<Col key={article.id as string} as="li">
202+
<ArticleCard {...article} />
203+
</Col>
204+
))}
205+
</Row>
206+
</details>
207+
);
208+
renderDepartment = (departments: Department[]) => (
209+
<details>
210+
<summary>{textJoin(t('related'), t('department'))}</summary>
211+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
212+
{departments.map(department => (
213+
<Col key={department.id as string} as="li">
214+
<GroupCard {...department} />
215+
</Col>
216+
))}
217+
</Row>
218+
</details>
219+
);
220+
221+
renderMeeting = (meetings: Meeting[]) => (
222+
<details>
223+
<summary>{textJoin(t('related'), t('meeting'))}</summary>
224+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
225+
{meetings.map(meeting => (
226+
<Col key={meeting.id as string} as="li">
227+
<MeetingCard {...meeting} />
228+
</Col>
229+
))}
230+
</Row>
231+
</details>
232+
);
233+
234+
renderActivity = (activitys: Activity[]) => (
235+
<details>
236+
<summary>{textJoin(t('related'), t('activity'))}</summary>
237+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
238+
{activitys.map(activity => (
239+
<Col key={activity.id as string} as="li">
240+
<ActivityCard {...activity} />
241+
</Col>
242+
))}
243+
</Row>
244+
</details>
245+
);
246+
247+
renderCommunity = (communitys: Community[]) => (
248+
<details>
249+
<summary>{textJoin(t('related'), t('community'))}</summary>
250+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
251+
{communitys.map(community => (
252+
<Col key={community.id as string} as="li">
253+
<CommunityCard {...community} />
254+
</Col>
255+
))}
256+
</Row>
257+
</details>
258+
);
259+
260+
renderOrganization = (organizations: Organization[]) => (
261+
<details>
262+
<summary>{textJoin(t('related'), t('organization'))}</summary>
263+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
264+
{organizations.map(({ id, ...organization }) => (
265+
<Col key={id as string} as="li">
266+
<OrganizationCard {...organization} />
267+
</Col>
268+
))}
269+
</Row>
270+
</details>
271+
);
272+
273+
renderNGO = (NGOs: Organization[]) => (
274+
<details>
275+
<summary>{textJoin(t('related'), t('NGO'))}</summary>
276+
<Row as="ol" className="list-unstyled g-3" xs={1} md={2}>
277+
{NGOs.map(({ id, ...NGO }) => (
278+
<Col key={id as string} as="li">
279+
<OrganizationCard {...NGO} />
280+
</Col>
281+
))}
282+
</Row>
283+
</details>
284+
);
285+
140286
render() {
141-
const { person, personnels } = this.props;
287+
const {
288+
person,
289+
personnels,
290+
departments,
291+
meetings,
292+
articles,
293+
activitys,
294+
communitys,
295+
organizations,
296+
NGOs,
297+
} = this.props;
142298

143299
return (
144300
<Container className="py-5">
@@ -165,6 +321,13 @@ export default class PersonDetailPage extends Component<PersonDetailPageProps> {
165321
<hr className="my-5" />
166322

167323
{personnels.map(this.renderPersonnel)}
324+
{articles.length > 0 && this.renderArticle(articles)}
325+
{departments.length > 0 && this.renderDepartment(departments)}
326+
{meetings.length > 0 && this.renderMeeting(meetings)}
327+
{activitys.length > 0 && this.renderActivity(activitys)}
328+
{communitys.length > 0 && this.renderCommunity(communitys)}
329+
{organizations.length > 0 && this.renderOrganization(organizations)}
330+
{NGOs.length > 0 && this.renderNGO(NGOs)}
168331
</Col>
169332
</Row>
170333

translation/en-US.ts

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export default {
118118
department: 'department',
119119
organization: 'organization',
120120
activity: 'activity',
121+
meeting: 'meeting',
122+
NGO: 'NGO',
121123

122124
// Organization page
123125
reset: 'reset',
@@ -270,4 +272,7 @@ export default {
270272
this_term_proposition: 'This term proposition',
271273
recommendation: 'recommendation',
272274
vote_for_me: 'Vote for Me',
275+
276+
// Member pages
277+
related: 'Related',
273278
} as const;

translation/zh-CN.ts

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export default {
112112
department: '部门',
113113
organization: '组织',
114114
activity: '活动',
115+
meeting: '会议',
116+
NGO: 'NGO',
115117

116118
// Organization page
117119
reset: '重置',
@@ -263,4 +265,7 @@ export default {
263265
this_term_proposition: '本届主张',
264266
recommendation: '推荐语',
265267
vote_for_me: '投我一票',
268+
269+
// Member pages
270+
related: '相关',
266271
} as const;

translation/zh-TW.ts

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export default {
112112
department: '部門',
113113
organization: '組織',
114114
activity: '活動',
115+
meeting: '會議',
116+
NGO: 'NGO',
115117

116118
// Organization page
117119
reset: '重置',
@@ -263,4 +265,7 @@ export default {
263265
this_term_proposition: '本屆主張',
264266
recommendation: '推薦語',
265267
vote_for_me: '投我一票',
268+
269+
// Member pages
270+
related: '相關',
266271
} as const;

0 commit comments

Comments
 (0)