From b14d2d106f2b7ed0c771bd28c25ac9646f5f2c3c Mon Sep 17 00:00:00 2001 From: Carina Antunes <carina.oliveira.antunes@cern.ch> Date: Mon, 23 May 2022 18:26:31 +0200 Subject: [PATCH] audit external: review improvements --- .../NotificationDisplay/NotificationDisplay.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/notifications/components/NotificationDisplay/NotificationDisplay.js b/src/notifications/components/NotificationDisplay/NotificationDisplay.js index 31f21ec2..9ccb49e8 100644 --- a/src/notifications/components/NotificationDisplay/NotificationDisplay.js +++ b/src/notifications/components/NotificationDisplay/NotificationDisplay.js @@ -27,14 +27,18 @@ const NotificationDisplay = ({ } async function downloadAuditReport() { - const auditAdminData = await getAuditById(notification.id); - if (Object.keys(auditAdminData)?.length === 0) { - showSnackbar('An error occurred while downloading audit information', 'error'); + const response = await getAuditById(notification.id); + if (response.error) { + const msg = + response.payload.status === 404 + ? 'Audit not yet available. Please try again soon.' + : 'An error occurred while downloading audit information.'; + showSnackbar(msg, 'error'); return; } const url = window.URL.createObjectURL( - new Blob([JSON.stringify(auditAdminData)], {type: 'application/json'}) + new Blob([JSON.stringify(response.payload)], {type: 'application/json'}) ); const link = document.createElement('a'); link.href = url; -- GitLab