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 ( -
- {t("dataProcessingDesc")} -
-- {t("required")} -
+ {/* Scrollable content */} ++ {t("dataProcessingDesc")} +
++ {t("required")} +
+