Allowing local lemonsqueezy payment skip and emulate success response
This commit is contained in:
@@ -13,6 +13,8 @@ import { Switch } from '@/components/ui/switch';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { useConsent, ConsentPreferences } from '@/contexts/consent';
|
||||
|
||||
const SKIP_BANNER_STORAGE_KEY = 'fotospiel.consent.skip';
|
||||
|
||||
const CookieBanner: React.FC = () => {
|
||||
const { t } = useTranslation('common');
|
||||
const {
|
||||
@@ -28,6 +30,35 @@ const CookieBanner: React.FC = () => {
|
||||
|
||||
const [draftPreferences, setDraftPreferences] = useState<ConsentPreferences>(preferences);
|
||||
|
||||
const shouldSkipBanner = useMemo(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const hasSkipParam = params.get('consent') === 'skip' || params.get('cookieBanner') === 'off';
|
||||
|
||||
if (hasSkipParam) {
|
||||
try {
|
||||
window.localStorage.setItem(SKIP_BANNER_STORAGE_KEY, '1');
|
||||
} catch (error) {
|
||||
console.warn('[Consent] Failed to persist skip flag', error);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return window.localStorage.getItem(SKIP_BANNER_STORAGE_KEY) === '1';
|
||||
} catch (error) {
|
||||
console.warn('[Consent] Failed to read skip flag', error);
|
||||
return false;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (isPreferencesOpen) {
|
||||
setDraftPreferences(preferences);
|
||||
@@ -51,6 +82,10 @@ const CookieBanner: React.FC = () => {
|
||||
closePreferences();
|
||||
};
|
||||
|
||||
if (shouldSkipBanner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{showBanner && !isPreferencesOpen && (
|
||||
|
||||
Reference in New Issue
Block a user