@code-collective/booking-widget 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/booking-widget.css +1 -1
- package/dist/booking-widget.js +1762 -2036
- package/dist/booking-widget.min.js +7 -7
- package/dist/booking-widget.umd.cjs +2 -2
- package/package.json +1 -1
- package/src/lib/CartBar.svelte +3 -1
- package/src/lib/CartOverviewButton.svelte +14 -36
- package/src/lib/Checkout.svelte +17 -0
- package/src/lib/CheckoutModal.svelte +91 -24
- package/src/lib/ContactForm.svelte +15 -6
- package/src/lib/EditBookingView.svelte +49 -4
- package/src/lib/PaymentPage.svelte +30 -25
- package/src/lib/TicketConfigurator.svelte +64 -27
- package/src/lib/api.ts +10 -2
- package/src/lib/cart-manager.ts +13 -0
- package/src/lib/config.ts +11 -8
- package/src/lib/elements/env.ts +0 -1
- package/src/lib/elements/register.ts +16 -3
- package/src/lib/index.ts +18 -7
- package/src/lib/peach-sdk.ts +40 -0
- package/src/lib/fake-api.ts +0 -282
- package/src/lib/mock-data.ts +0 -241
package/src/lib/mock-data.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CheckoutUnitDto,
|
|
3
|
-
CheckoutPickupLocationDto,
|
|
4
|
-
CheckoutOptionDto,
|
|
5
|
-
CheckoutProductDto,
|
|
6
|
-
CheckoutUnitPricingDto,
|
|
7
|
-
CheckoutAvailabilityCalendarDto,
|
|
8
|
-
CheckoutAvailabilityDto,
|
|
9
|
-
} from './client-types';
|
|
10
|
-
|
|
11
|
-
const adultUnit: CheckoutUnitDto = {
|
|
12
|
-
id: 'unit_adult',
|
|
13
|
-
type: 'ADULT',
|
|
14
|
-
title: 'Adult',
|
|
15
|
-
restrictions: { minAge: 12, maxAge: 100 },
|
|
16
|
-
pricing: [{ retail: 76500, currency: 'ZAR', currencyPrecision: 2 }],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const childUnit: CheckoutUnitDto = {
|
|
20
|
-
id: 'unit_child',
|
|
21
|
-
type: 'CHILD',
|
|
22
|
-
title: 'Junior',
|
|
23
|
-
restrictions: { minAge: 2, maxAge: 11 },
|
|
24
|
-
pricing: [{ retail: 49500, currency: 'ZAR', currencyPrecision: 2 }],
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const pickupLocations: CheckoutPickupLocationDto[] = [
|
|
28
|
-
{
|
|
29
|
-
id: 'pickup_long_street',
|
|
30
|
-
title: 'Long Street',
|
|
31
|
-
directions: 'Corner of Long and Kloof Street, outside the Engen garage',
|
|
32
|
-
address: '186 Long St, Cape Town City Centre, 8001',
|
|
33
|
-
latitude: -33.9249,
|
|
34
|
-
longitude: 18.4167,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: 'pickup_camps_bay',
|
|
38
|
-
title: 'Camps Bay',
|
|
39
|
-
directions: 'At the main bus stop on Victoria Road',
|
|
40
|
-
address: 'Victoria Rd, Camps Bay, Cape Town, 8005',
|
|
41
|
-
latitude: -33.9506,
|
|
42
|
-
longitude: 18.3782,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: 'pickup_sea_point_1',
|
|
46
|
-
title: 'Sea Point Stop 1',
|
|
47
|
-
directions: 'Outside Winchester Mansions, Beach Road',
|
|
48
|
-
address: '221 Beach Rd, Sea Point, Cape Town, 8005',
|
|
49
|
-
latitude: -33.9171,
|
|
50
|
-
longitude: 18.3889,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: 'pickup_va_waterfront',
|
|
54
|
-
title: 'V&A Waterfront',
|
|
55
|
-
directions: 'Two Oceans Aquarium bus bay, Dock Road',
|
|
56
|
-
address: 'Dock Rd, V&A Waterfront, Cape Town, 8001',
|
|
57
|
-
latitude: -33.908,
|
|
58
|
-
longitude: 18.4178,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
function makeOption(id: string, internalName: string, title: string, description: string): CheckoutOptionDto {
|
|
63
|
-
return {
|
|
64
|
-
id,
|
|
65
|
-
internalName,
|
|
66
|
-
title,
|
|
67
|
-
description,
|
|
68
|
-
units: [adultUnit, childUnit],
|
|
69
|
-
pickupAvailable: true,
|
|
70
|
-
pickupRequired: true,
|
|
71
|
-
pickupLocations,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const sampleProductData: CheckoutProductDto = {
|
|
76
|
-
id: '241c39c3-9c76-4a6f-bb38-3a4f18d08a61',
|
|
77
|
-
internalName: 'Franschhoek Wine Tram Xplorer Tour',
|
|
78
|
-
title: 'Franschhoek Wine Tram Xplorer Tour',
|
|
79
|
-
description: 'Explore the Franschhoek Wine Valley by heritage tram and open-top bus.',
|
|
80
|
-
options: [
|
|
81
|
-
makeOption(
|
|
82
|
-
'option_blue_tram',
|
|
83
|
-
'BLUE Line - Tram then Bus',
|
|
84
|
-
'BLUE Line - Tram then Bus',
|
|
85
|
-
'Start your journey on the heritage tram through the vineyards, then transfer to the bus.',
|
|
86
|
-
),
|
|
87
|
-
makeOption(
|
|
88
|
-
'option_blue_bus',
|
|
89
|
-
'BLUE Line - Bus then Tram',
|
|
90
|
-
'BLUE Line - Bus then Tram',
|
|
91
|
-
'Begin with the hop-on bus route, then switch to the heritage tram.',
|
|
92
|
-
),
|
|
93
|
-
makeOption(
|
|
94
|
-
'option_pink_tram',
|
|
95
|
-
'PINK Line - Tram then Bus',
|
|
96
|
-
'PINK Line - Tram then Bus',
|
|
97
|
-
'Explore the PINK route starting on the tram through the winelands.',
|
|
98
|
-
),
|
|
99
|
-
makeOption(
|
|
100
|
-
'option_pink_bus',
|
|
101
|
-
'PINK Line - Bus then Tram',
|
|
102
|
-
'PINK Line - Bus then Tram',
|
|
103
|
-
'Explore the PINK route starting on the bus before switching to the tram.',
|
|
104
|
-
),
|
|
105
|
-
makeOption(
|
|
106
|
-
'option_red_tram',
|
|
107
|
-
'RED Line - Tram then Bus',
|
|
108
|
-
'RED Line - Tram then Bus',
|
|
109
|
-
'Ride the RED route beginning with the scenic tram leg.',
|
|
110
|
-
),
|
|
111
|
-
makeOption(
|
|
112
|
-
'option_red_bus',
|
|
113
|
-
'RED Line - Bus then Tram',
|
|
114
|
-
'RED Line - Bus then Tram',
|
|
115
|
-
'Take the RED route starting on the bus, then enjoy the tram.',
|
|
116
|
-
),
|
|
117
|
-
makeOption(
|
|
118
|
-
'option_green_bus',
|
|
119
|
-
'GREEN Line - Bus then Tram',
|
|
120
|
-
'GREEN Line - Bus then Tram',
|
|
121
|
-
'The GREEN route begins with a comfortable bus ride before the tram.',
|
|
122
|
-
),
|
|
123
|
-
makeOption(
|
|
124
|
-
'option_green_tram',
|
|
125
|
-
'GREEN Line - Tram then Bus',
|
|
126
|
-
'GREEN Line - Tram then Bus',
|
|
127
|
-
'The GREEN route begins with the heritage tram through the valley.',
|
|
128
|
-
),
|
|
129
|
-
],
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
function formatDate(d: Date): string {
|
|
133
|
-
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function isWeekend(d: Date): boolean {
|
|
137
|
-
const day = d.getDay();
|
|
138
|
-
return day === 0 || day === 6;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function isHalloween(d: Date): boolean {
|
|
142
|
-
return d.getMonth() === 9 && d.getDate() === 31 && d.getFullYear() === 2026;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function makeUnitPricing(): CheckoutUnitPricingDto[] {
|
|
146
|
-
return [
|
|
147
|
-
{ unitId: 'unit_adult', original: 88500, retail: 76500, net: 65000, currency: 'ZAR', currencyPrecision: 2 },
|
|
148
|
-
{ unitId: 'unit_child', original: 49500, retail: 49500, net: 42000, currency: 'ZAR', currencyPrecision: 2 },
|
|
149
|
-
];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function generateSampleAvailability(): Record<string, CheckoutAvailabilityCalendarDto> {
|
|
153
|
-
const result: Record<string, CheckoutAvailabilityCalendarDto> = {};
|
|
154
|
-
const today = new Date();
|
|
155
|
-
today.setHours(0, 0, 0, 0);
|
|
156
|
-
|
|
157
|
-
let soldOutCounter = 0;
|
|
158
|
-
|
|
159
|
-
for (let i = 0; i < 90; i++) {
|
|
160
|
-
const d = new Date(today);
|
|
161
|
-
d.setDate(d.getDate() + i);
|
|
162
|
-
const key = formatDate(d);
|
|
163
|
-
|
|
164
|
-
if (isWeekend(d)) {
|
|
165
|
-
result[key] = { localDate: key, available: false, status: 'CLOSED', openingHours: null };
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
soldOutCounter++;
|
|
170
|
-
|
|
171
|
-
if (soldOutCounter % 5 === 0) {
|
|
172
|
-
result[key] = {
|
|
173
|
-
localDate: key,
|
|
174
|
-
available: false,
|
|
175
|
-
status: 'SOLD_OUT',
|
|
176
|
-
openingHours: [{ from: '08:45', to: '17:00' }],
|
|
177
|
-
unitPricing: makeUnitPricing(),
|
|
178
|
-
};
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (isHalloween(d)) {
|
|
183
|
-
result[key] = {
|
|
184
|
-
localDate: key,
|
|
185
|
-
available: true,
|
|
186
|
-
status: 'AVAILABLE',
|
|
187
|
-
openingHours: null,
|
|
188
|
-
unitPricing: makeUnitPricing(),
|
|
189
|
-
};
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
result[key] = {
|
|
194
|
-
localDate: key,
|
|
195
|
-
available: true,
|
|
196
|
-
status: 'AVAILABLE',
|
|
197
|
-
openingHours: [{ from: '08:45', to: '17:00' }],
|
|
198
|
-
unitPricing: makeUnitPricing(),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return result;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function generateSampleTimeSlots(date: Date): CheckoutAvailabilityDto[] {
|
|
206
|
-
const dateStr = formatDate(date);
|
|
207
|
-
|
|
208
|
-
if (isHalloween(date)) {
|
|
209
|
-
return [
|
|
210
|
-
{
|
|
211
|
-
id: `avail_${dateStr}_allday`,
|
|
212
|
-
localDateTimeStart: `${dateStr}T00:00:00`,
|
|
213
|
-
localDateTimeEnd: `${dateStr}T23:59:59`,
|
|
214
|
-
allDay: true,
|
|
215
|
-
available: true,
|
|
216
|
-
status: 'AVAILABLE',
|
|
217
|
-
vacancies: 50,
|
|
218
|
-
utcCutoffAt: `${dateStr}T22:00:00Z`,
|
|
219
|
-
openingHours: null,
|
|
220
|
-
unitPricing: makeUnitPricing(),
|
|
221
|
-
},
|
|
222
|
-
];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return [
|
|
226
|
-
{
|
|
227
|
-
id: `avail_${dateStr}_0845`,
|
|
228
|
-
localDateTimeStart: `${dateStr}T08:45:00`,
|
|
229
|
-
localDateTimeEnd: `${dateStr}T17:00:00`,
|
|
230
|
-
allDay: false,
|
|
231
|
-
available: true,
|
|
232
|
-
status: 'AVAILABLE',
|
|
233
|
-
vacancies: 24,
|
|
234
|
-
utcCutoffAt: `${dateStr}T06:45:00Z`,
|
|
235
|
-
openingHours: [{ from: '08:45', to: '17:00' }],
|
|
236
|
-
pickupAvailable: true,
|
|
237
|
-
pickupRequired: true,
|
|
238
|
-
unitPricing: makeUnitPricing(),
|
|
239
|
-
},
|
|
240
|
-
];
|
|
241
|
-
}
|