- Filtr 'Ilość jednostek wewn.' w sklepie (1–9 jednostek, checkboxy, liczniki) - Komponent RecentlyViewedProducts + Zustand store (recently-viewed-store.ts) - Pompy ciepła dodane do sklepu i nawigacji (Header + MobileMenu) - Logotypy marek zaktualizowane (Daikin, Panasonic + odświeżone istniejące) - Checkbox zgody RODO w /zamowienie powiększony (w-5 h-5) - Usunięcie ~65 zbędnych komentarzy WHAT z 12 plików (build: 0 errors) - Plik analyze_products.ts (pomocniczy skrypt diagnostyczny)
30 lines
807 B
TypeScript
30 lines
807 B
TypeScript
import { create } from 'zustand';
|
|
import { persist } from 'zustand/middleware';
|
|
import { Product } from '@/content/products';
|
|
|
|
interface RecentlyViewedState {
|
|
items: Product[];
|
|
addItem: (item: Product) => void;
|
|
clear: () => void;
|
|
}
|
|
|
|
export const useRecentlyViewedStore = create<RecentlyViewedState>()(
|
|
persist(
|
|
(set) => ({
|
|
items: [],
|
|
|
|
addItem: (newItem) => {
|
|
set((state) => {
|
|
// Usuń, jeśli już jest na liście (aby przenieść na początek)
|
|
const filtered = state.items.filter((i) => i.slug !== newItem.slug);
|
|
// Dodaj na początek, zachowaj tylko ostatnie 4
|
|
return { items: [newItem, ...filtered].slice(0, 4) };
|
|
});
|
|
},
|
|
|
|
clear: () => set({ items: [] }),
|
|
}),
|
|
{ name: 'thermcool-recently-viewed' }
|
|
)
|
|
);
|