From 5e0fadb36bbff5e3e5efd387999b6a82ea8daf61 Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Fri, 26 Jun 2026 10:16:30 -0400 Subject: [PATCH 1/2] Add Download PDF --- app/components/rfd/MoreDropdown.tsx | 4 ++++ app/routes/rfd.$slug.pdf.download.tsx | 33 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 app/routes/rfd.$slug.pdf.download.tsx diff --git a/app/components/rfd/MoreDropdown.tsx b/app/components/rfd/MoreDropdown.tsx index e6bbe5c..11f846f 100644 --- a/app/components/rfd/MoreDropdown.tsx +++ b/app/components/rfd/MoreDropdown.tsx @@ -48,6 +48,10 @@ const MoreDropdown = () => { )} + + Download PDF + + View PDF diff --git a/app/routes/rfd.$slug.pdf.download.tsx b/app/routes/rfd.$slug.pdf.download.tsx new file mode 100644 index 0000000..d31ead4 --- /dev/null +++ b/app/routes/rfd.$slug.pdf.download.tsx @@ -0,0 +1,33 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * Copyright Oxide Computer Company + */ + +import { redirect, type LoaderFunction } from 'react-router' + +import { authenticate } from '~/services/auth.server' +import { fetchRfdPdf } from '~/services/rfd.server' +import { parseRfdNum } from '~/utils/parseRfdNum' + +export const loader: LoaderFunction = async ({ request, params: { slug } }) => { + const num = parseRfdNum(slug) + if (!num) throw new Response('Not Found', { status: 404 }) + + const user = await authenticate(request) + const rfd = await fetchRfdPdf(num, user) + + if (!rfd || rfd.content.length === 0) throw new Response('Not Found', { status: 404 }) + + const pdf = rfd.content[0] + + if (pdf.source === 'google') { + throw redirect( + `https://drive.google.com/uc?export=download&id=${pdf.externalId}`, + ) + } + + throw redirect(pdf.link) +} From ae5f6c335945e9f19b876cbc420fa6e94e3e66f8 Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Fri, 26 Jun 2026 10:52:51 -0400 Subject: [PATCH 2/2] Format --- app/routes/rfd.$slug.pdf.download.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/routes/rfd.$slug.pdf.download.tsx b/app/routes/rfd.$slug.pdf.download.tsx index d31ead4..e84dd58 100644 --- a/app/routes/rfd.$slug.pdf.download.tsx +++ b/app/routes/rfd.$slug.pdf.download.tsx @@ -24,9 +24,7 @@ export const loader: LoaderFunction = async ({ request, params: { slug } }) => { const pdf = rfd.content[0] if (pdf.source === 'google') { - throw redirect( - `https://drive.google.com/uc?export=download&id=${pdf.externalId}`, - ) + throw redirect(`https://drive.google.com/uc?export=download&id=${pdf.externalId}`) } throw redirect(pdf.link)