Repository navigation
feat: add export to excel functionality in reviewers and assignments tab in fap page #1839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
fbff885
4387ff6
0bfb265
1fdac5d
6b3ba40
402cb57
a48a5e7
e155f24
53535d2
90e1003
861fa05
eec575c
256d89b
20724b8
3126f6b
03d1db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,10 @@ import { | |
| DefaultCallExtraFapDataColumns, | ||
| collectCallFapXLSXData, | ||
| } from '../../factory/xlsx/callFaps'; | ||
| import { collectFapXLSXData } from '../../factory/xlsx/fap'; | ||
| import { | ||
| collectFapXLSXData, | ||
| collectFapReviewXLSXData, | ||
| } from '../../factory/xlsx/fap'; | ||
| import { collectManagementDecisionXLSXData } from '../../factory/xlsx/managementDecision'; | ||
| import { | ||
| collectProposalXLSXData, | ||
|
|
@@ -130,6 +133,79 @@ router.get(`/${XLSXType.FAP}/:fap_id/call/:call_id`, async (req, res, next) => { | |
| } | ||
| }); | ||
|
|
||
| router.get( | ||
| `/${XLSXType.FAP_REVIEWS}/:fap_id/call/:call_id`, | ||
| async (req, res, next) => { | ||
| try { | ||
| if (!req.user) { | ||
| throw new Error('Not authorized'); | ||
| } | ||
|
|
||
| const userWithRole = { | ||
| ...res.locals.agent, | ||
| }; | ||
|
Comment on lines
+144
to
+146
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to validate we are getting all the information we need from this object.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| const fapId = parseInt(req.params.fap_id); | ||
| const callId = parseInt(req.params.call_id); | ||
|
|
||
| if (isNaN(fapId) || isNaN(callId)) { | ||
| throw new Error( | ||
| `Invalid Fap or call ID: Fap ${req.params.fap_id}, Call ${req.params.call_id}` | ||
| ); | ||
| } | ||
|
|
||
| const reviewerProposalsParam = req.query.reviewerProposals; | ||
|
|
||
| if (typeof reviewerProposalsParam !== 'string') { | ||
| throw new Error('Proposal reviewer is required'); | ||
| } | ||
|
|
||
| const reviewerProposals: Record<number, number[]> = JSON.parse( | ||
| reviewerProposalsParam | ||
| ); | ||
|
|
||
| const { data, filename } = await collectFapReviewXLSXData( | ||
| fapId, | ||
| callId, | ||
| reviewerProposals, | ||
| userWithRole | ||
| ); | ||
|
|
||
| const meta: XLSXMetaBase = { | ||
| singleFilename: filename, | ||
| collectionFilename: filename, | ||
| columns: [ | ||
| 'Proposal ID', | ||
| 'Proposal title', | ||
| 'Instrument', | ||
| 'Date assigned', | ||
| 'Rank', | ||
| 'Grade', | ||
| 'Comment', | ||
| 'Status', | ||
| ], | ||
| }; | ||
|
|
||
| const userRole = req.user.currentRole; | ||
|
|
||
| callFactoryService( | ||
| DownloadType.XLSX, | ||
| XLSXType.FAP_REVIEWS, | ||
| { | ||
| data, | ||
| meta, | ||
| userRole, | ||
| }, | ||
| req, | ||
| res, | ||
| next | ||
| ); | ||
| } catch (e) { | ||
| next(e); | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| router.get(`/${XLSXType.CALL_FAP}/:call_id`, async (req, res, next) => { | ||
| try { | ||
| if (!req.user) { | ||
|
|
||
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.
Is there a legitimate case where
callIdis0?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.
The
callIdis set to0when no calls are selected in the frontend.