Skip to content

Commit e7eff9b

Browse files
committed
feat(pr): add proper peer review stuff
1 parent 1f63477 commit e7eff9b

6 files changed

Lines changed: 121 additions & 107 deletions

File tree

apps/peer-review/app/ReviewSummary.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import { Disclosure, Transition } from '@headlessui/react'
44
import PaperClipIcon from '@heroicons/react/outline/PaperClipIcon'
5-
import { Review } from './[pr]/page'
5+
import { ReviewAssignment } from './pr/[pr]/page'
66

7-
export function ReviewSummary({ review }: { review: Review }) {
7+
export function ReviewSummary({ review }: { review: ReviewAssignment }) {
88
return (
99
<div className="bg-white border border-black overflow-hidden " key={review.reviewerId}>
1010
<div className="px-4 py-5 sm:px-6">
@@ -29,24 +29,19 @@ export function ReviewSummary({ review }: { review: Review }) {
2929
{review.reviewerComments?.[0]?.authorEmail?.toLowerCase()}
3030
</dd>
3131
</div>
32-
<div className="sm:col-span-1">
33-
<dt className="text-sm font-medium text-gray-500">Salary expectation</dt>
34-
<dd className="mt-1 text-sm text-gray-900">$120,000</dd>
35-
</div>
3632
<div className="sm:col-span-2">
3733
<dt className="text-sm font-medium text-gray-500">Reviewer Comments</dt>
3834
<dd className="mt-1 text-sm text-gray-900">
3935
<Disclosure>
4036
{({ open }) => (
4137
<>
4238
<Disclosure.Button className="text-indigo-600 hover:text-indigo-500">
43-
Show more {`${open}`}
39+
{open ? 'Hide' : 'Show'} reviewer comments
4440
</Disclosure.Button>
4541

4642
{/*
4743
Use the `Transition` + `open` render prop argument to add transitions.
4844
*/}
49-
<Disclosure.Panel>AAAAAAAAA</Disclosure.Panel>
5045
<Transition
5146
show={open}
5247
enter="transition duration-100 ease-out"
@@ -59,15 +54,14 @@ export function ReviewSummary({ review }: { review: Review }) {
5954
{/*
6055
Don't forget to add `static` to your `Disclosure.Panel`!
6156
*/}
62-
{/* <Disclosure.Panel>
57+
<Disclosure.Panel>
6358
<div
64-
className="prose"
65-
dangerouslySetInnerHTML={{
66-
__html: review.reviewerComments?.[0]?.comments,
67-
}}
68-
/>
69-
Yes! You can purchase a license that you can share with your entire team.
70-
</Disclosure.Panel> */}
59+
className="prose"
60+
dangerouslySetInnerHTML={{
61+
__html: review.reviewerComments?.[0]?.comments,
62+
}}
63+
/>
64+
</Disclosure.Panel>
7165
</Transition>
7266
</>
7367
)}

apps/peer-review/app/doi/page.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

apps/peer-review/app/layout.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import '../styles.css'
22

33
export default function Layout({ children }: { children: React.ReactNode }) {
44
return (
5-
<div className="container">
6-
<main>{children}</main>
7-
</div>
5+
<html>
6+
<head></head>
7+
<body>
8+
<div className="container">
9+
<main>{children}</main>
10+
</div>
11+
</body>
12+
</html>
813
)
914
}
Lines changed: 91 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
import { ReviewSummary } from 'apps/peer-review/app/ReviewSummary'
2-
interface Reviews {
3-
reviewRound: ReviewRound
2+
import { format } from 'date-fns'
3+
interface Response {
4+
_href: string
5+
contextId: number
6+
currentPublicationId: number
7+
dateLastActivity: string
8+
dateSubmitted: string
9+
doiSuffix?: any
10+
id: number
11+
lastModified: string
12+
locale: string
13+
'pub-id::doi'?: any
14+
publications: Publication[]
15+
stageId: number
16+
stages: Stage[]
17+
status: number
18+
statusLabel: string
19+
submissionProgress: number
20+
urlAuthorWorkflow: string
21+
urlEditorialWorkflow: string
22+
urlPublished: string
23+
urlWorkflow: string
424
reviews: Review[]
525
}
626

727
export interface Review {
28+
reviewRound: ReviewRound
29+
reviewAssignments: ReviewAssignment[]
30+
}
31+
32+
export interface ReviewAssignment {
833
id: number
934
submissionId: number
1035
reviewerId: number
@@ -27,10 +52,15 @@ export interface Review {
2752
unconsidered: number
2853
reviewMethodKey: string
2954
recommendationText: string
30-
status: number
55+
status: string
3156
statusKey: string
3257
reviewFiles: ReviewFile[]
3358
reviewerComments: ReviewerComment[]
59+
isCurrentUserAssigned: boolean
60+
statusId: number
61+
due: string
62+
responseDue: string
63+
roundId: number
3464
}
3565

3666
interface ReviewerComment {
@@ -50,11 +80,11 @@ interface ReviewFile {
5080
caption?: any
5181
copyrightOwner?: any
5282
createdAt: string
53-
creator: Creator
83+
creator: FullTitle
5484
credit?: any
5585
dateCreated?: any
5686
dependentFiles: any[]
57-
description: Creator
87+
description: FullTitle
5888
documentType: string
5989
doiSuffix?: any
6090
fileId: number
@@ -64,15 +94,15 @@ interface ReviewFile {
6494
language?: any
6595
locale: string
6696
mimetype: string
67-
name: Creator
97+
name: FullTitle
6898
path: string
6999
'pub-id::doi'?: any
70-
publisher: Creator
100+
publisher: FullTitle
71101
revisions: any[]
72-
source: Creator
102+
source: FullTitle
73103
sourceSubmissionFileId?: any
74-
sponsor: Creator
75-
subject: Creator
104+
sponsor: FullTitle
105+
subject: FullTitle
76106
submissionId: number
77107
terms?: any
78108
updatedAt: string
@@ -81,44 +111,30 @@ interface ReviewFile {
81111
viewable?: any
82112
}
83113

84-
interface Creator {
85-
en_US: string
86-
}
87-
88114
interface ReviewRound {
89115
id: number
90116
submissionId: number
91117
stageId: number
92118
round: number
93-
status: number
119+
status: string
94120
statusKey: string
121+
statusId: number
95122
}
96123

97-
interface Submission {
98-
itemsMax: number
99-
items: SubmissionItem[]
124+
interface Stage {
125+
id: number
126+
label: string
127+
isActiveStage: boolean
128+
queries: any[]
129+
currentUserAssignedRoles: any[]
130+
files: Files
131+
statusId?: number
132+
status?: string
133+
currentUserCanRecommendOnly?: boolean
100134
}
101135

102-
export interface SubmissionItem {
103-
_href: string
104-
contextId: number
105-
currentPublicationId: number
106-
dateLastActivity: string
107-
dateSubmitted: string
108-
doiSuffix?: any
109-
id: number
110-
lastModified: string
111-
locale: string
112-
'pub-id::doi'?: any
113-
publications: Publication[]
114-
stageId: number
115-
status: number
116-
statusLabel: string
117-
submissionProgress: number
118-
urlAuthorWorkflow: string
119-
urlEditorialWorkflow: string
120-
urlPublished: string
121-
urlWorkflow: string
136+
interface Files {
137+
count: number
122138
}
123139

124140
interface Publication {
@@ -133,10 +149,10 @@ interface Publication {
133149
galleys: any[]
134150
id: number
135151
locale: string
136-
pages?: string
152+
pages?: any
137153
prefix: FullTitle
138154
primaryContactId: number
139-
'pub-id::doi'?: string
155+
'pub-id::doi'?: any
140156
'pub-id::publisher-id'?: any
141157
sectionId: number
142158
status: number
@@ -157,13 +173,13 @@ interface CoverImage {
157173

158174
const fetchPR = async (submission: string) => {
159175
try {
160-
const url = `${process.env.OJS_URL}/_reviews/${submission}/reviews?apiToken=${process.env.OJS_TOKEN}`
176+
const url = `${process.env.OJS_URL}/_reviews/${submission}?apiToken=${process.env.OJS_TOKEN}`
161177
const res = await fetch(url)
162-
return res.json() as Promise<Reviews[]>
178+
return res.json() as Promise<Response>
163179
} catch (e) {
164180
console.error('ERROR')
165181
console.error(e)
166-
return []
182+
return {} as Response
167183
}
168184
}
169185

@@ -184,7 +200,7 @@ export const fetchSubmission = async (
184200
console.log({ url })
185201
const res = await fetch(url)
186202
console.log({ res })
187-
return res.json() as Promise<SubmissionItem>
203+
return res.json() as Promise<Response>
188204
} catch (e) {
189205
console.error('ERROR')
190206
console.error(e)
@@ -198,9 +214,9 @@ export default async function Page(props: { params: { pr: string } }) {
198214
} = props
199215

200216
console.log({ props })
201-
const thing = await fetchPR(pr)
202-
const submission = await fetchSubmission(pr)
203-
console.log({ submission })
217+
const submission = await fetchPR(pr)
218+
// const submission = await fetchSubmission(pr)
219+
// console.dir({ submission }, { depth: null })
204220
if (!submission) {
205221
return <div>Submission not found</div>
206222
}
@@ -219,36 +235,52 @@ export default async function Page(props: { params: { pr: string } }) {
219235
</div>
220236
<div className="flex flex-col gap-2">
221237
<span className="text-lg font-normal">Submitted</span>
222-
<span className="font-normal">{submission.dateSubmitted}</span>
238+
239+
<span className="font-normal">
240+
{format(new Date(submission.dateSubmitted), 'MMM d, yyyy, h:mm a')}
241+
</span>
223242
</div>
224243

225244
<div className="flex flex-col gap-2">
226-
<span className="text-lg font-normal">Last Activity</span>
227-
<span className="font-normal">{submission.lastModified}</span>
245+
<span className="text-lg font-normal">Latest Activity</span>
246+
{format(new Date(submission.lastModified), 'MMM d, yyyy, h:mm a')}
228247
</div>
229248

230249
<div className="flex flex-col gap-2">
231250
<span className="text-lg font-normal">Status</span>
232251
<span className="font-normal">{submission.statusLabel}</span>
233252
</div>
234253

254+
{/* Names of the Reviewers */}
235255
<div className="flex flex-col gap-2">
236-
<span className="text-lg font-normal">Progress</span>
237-
<span className="font-normal">{submission.submissionProgress}%</span>
256+
<span className="text-lg font-normal">Reviewers</span>
257+
<span className="font-normal">
258+
{submission.reviews.map((review) => (
259+
<div className="flex flex-col gap-4" key={review.reviewRound.id}>
260+
{review.reviewAssignments.map((reviewer) => (
261+
<div className="flex flex-col gap-4" key={reviewer.reviewerId}>
262+
<span className="font-normal">{reviewer.reviewerFullName}</span>
263+
</div>
264+
))}
265+
</div>
266+
))}
267+
</span>
238268
</div>
239269

240-
<div className="flex flex-col gap-2">
241-
<span className="text-lg font-normal">DOI</span>
242-
<span className="font-normal">{submission.publications?.[0]?.['pub-id::doi']}</span>
243-
</div>
270+
{submission.publications?.[0]?.['pub-id::doi'] && (
271+
<div className="flex flex-col gap-2">
272+
<span className="text-lg font-normal">DOI</span>
273+
<span className="font-normal">{submission.publications?.[0]?.['pub-id::doi']}</span>
274+
</div>
275+
)}
244276

245277
<div className="flex flex-col gap-8">
246-
{thing.map((review) => (
278+
{submission.reviews.map((review) => (
247279
<div className="flex flex-col gap-4" key={review.reviewRound.id}>
248280
<h2 className="text-2xl font-bold">Review Round {review.reviewRound.round}</h2>
249-
<h3 className="text-lg font-bold">{review.reviewRound.statusKey}</h3>
281+
<h3 className="text-lg">{review.reviewRound.status}</h3>
250282
<div className="flex flex-col gap-8">
251-
{review.reviews.map((review) => (
283+
{review.reviewAssignments.map((review) => (
252284
<ReviewSummary review={review} key={review.id} />
253285
))}
254286
</div>

apps/peer-review/tsconfig.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
"resolveJsonModule": true,
1212
"isolatedModules": true,
1313
"incremental": true,
14-
"types": ["jest", "node"],
14+
"types": [
15+
"jest",
16+
"node"
17+
],
1518
"module": "esnext",
1619
"plugins": [
1720
{
@@ -27,7 +30,12 @@
2730
"next-env.d.ts",
2831
".next/types/**/*.ts",
2932
"postcss.config.cjs",
30-
"../../dist/apps/peer-review/.next/types/**/*.ts"
33+
"../../dist/apps/peer-review/.next/types/**/*.ts",
34+
"../../apps/peer-review/.next/types/**/*.ts"
3135
],
32-
"exclude": ["node_modules", "jest.config.ts", "../../dist/apps/peer-review/.next/types/**/*.ts"]
36+
"exclude": [
37+
"node_modules",
38+
"jest.config.ts",
39+
"../../dist/apps/peer-review/.next/types/**/*.ts"
40+
]
3341
}

0 commit comments

Comments
 (0)