From 27690a836e0dc22d08aafbfa83e737ab48aa1153 Mon Sep 17 00:00:00 2001 From: Patrick Plate Date: Sat, 13 Jun 2026 17:11:20 +0200 Subject: [PATCH] fix: consent banner dismiss on decline + short viewport layout Bug 1: Clicking 'Ablehnen' now properly dismisses the dialog by calling the delete account mutation and signing out (previously it redirected to /settings/privacy which re-rendered the banner in a loop). Bug 2: Restructured the dialog layout with flex-col + overflow-y-auto on the content area only. Header and action buttons are pinned (shrink-0) so they're always accessible on short viewports. Added max-h constraint with min() to cap at 600px or 90vh. --- .../src/components/consent-banner.tsx | 87 +++++++++++-------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/cannamanage-frontend/src/components/consent-banner.tsx b/cannamanage-frontend/src/components/consent-banner.tsx index 288439e..2455bb9 100644 --- a/cannamanage-frontend/src/components/consent-banner.tsx +++ b/cannamanage-frontend/src/components/consent-banner.tsx @@ -3,8 +3,10 @@ import { useState } from "react" import { useConsentCheckQuery, + useDeleteAccountMutation, useGrantConsentMutation, } from "@/services/consent" +import { signOut } from "next-auth/react" import { useTranslations } from "next-intl" import { CheckCircle, Shield } from "lucide-react" @@ -19,6 +21,7 @@ export function ConsentBanner() { const { data: consentCheck, isLoading } = useConsentCheckQuery() const grantMutation = useGrantConsentMutation() + const deleteMutation = useDeleteAccountMutation() // Don't show if still loading or consent already granted if (isLoading || consentCheck?.hasDataProcessingConsent) { @@ -34,53 +37,60 @@ export function ConsentBanner() { } } - const handleReject = () => { - // Redirect to deletion confirmation - window.location.href = "/settings/privacy?action=delete" + const handleReject = async () => { + // Delete account and sign out — dismisses the dialog by leaving the app + await deleteMutation.mutateAsync() + await signOut({ callbackUrl: "/login" }) } + const isPending = grantMutation.isPending || deleteMutation.isPending + return ( -
-
-
+
+
+ {/* Header — fixed */} +

{t("title")}

- {/* Required: Data Processing */} -
-

{t("dataProcessing")}

-

- {t("dataProcessingDesc")} -

-

- {t("required")} -

+ {/* Scrollable content */} +
+ {/* Required: Data Processing */} +
+

{t("dataProcessing")}

+

+ {t("dataProcessingDesc")} +

+

+ {t("required")} +

+
+ + {/* Optional: Marketing */} +
+ +
- {/* Optional: Marketing */} -
- -
- - {/* Actions */} -
+ {/* Actions — fixed at bottom */} +