1
1
import { text2color } from 'idea-react' ;
2
2
import { marked } from 'marked' ;
3
+ import { textJoin } from 'mobx-i18n' ;
3
4
import { observer } from 'mobx-react' ;
4
5
import { compose , errorLogger , translator } from 'next-ssr-middleware' ;
5
6
import { Component } from 'react' ;
6
7
import { Badge , Breadcrumb , Col , Container , Image , Row } from 'react-bootstrap' ;
7
8
import { formatDate } from 'web-utility' ;
8
9
10
+ import { ActivityCard } from '../../components/Activity/Card' ;
11
+ import { ArticleCard } from '../../components/Article/Card' ;
9
12
import { CommentBox } from '../../components/Base/CommentBox' ;
10
13
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' ;
11
17
import { PageHead } from '../../components/Layout/PageHead' ;
18
+ import { OrganizationCard } from '../../components/Organization/Card' ;
19
+ import { Activity , SearchActivityModel } from '../../models/Activity' ;
12
20
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' ;
13
28
import { Personnel , PersonnelModel } from '../../models/Personnel' ;
29
+ import {
30
+ Department ,
31
+ SearchDepartmentModel ,
32
+ } from '../../models/Personnel/Department' ;
14
33
import { Person , PersonModel } from '../../models/Personnel/Person' ;
15
-
34
+ import { Article , SearchArticleModel } from '../../models/Product/Article' ;
16
35
interface PersonDetailPageProps {
17
36
person : Person ;
18
37
personnels : Personnel [ ] ;
38
+ articles : Article [ ] ;
39
+ departments : Department [ ] ;
40
+ meetings : Meeting [ ] ;
41
+ activitys : Activity [ ] ;
42
+ communitys : Community [ ] ;
43
+ organizations : Organization [ ] ;
44
+ NGOs : Organization [ ] ;
19
45
}
20
46
21
47
export const getServerSideProps = compose < { name : string } , PersonDetailPage > (
@@ -31,8 +57,38 @@ export const getServerSideProps = compose<{ name: string }, PersonDetailPage>(
31
57
recipient : name ,
32
58
} ) ;
33
59
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
+
34
90
return {
35
- props : JSON . parse ( JSON . stringify ( { person , personnels } ) ) ,
91
+ props : JSON . parse ( JSON . stringify ( searchResults ) ) ,
36
92
} ;
37
93
} ,
38
94
) ;
@@ -137,8 +193,108 @@ export default class PersonDetailPage extends Component<PersonDetailPageProps> {
137
193
</ li >
138
194
) ;
139
195
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
+
140
286
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 ;
142
298
143
299
return (
144
300
< Container className = "py-5" >
@@ -165,6 +321,13 @@ export default class PersonDetailPage extends Component<PersonDetailPageProps> {
165
321
< hr className = "my-5" />
166
322
167
323
{ 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 ) }
168
331
</ Col >
169
332
</ Row >
170
333
0 commit comments