Allowing local lemonsqueezy payment skip and emulate success response
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-02-04 10:39:53 +01:00
parent a07cc9610b
commit 049c4f82b9
7 changed files with 531 additions and 5 deletions

View File

@@ -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 && (