-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
141 lines (128 loc) · 3.23 KB
/
Copy pathtypes.ts
File metadata and controls
141 lines (128 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
export interface Review {
id: string;
userName: string;
userImage: string;
rating: number;
comment: string;
timestamp: string;
createdAt?: number;
}
export type EntityCategory = 'Yoga' | 'Spa' | 'Nutrition' | 'Fitness' | 'Muay Thai' | 'Clinic' | 'Brand' | 'Event';
export interface WellnessEntity {
id: string;
name: string;
rating: number;
distance: string;
area: string;
points: number;
imageUrl: string;
category: EntityCategory;
description?: string;
reviews?: Review[];
startingPrice?: number;
}
export interface Trainer {
id: string;
name: string;
specialty: string;
rating: number;
imageUrl: string;
pointsPerSession: number;
bio: string;
}
export interface Product {
id: string;
name: string;
brand: string;
price: string;
points: number;
imageUrl: string;
category: 'Supplements' | 'Apparel' | 'Equipment';
}
export interface User {
name: string;
points: number;
tier: 'Bronze' | 'Silver' | 'Gold' | 'Elite';
streak: number;
profileImage: string;
}
export interface ClassSession {
id: string;
name: string;
instructor: string;
instructorImage: string;
time: string;
duration: string;
price: string;
points: number;
isFull?: boolean;
capacityStatus?: 'full' | 'almost-full' | 'few-spots' | 'available';
}
export interface Booking {
id: string;
studioName: string;
className: string;
date: string;
time: string;
instructor: string;
pointsEarned: number;
price: string;
status: 'upcoming' | 'completed' | 'cancelled';
}
export interface FeedPost {
id: string;
user: string;
userImage: string;
location: string;
imageUrl: string;
points: number;
caption: string;
likes: number;
comments: number;
timestamp: string;
type: string;
}
export const TIER_THRESHOLDS = {
SILVER: 2500,
GOLD: 5000
} as const;
export const DISCOUNT_RATES = {
BASE: 0.10,
SILVER: 0.15,
GOLD: 0.25
} as const;
export const TIER_BENEFITS = {
bronze: ['Standard App Access', '10% Discount', 'Base Point Rewards'],
silver: ['15% Global Discount', 'Priority Studio Booking', 'Exclusive Community Feed Perks'],
gold: ['25% Maximum Discount', 'Masterclass & VIP Events', 'Dedicated Wellness Concierge']
};
/**
* Centralized pricing engine to prevent logic drift
*/
export const pricingEngine = {
getDiscountRate: (points: number) => {
if (points >= TIER_THRESHOLDS.GOLD) return DISCOUNT_RATES.GOLD;
if (points >= TIER_THRESHOLDS.SILVER) return DISCOUNT_RATES.SILVER;
return DISCOUNT_RATES.BASE;
},
getTierName: (points: number) => {
if (points >= TIER_THRESHOLDS.GOLD) return 'gold';
if (points >= TIER_THRESHOLDS.SILVER) return 'silver';
return 'bronze';
},
calculateDiscount: (priceStr: string | number, rate: number) => {
const numericPrice = typeof priceStr === 'number'
? priceStr
: (parseInt(priceStr.replace(/\D/g, '')) || 0);
const discounted = Math.floor(numericPrice * (1 - rate));
const savings = numericPrice - discounted;
return {
original: numericPrice,
discounted,
savings,
formattedDiscounted: `฿${discounted.toLocaleString()}`,
formattedOriginal: `฿${numericPrice.toLocaleString()}`,
formattedSavings: `฿${savings.toLocaleString()}`
};
}
};