v4.0.0.4 - Pricing changes

This commit is contained in:
2026-05-31 07:37:29 +12:00
parent 91b22c6d60
commit 7d5b72e1d3
5 changed files with 5 additions and 10 deletions
-1
View File
@@ -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']
},
{
-1
View File
@@ -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']
},
{
-1
View File
@@ -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']
},
{
+3 -3
View File
@@ -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' },
+2 -4
View File
@@ -11,10 +11,8 @@ export function decoratePlans<T extends { price: string; period: string }>(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) => ({