From 7d5b72e1d334c1a7dd8b782047f2995e31856442 Mon Sep 17 00:00:00 2001 From: ponzischeme89 Date: Sun, 31 May 2026 07:37:29 +1200 Subject: [PATCH] v4.0.0.4 - Pricing changes --- src/lib/content/dog-walking.ts | 1 - src/lib/content/pack-walks.ts | 1 - src/lib/content/puppy-visits.ts | 1 - src/lib/utils/pricing.test.ts | 6 +++--- src/lib/utils/pricing.ts | 6 ++---- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib/content/dog-walking.ts b/src/lib/content/dog-walking.ts index 592c009..fbd5b61 100644 --- a/src/lib/content/dog-walking.ts +++ b/src/lib/content/dog-walking.ts @@ -90,7 +90,6 @@ export const dogWalkingContent: ServicePageContent = { title: '45 Minute Solo Walk', price: '$55', period: 'Per Walk', - popular: true, features: ['Free pickup and drop-off', 'Balanced walk length for most dogs', 'Time for calm handling and structure', 'Most popular length'] }, { diff --git a/src/lib/content/pack-walks.ts b/src/lib/content/pack-walks.ts index fb089f6..45690d9 100644 --- a/src/lib/content/pack-walks.ts +++ b/src/lib/content/pack-walks.ts @@ -85,7 +85,6 @@ export const packWalksContent: ServicePageContent = { title: '2-3 Walks Per Week', price: '$55', period: 'Per Walk', - popular: true, features: ['Two to three regular walks each week', 'Free pickup and drop-off', 'Consistent exercise and social time', 'Most popular routine'] }, { diff --git a/src/lib/content/puppy-visits.ts b/src/lib/content/puppy-visits.ts index 64ce7aa..6416d79 100644 --- a/src/lib/content/puppy-visits.ts +++ b/src/lib/content/puppy-visits.ts @@ -75,7 +75,6 @@ export const puppyVisitsContent: ServicePageContent = { title: '45 Minute Visit', price: '$49', period: 'Per Visit', - popular: true, features: ['Toilet break and feeding if needed', 'Play and enrichment time', 'Early routine-building support', 'Most popular visit length'] }, { diff --git a/src/lib/utils/pricing.test.ts b/src/lib/utils/pricing.test.ts index 66ba35d..8c44267 100644 --- a/src/lib/utils/pricing.test.ts +++ b/src/lib/utils/pricing.test.ts @@ -3,17 +3,17 @@ import { describe, expect, it } from 'vitest'; import { decoratePlans } from './pricing'; describe('decoratePlans', () => { - it('prefers an explicit popular plan over the cheapest plan', () => { + it('always highlights the cheapest plan, ignoring any popular flag', () => { const plans = decoratePlans([ { title: 'Cheapest', price: '$39', period: 'Per Walk' }, { title: 'Recommended', price: '$49', period: 'Per Walk', popular: true }, { title: 'Longest', price: '$55', period: 'Per Walk' } ]); - expect(plans.map((plan) => plan.isPopular)).toEqual([false, true, false]); + expect(plans.map((plan) => plan.isPopular)).toEqual([true, false, false]); }); - it('falls back to the cheapest plan when none is marked popular', () => { + it('highlights the cheapest plan regardless of order', () => { const plans = decoratePlans([ { title: 'Weekly', price: '$58', period: 'Per Walk' }, { title: 'Regular', price: '$55', period: 'Per Walk' }, diff --git a/src/lib/utils/pricing.ts b/src/lib/utils/pricing.ts index e8cd0c9..28cff87 100644 --- a/src/lib/utils/pricing.ts +++ b/src/lib/utils/pricing.ts @@ -11,10 +11,8 @@ export function decoratePlans(plans })); const sorted = [...enriched].sort((a, b) => a.value - b.value || a.index - b.index); - const explicitPopularIndex = plans.findIndex( - (plan) => 'popular' in plan && Boolean((plan as T & { popular?: boolean }).popular) - ); - const featuredIndex = explicitPopularIndex >= 0 ? explicitPopularIndex : (sorted[0]?.index ?? -1); + // The cheapest plan is always the highlighted one, on desktop and mobile. + const featuredIndex = sorted[0]?.index ?? -1; const mobileOrder = new Map(sorted.map((entry, order) => [entry.index, order])); return plans.map((plan, index) => ({