fix: consent banner fails open on API error (500/403)

The consent check endpoint (/consent/check) returns 500 via the
proxy when the backend returns 403 (missing JWT forwarding).
Previously this caused the banner to show permanently since
consentCheck was undefined. Now isError = true hides the banner
(fail-open strategy — don't block users when backend is unavailable).
This commit is contained in:
Patrick Plate
2026-06-13 17:30:19 +02:00
parent 27690a836e
commit 9aaf771469
@@ -19,12 +19,12 @@ export function ConsentBanner() {
const t = useTranslations("consent") const t = useTranslations("consent")
const [marketingChecked, setMarketingChecked] = useState(false) const [marketingChecked, setMarketingChecked] = useState(false)
const { data: consentCheck, isLoading } = useConsentCheckQuery() const { data: consentCheck, isLoading, isError } = useConsentCheckQuery()
const grantMutation = useGrantConsentMutation() const grantMutation = useGrantConsentMutation()
const deleteMutation = useDeleteAccountMutation() const deleteMutation = useDeleteAccountMutation()
// Don't show if still loading or consent already granted // Don't show if loading, errored (fail open), or consent already granted
if (isLoading || consentCheck?.hasDataProcessingConsent) { if (isLoading || isError || consentCheck?.hasDataProcessingConsent) {
return null return null
} }