feat: optymalizacja GlobalSearch, nawigacji oraz filtrów w sklepie

This commit is contained in:
MichalC
2026-06-27 21:12:23 +02:00
parent 0c59086a6b
commit c4294a81cf
43 changed files with 1623 additions and 192 deletions
+34 -16
View File
@@ -1,26 +1,44 @@
"use client";
'use client';
import { useEffect } from "react";
import { useConsentStore } from "@/lib/consent-store";
import { GoogleAnalytics, GoogleTagManager } from "@next/third-parties/google";
import Script from 'next/script';
import { useConsentStore } from '@/lib/consent-store';
const GA_ID = 'G-VW3GD6SS7K';
const CLARITY_ID = 'xdo6q3i06e';
export function AnalyticsWrapper() {
const { analytics, marketing, isInitialized, initialize } = useConsentStore();
const { analyticsConsent } = useConsentStore();
useEffect(() => {
initialize();
}, [initialize]);
if (!isInitialized) return null;
if (!analyticsConsent) return null;
return (
<>
{/* Ładujemy GTM tylko jeśli zgoda na marketing ATAK LUB analitykę,
w zależności od rygorystyczności, zazwyczaj GTM potrzebuje analityki/marketingu */}
{(analytics || marketing) && <GoogleTagManager gtmId="GTM-MBMRCD2N" />}
{/* Ładujemy GA4 tylko jeśli użytkownik zgodził się na analitykę */}
{analytics && <GoogleAnalytics gaId="G-1NGTSR4TWD" />}
{/* GA4 */}
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
strategy="afterInteractive"
/>
<Script id="ga4-init" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}', {
page_path: window.location.pathname,
});
`}
</Script>
{/* Microsoft Clarity */}
<Script id="clarity-init" strategy="afterInteractive">
{`
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "${CLARITY_ID}");
`}
</Script>
</>
);
}
+17 -5
View File
@@ -12,6 +12,7 @@ export function CookieBanner() {
analytics,
marketing,
setConsent,
setAnalyticsConsent,
acceptAll,
rejectOptional,
closeBanner
@@ -25,9 +26,20 @@ export function CookieBanner() {
const handleSaveSettings = () => {
setConsent(localAnalytics, localMarketing);
setAnalyticsConsent(localAnalytics);
setShowSettings(false);
};
const handleAcceptAll = () => {
acceptAll();
setAnalyticsConsent(true);
};
const handleRejectOptional = () => {
rejectOptional();
setAnalyticsConsent(false);
};
const handleOpenSettings = () => {
const hasConsent = localStorage.getItem('thermcool_cookie_consent_v1');
setLocalAnalytics(hasConsent ? analytics : true);
@@ -63,13 +75,13 @@ export function CookieBanner() {
<div className="flex flex-col sm:flex-row flex-wrap items-center gap-3 mt-6">
<button
onClick={acceptAll}
onClick={handleAcceptAll}
className="btn btn-primary text-white flex-grow sm:flex-grow-0 border-none shadow-md"
>
<Check className="w-4 h-4 mr-1 text-white" /> Akceptuj wszystkie
</button>
<button
onClick={rejectOptional}
onClick={handleRejectOptional}
className="btn btn-outline border-slate-600 text-slate-200 hover:bg-slate-800 hover:text-white hover:border-slate-500 flex-grow sm:flex-grow-0"
>
<X className="w-4 h-4 mr-1 text-slate-300" /> Tylko niezbędne
@@ -87,7 +99,7 @@ export function CookieBanner() {
{/* Przycisk zamknięcia wymusza "Tylko niezbędne" dla bezpieczeństwa */}
<button
onClick={rejectOptional}
onClick={handleRejectOptional}
className="absolute top-4 right-4 text-slate-500 hover:text-white p-1"
aria-label="Zamknij"
>
@@ -167,13 +179,13 @@ export function CookieBanner() {
<div className="p-5 border-t border-slate-700 bg-slate-800/50 flex flex-col-reverse sm:flex-row justify-end gap-3 items-center">
<button
onClick={rejectOptional}
onClick={handleRejectOptional}
className="btn btn-ghost text-slate-400 hover:text-white w-full sm:w-auto"
>
Odrzuć wszystkie
</button>
<button
onClick={acceptAll}
onClick={handleAcceptAll}
className="btn btn-outline border-slate-600 text-white hover:bg-slate-700 w-full sm:w-auto"
>
Akceptuj wszystkie