This commit is contained in:
AI Assistant
2026-08-10 23:41:14 +02:00
parent 7324a6f800
commit 5f85f33af0
4 changed files with 40 additions and 14 deletions
+21 -1
View File
@@ -125,6 +125,26 @@ export function KalkulatorClient({ products }: Props) {
window.scrollTo({ top: 0, behavior: 'smooth' });
};
const getShopUrl = () => {
const params = new URLSearchParams();
if (category) params.set('category', category);
if (preferredBrand) params.set('brand', preferredBrand);
const avgInstallCost = (installCost.min + installCost.max) / 2;
const deviceBudget = Math.max(0, budget - avgInstallCost);
if (deviceBudget > 0) params.set('priceMax', Math.round(deviceBudget).toString());
if (category === 'scienne') {
if (requiredPowerRounded <= 2.5) params.set('room', 'Do 25 m²');
else if (requiredPowerRounded <= 3.5) params.set('room', '25-35 m²');
else if (requiredPowerRounded <= 5.0) params.set('room', '35-50 m²');
else params.set('room', 'Powyżej 50 m²');
} else if (category === 'multisplit') {
params.set('units', rooms.toString());
}
return `/sklep?${params.toString()}`;
};
return (
<main className="bg-slate-50 min-h-screen py-12">
@@ -599,7 +619,7 @@ export function KalkulatorClient({ products }: Props) {
Dalej <ArrowRight className="size-4" />
</button>
) : (
<Link href="/sklep" className="flex items-center gap-2 px-6 py-2.5 bg-accent text-white rounded-xl text-sm font-bold hover:bg-accent/90 transition-colors">
<Link href={getShopUrl()} className="flex items-center gap-2 px-6 py-2.5 bg-accent text-white rounded-xl text-sm font-bold hover:bg-accent/90 transition-colors">
Przejdź do sklepu <ArrowRight className="size-4" />
+1 -1
View File
@@ -140,7 +140,7 @@ export function Footer() {
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex flex-col sm:flex-row justify-between items-center gap-4">
<div className="flex flex-col gap-2">
<p className="text-xs text-slate-400 text-center sm:text-left">
© {currentYear} {companyDetails.name}. Wszelkie prawa zastrzeżone. Projekt strony i wdrożenie ThermCool.
© {currentYear} {companyDetails.name}. Wszelkie prawa zastrzeżone. Projekt strony i wdrożenie Powered by NetScale.
</p>
<CookieSettingsTrigger />
</div>
+10 -4
View File
@@ -80,6 +80,9 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
const urlSearch = searchParams.get('search') || '';
const urlBrand = searchParams.get('brand') || '';
const urlCategory = searchParams.get('category') || 'all';
const urlPriceMax = searchParams.get('priceMax') || '';
const urlRoom = searchParams.get('room') || '';
const urlUnits = searchParams.get('units') || '';
const [category, setCategory] = useState<'all' | 'scienne' | 'multisplit' | 'podlogowe' | 'jednostka-scienna'>(
urlCategory as 'all' | 'scienne' | 'multisplit' | 'podlogowe' | 'jednostka-scienna'
@@ -87,10 +90,10 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
const [selectedBrands, setSelectedBrands] = useState<string[]>(urlBrand ? [urlBrand] : []);
const [searchQuery, setSearchQuery] = useState(urlSearch);
const [priceMin, setPriceMin] = useState('');
const [priceMax, setPriceMax] = useState('');
const [selectedRooms, setSelectedRooms] = useState<string[]>([]);
const [priceMax, setPriceMax] = useState(urlPriceMax);
const [selectedRooms, setSelectedRooms] = useState<string[]>(urlRoom ? [urlRoom] : []);
const [selectedColors, setSelectedColors] = useState<string[]>([]);
const [selectedUnitCounts, setSelectedUnitCounts] = useState<number[]>([]);
const [selectedUnitCounts, setSelectedUnitCounts] = useState<number[]>(urlUnits ? [parseInt(urlUnits)] : []);
const [page, setPage] = useState(1);
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
@@ -104,10 +107,13 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
} else {
setCategory('all');
}
setPriceMax(urlPriceMax);
setSelectedRooms(urlRoom ? [urlRoom] : []);
setSelectedUnitCounts(urlUnits ? [parseInt(urlUnits)] : []);
setPage(1);
}, 0);
return () => clearTimeout(timer);
}, [urlSearch, urlBrand, urlCategory]);
}, [urlSearch, urlBrand, urlCategory, urlPriceMax, urlRoom, urlUnits]);
const toggleBrand = (b: string) => {
setSelectedBrands(prev => prev.includes(b) ? prev.filter(x => x !== b) : [...prev, b]);