Hide audit report buttons when no file attached

When an audit has no report attached, neither the View nor Request access button should be displayed. Updated the conditional rendering to wrap the entire button section with the audit.report check instead of only checking it in the nested ternary.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-17 14:16:45 +01:00
parent 91a06d1fb5
commit 52b4951507

View File

@@ -121,28 +121,30 @@ export function AuditRow(props: { audit: AuditRowFragment$key }) {
<IconMedal size={16} className="flex-none text-txt-tertiary" />
{audit.name ?? audit.framework.name}
</div>
{audit.report && audit.report.isUserAuthorized
? (
<Button
className="w-full md:w-max"
variant="secondary"
icon={IconArrowLink}
to={`/documents/${audit.report.id}`}
>
{__("View")}
</Button>
)
: (
<Button
disabled={hasRequested || isRequestingAccess}
className="w-full md:w-max"
variant="secondary"
icon={IconLock}
onClick={handleRequestAccess}
>
{hasRequested ? __("Access requested") : __("Request access")}
</Button>
)}
{audit.report && (
audit.report.isUserAuthorized
? (
<Button
className="w-full md:w-max"
variant="secondary"
icon={IconArrowLink}
to={`/documents/${audit.report.id}`}
>
{__("View")}
</Button>
)
: (
<Button
disabled={hasRequested || isRequestingAccess}
className="w-full md:w-max"
variant="secondary"
icon={IconLock}
onClick={handleRequestAccess}
>
{hasRequested ? __("Access requested") : __("Request access")}
</Button>
)
)}
</div>
);
}