From 0b19f3ce086f7e6467b308ad429868677f767362 Mon Sep 17 00:00:00 2001 From: Talha Ahmed Date: Thu, 27 Aug 2026 19:26:31 +0500 Subject: [PATCH] =?UTF-8?q?CV=20bank:=20in-app=20preview=20=E2=80=94=20vie?= =?UTF-8?q?w=20a=20stored=20CV=20without=20downloading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each bank row gains an eye action that opens the PDF in a modal iframe. fetchBlobUrl learned an optional MIME re-type: /documents/download sends octet-stream, which would trigger a download instead of the inline viewer, so the blob is re-wrapped as application/pdf. Object URL revoked on close. Download and remove actions unchanged. Co-Authored-By: Claude Fable 5 --- frontend/dist/index.html | 2 +- frontend/src/api/candidates.js | 14 +++++++++- frontend/src/lib/apiClient.js | 15 ++++++----- frontend/src/screens/CvImport.jsx | 43 +++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/frontend/dist/index.html b/frontend/dist/index.html index cbca26d..a7a1f61 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -24,7 +24,7 @@ - + diff --git a/frontend/src/api/candidates.js b/frontend/src/api/candidates.js index 1afa119..b949343 100644 --- a/frontend/src/api/candidates.js +++ b/frontend/src/api/candidates.js @@ -12,7 +12,7 @@ function returns the parsed {data, total, status_code} envelope. ============================================================ */ -import { downloadFile, request } from '../lib/apiClient' +import { downloadFile, fetchBlobUrl, request } from '../lib/apiClient' /** Active job posts for pickers. Needs job_board.view OR candidates.view. * @@ -80,6 +80,18 @@ export function downloadCvBankCv(id) { return downloadFile('/documents/download', { params: { manual_upload_candidate_id: id } }) } +/** + * Object URL of a stored CV for IN-APP preview (no download). The route sends + * octet-stream, so the blob is re-typed to application/pdf for the browser's + * inline viewer. Caller revokes the URL when the preview closes. + */ +export function viewCvBankCv(id) { + return fetchBlobUrl('/documents/download', { + params: { manual_upload_candidate_id: id }, + type: 'application/pdf', + }) +} + /** * Score the decoded attachments of inbox messages against a job post. * Needs candidates.create. messageIds are inbox_messages PK uuids (the `id` diff --git a/frontend/src/lib/apiClient.js b/frontend/src/lib/apiClient.js index 9cf0bea..2935634 100644 --- a/frontend/src/lib/apiClient.js +++ b/frontend/src/lib/apiClient.js @@ -188,12 +188,14 @@ export async function downloadFile(path, { params, auth = true, filename } = {}) } /** - * Authenticated binary GET returning an object URL for /