@@ -47,6 +47,13 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
47
47
} ,
48
48
} ) ;
49
49
50
+ const national_coordinator_deputy_role = await db . role . findFirst ( {
51
+ where : { type : "national_coordinator_deputy" } ,
52
+ select : {
53
+ id : true ,
54
+ } ,
55
+ } ) ;
56
+
50
57
const national_representative_role = await db . role . findFirst ( {
51
58
where : { type : "national_representative" } ,
52
59
select : {
@@ -55,6 +62,7 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
55
62
} ) ;
56
63
57
64
const national_coordinator_role_id = national_coordinator_role ?. id ;
65
+ const national_coordinator_deputy_role_id = national_coordinator_deputy_role ?. id ;
58
66
const national_representative_role_id = national_representative_role ?. id ;
59
67
60
68
const [ countries , total ] = await Promise . all ( [
@@ -63,10 +71,18 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
63
71
institutions : {
64
72
select : {
65
73
name : true ,
74
+ startDate : true ,
75
+ endDate : true ,
66
76
types : true ,
67
77
url : true ,
68
78
} ,
69
79
} ,
80
+ outreach : {
81
+ select : {
82
+ type : true ,
83
+ url : true ,
84
+ } ,
85
+ } ,
70
86
users : {
71
87
select : {
72
88
name : true ,
@@ -77,6 +93,7 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
77
93
where : {
78
94
OR : [
79
95
{ roleId : { equals : national_coordinator_role_id } } ,
96
+ { roleId : { equals : national_coordinator_deputy_role_id } } ,
80
97
{ roleId : { equals : national_representative_role_id } } ,
81
98
] ,
82
99
} ,
@@ -127,13 +144,38 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
127
144
. map ( ( contribution ) => {
128
145
return contribution . person . name . trim ( ) ;
129
146
} ) ;
147
+ const nationalCoordinatorDeputies = country . contributions
148
+ . filter ( ( contribution ) => {
149
+ return contribution . role . type === "national_coordinator_deputy" ;
150
+ } )
151
+ . map ( ( contribution ) => {
152
+ return contribution . person . name . trim ( ) ;
153
+ } ) ;
130
154
const nationalCoordinators = [
131
155
...new Set ( nationalCoordinatorUsers . concat ( nationalCoordinatorPersons ) ) ,
132
156
] ;
157
+ const outreachUrl = country . outreach . find ( ( outreach ) => {
158
+ return outreach . type === "national_website" ;
159
+ } ) ?. url ;
160
+ const partnerInstitutionsResult = country . institutions . filter ( ( institution ) => {
161
+ return institution . types . includes ( "partner_institution" ) ;
162
+ } ) ;
163
+
164
+ const partnerInstitutions = partnerInstitutionsResult . map ( ( partnerInstitution ) => {
165
+ const { name, startDate, endDate, url : website } = partnerInstitution ;
166
+ return {
167
+ name,
168
+ startDate,
169
+ endDate,
170
+ website,
171
+ } ;
172
+ } ) ;
133
173
134
174
return {
135
175
name : country . name ,
136
176
code : country . code ,
177
+ consortiumName : country . consortiumName ,
178
+ description : country . description ,
137
179
startDate : country . startDate ,
138
180
endDate : country . endDate ,
139
181
type : country . type ,
@@ -148,6 +190,9 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
148
190
urls : nationalCoordinatingInstitution . url ,
149
191
} ,
150
192
nationalCoordinators,
193
+ nationalCoordinatorDeputies,
194
+ outreachUrl,
195
+ partnerInstitutions,
151
196
} ;
152
197
} ) ;
153
198
0 commit comments