Skip to content

Commit

Permalink
feat: link to UCAS PDF using infosys servedocument.cgi
Browse files Browse the repository at this point in the history
  • Loading branch information
zaki-amin committed Nov 1, 2024
1 parent 544c271 commit 2907a6f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/applications/[cycle]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default async function AdmissionsCycleApplicationsPage({
</Flex>
</Flex>
<ApplicationTable
cycle={cycle}
applications={JSON.parse(JSON.stringify(applications))}
reviewerIds={reviewerIds}
user={{ email: userEmail, role: user?.role }}
Expand Down
24 changes: 22 additions & 2 deletions components/ApplicationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {
User,
WP
} from '@prisma/client'
import { MagnifyingGlassIcon } from '@radix-ui/react-icons'
import { Link2Icon, MagnifyingGlassIcon } from '@radix-ui/react-icons'
import { Card, Flex, Text, TextField } from '@radix-ui/themes'
import { ColumnFiltersState, createColumnHelper } from '@tanstack/react-table'
import { useSession } from 'next-auth/react'
import Link from 'next/link'
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import React, { FC, useEffect, useState } from 'react'

Expand All @@ -40,12 +41,14 @@ const SEARCH_PARAM_REVIEWER = 'reviewer'
const columnHelper = createColumnHelper<ApplicationRow>()

interface ApplicationTableProps {
cycle: number
applications: ApplicationRow[]
reviewerIds: string[]
user: { email: string; role?: Role }
}

const ApplicationTable: FC<ApplicationTableProps> = ({
cycle,
applications,
reviewerIds,
user: { email, role }
Expand Down Expand Up @@ -94,7 +97,7 @@ const ApplicationTable: FC<ApplicationTableProps> = ({
id: 'applicant.cid'
}),
columnHelper.accessor('applicant.ucasNumber', {
cell: (info) => info.getValue(),
cell: (info) => <UcasApplicationLink admissionsCycle={cycle} ucasNumber={info.getValue()} />,
header: 'UCAS Number',
id: 'applicant.ucasNumber'
}),
Expand Down Expand Up @@ -208,4 +211,21 @@ const WPColourMap: Record<WP, 'green' | 'red' | 'yellow'> = {
[WP.NOT_CALCULATED]: 'yellow'
}

const UcasApplicationLink: FC<{ admissionsCycle: number; ucasNumber: string }> = ({
admissionsCycle,
ucasNumber
}) => {
const transformedCycle = '20' + admissionsCycle.toString().slice(0, 2)
const cgiLink = `https://infosys.doc.ic.ac.uk/UGinterviews/servedocument.cgi?key=${transformedCycle}:${ucasNumber}`

return (
<Link href={cgiLink} target="_blank">
<Flex align="center" gap="1">
<Link2Icon />
{ucasNumber}
</Flex>
</Link>
)
}

export default ApplicationTable

0 comments on commit 2907a6f

Please sign in to comment.