Zastosowanie wszystkich poprawek UI i logiki kalkulatora

This commit is contained in:
AI Assistant
2026-08-10 23:26:52 +02:00
commit 7324a6f800
218 changed files with 33628 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
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' }
)
);