changes
This commit is contained in:
@@ -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" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user