Skip to content

Commit

Permalink
Remove hardcoding of the field name
Browse files Browse the repository at this point in the history
Refs #1712
  • Loading branch information
thewilkybarkid committed May 16, 2024
1 parent f0128d3 commit 073bdcf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/review-requests-page/review-requests-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { html, plainText } from '../html'
import { PageResponse } from '../response'
import { reviewRequestsMatch, writeReviewMatch } from '../routes'
import { renderDate } from '../time'
import { getFieldName } from '../types/field'
import type { ReviewRequests } from './review-requests'

export const createPage = ({ currentPage, totalPages, reviewRequests }: ReviewRequests) =>
Expand Down Expand Up @@ -40,9 +41,7 @@ export const createPage = ({ currentPage, totalPages, reviewRequests }: ReviewRe
${request.preprint.id.value === ('10.1101/2023.06.12.544578' as Doi)
? html`
<ul class="categories">
${['Biochemistry, Genetics and Molecular Biology', 'Immunology and Microbiology'].map(
field => html`<li>${field}</li>`,
)}
${['13' as const, '24' as const].map(field => html`<li>${getFieldName(field)}</li>`)}
</ul>
`
: ''}
Expand Down
34 changes: 34 additions & 0 deletions src/types/field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export type FieldId = keyof typeof fields

export function getFieldName(id: FieldId): string {
return fields[id]
}

const fields = {
'11': 'Agricultural and Biological Sciences',
'12': 'Arts and Humanities',
'13': 'Biochemistry, Genetics and Molecular Biology',
'14': 'Business, Management and Accounting',
'15': 'Chemical Engineering',
'16': 'Chemistry',
'17': 'Computer Science',
'18': 'Decision Sciences',
'19': 'Earth and Planetary Sciences',
'20': 'Economics, Econometrics and Finance',
'21': 'Energy',
'22': 'Engineering',
'23': 'Environmental Science',
'24': 'Immunology and Microbiology',
'25': 'Materials Science',
'26': 'Mathematics',
'27': 'Medicine',
'28': 'Neuroscience',
'29': 'Nursing',
'30': 'Pharmacology, Toxicology and Pharmaceutics',
'31': 'Physics and Astronomy',
'32': 'Psychology',
'33': 'Social Sciences',
'34': 'Veterinary',
'35': 'Dentistry',
'36': 'Health Professions',
}

0 comments on commit 073bdcf

Please sign in to comment.