@bash-app/bash-common 29.28.2 → 29.29.0
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/package.json
CHANGED
package/prisma/schema.prisma
CHANGED
|
@@ -933,6 +933,13 @@ model AssociatedService {
|
|
|
933
933
|
@@unique([ownerEmail, serviceId])
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
+
enum ServiceCancelationPolicy {
|
|
937
|
+
VeryFlexible
|
|
938
|
+
Flexible
|
|
939
|
+
Standard90Day
|
|
940
|
+
Standard30Day
|
|
941
|
+
}
|
|
942
|
+
|
|
936
943
|
// Common data for all services; 1-1 relation between each individual service model such as Venue
|
|
937
944
|
model Service {
|
|
938
945
|
id String @id @default(cuid())
|
|
@@ -982,9 +989,9 @@ model Service {
|
|
|
982
989
|
emergencyContact String?
|
|
983
990
|
contactDetails String?
|
|
984
991
|
// rates Rate[] @relation("MultipleRates")
|
|
985
|
-
cancellationPolicy
|
|
986
|
-
refundPolicy String?
|
|
987
|
-
insurancePolicy String?
|
|
992
|
+
cancellationPolicy ServiceCancelationPolicy?
|
|
993
|
+
// refundPolicy String?
|
|
994
|
+
// insurancePolicy String?
|
|
988
995
|
// hoursOfOperation Json? @default("{}")
|
|
989
996
|
|
|
990
997
|
stripeAccountId String?
|
package/src/extendedSchemas.ts
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
ServiceAddon,
|
|
38
38
|
ServicePackage,
|
|
39
39
|
} from "@prisma/client";
|
|
40
|
-
import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray } from "./definitions";
|
|
40
|
+
import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray, VENUE_DATA_TO_INCLUDE } from "./definitions";
|
|
41
41
|
|
|
42
42
|
export const FRONT_END_USER_DATA_TO_SELECT = {
|
|
43
43
|
id: true,
|
|
@@ -108,6 +108,158 @@ export const BASH_EVENT_DATA_TO_REMOVE: RemoveCommonProperties<BashEvent, BashEv
|
|
|
108
108
|
'amountOfGuests',
|
|
109
109
|
];
|
|
110
110
|
|
|
111
|
+
//---------------Services------------------
|
|
112
|
+
export interface ServiceExt extends Service {
|
|
113
|
+
owner?: PublicUser | null;
|
|
114
|
+
creator?: PublicUser | null;
|
|
115
|
+
|
|
116
|
+
stripeAccount?: StripeAccount | null;
|
|
117
|
+
|
|
118
|
+
// availableDateTimes?: Availability[];
|
|
119
|
+
|
|
120
|
+
bookings?: Booking[];
|
|
121
|
+
// rates?: Rate[];
|
|
122
|
+
targetAudience?: TargetAudience | null;
|
|
123
|
+
media?: Media[];
|
|
124
|
+
serviceLinks?: ServiceLinkExt[];
|
|
125
|
+
|
|
126
|
+
eventService?: EventService;
|
|
127
|
+
entertainmentService?: EntertainmentService;
|
|
128
|
+
vendor?: Vendor;
|
|
129
|
+
exhibitor?: Exhibitor;
|
|
130
|
+
sponsor?: Sponsor;
|
|
131
|
+
venue?: Venue;
|
|
132
|
+
organization?: Organization;
|
|
133
|
+
volunteerService?: VolunteerService;
|
|
134
|
+
bashEvent: BashEvent[];
|
|
135
|
+
|
|
136
|
+
serviceRatesAssociation?: ServiceRatesAssociationExt | null;
|
|
137
|
+
associatedBashesReferencingMe?: AssociatedBash[];
|
|
138
|
+
associatedServicesReferencingMe?: AssociatedService[];
|
|
139
|
+
|
|
140
|
+
// googleReviews: GoogleReview[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ServiceRateExt extends ServiceRate {
|
|
144
|
+
serviceSpecialRates?: ServiceSpecialRates;
|
|
145
|
+
serviceDailyRates?: ServiceDailyRates;
|
|
146
|
+
serviceRatesAssociation?: ServiceRatesAssociation;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface ServicePackageExt extends ServicePackage {
|
|
150
|
+
serviceAddons: ServiceAddon[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface ServiceDailyRatesExt extends ServiceDailyRates {
|
|
154
|
+
serviceRate?: ServiceRate;
|
|
155
|
+
}
|
|
156
|
+
export interface ServiceSpecialRatesExt extends ServiceSpecialRates {
|
|
157
|
+
serviceRate?: ServiceRate;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ServiceRatesAssociationExt extends ServiceRatesAssociation {
|
|
161
|
+
serviceGeneralRates?: ServiceRate | null;
|
|
162
|
+
serviceDailyRates?: ServiceDailyRatesExt[];
|
|
163
|
+
serviceSpecialRates?: ServiceSpecialRatesExt[];
|
|
164
|
+
|
|
165
|
+
addons?: ServiceAddon[];
|
|
166
|
+
packages?: ServicePackageExt[];
|
|
167
|
+
media?: Media[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
export interface EventServiceExt extends EventService {
|
|
172
|
+
service: ServiceExt;
|
|
173
|
+
crowdSize?: AmountOfGuests;
|
|
174
|
+
serviceRange?: ServiceRange;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface EntertainmentServiceExt extends EntertainmentService {
|
|
178
|
+
service: ServiceExt;
|
|
179
|
+
crowdSize?: AmountOfGuests;
|
|
180
|
+
serviceRange?: ServiceRange;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface ExhibitorExt extends Exhibitor {
|
|
184
|
+
service: ServiceExt;
|
|
185
|
+
crowdSize?: AmountOfGuests;
|
|
186
|
+
serviceRange?: ServiceRange;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface SponsorExt extends Sponsor {
|
|
190
|
+
service: ServiceExt;
|
|
191
|
+
crowdSize?: AmountOfGuests;
|
|
192
|
+
serviceRange?: ServiceRange;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface VendorExt extends Vendor {
|
|
196
|
+
service: ServiceExt;
|
|
197
|
+
crowdSize?: AmountOfGuests;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface VenueExt extends Venue {
|
|
201
|
+
service: ServiceExt;
|
|
202
|
+
// crowdSize?: AmountOfGuests;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface OrganizationExt extends Organization {
|
|
206
|
+
service: ServiceExt;
|
|
207
|
+
amountOfGuests?: AmountOfGuests;
|
|
208
|
+
}
|
|
209
|
+
//-----------------------------------------
|
|
210
|
+
|
|
211
|
+
export interface VolunteerServiceExt extends VolunteerService {
|
|
212
|
+
service?: ServiceExt;
|
|
213
|
+
serviceRange?: ServiceRange | null;
|
|
214
|
+
media?: Media[];
|
|
215
|
+
links?: Link[];
|
|
216
|
+
// availableDateTimes?: Availability[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface ServiceLinkExt extends ServiceLink {
|
|
220
|
+
link: Link;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
// Create the final object dynamically
|
|
225
|
+
function createAllTrueObject<T extends string>(keys: T[]): Record<T, true> {
|
|
226
|
+
return keys.reduce((acc, key) => {
|
|
227
|
+
acc[key] = true;
|
|
228
|
+
return acc;
|
|
229
|
+
}, {} as Record<T, true>);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Define the keys and values in a single object
|
|
233
|
+
const serviceKeysObject = {
|
|
234
|
+
eventService: true,
|
|
235
|
+
entertainmentService: true,
|
|
236
|
+
vendor: true,
|
|
237
|
+
exhibitor: true,
|
|
238
|
+
sponsor: true,
|
|
239
|
+
venue: true,
|
|
240
|
+
organization: true,
|
|
241
|
+
} as const;
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
export type ServiceSpecificName = keyof typeof serviceKeysObject;
|
|
245
|
+
|
|
246
|
+
const serviceKeysArray = Object.keys(serviceKeysObject);
|
|
247
|
+
|
|
248
|
+
export type ServiceSpecificType = ServiceExt[ServiceSpecificName];
|
|
249
|
+
|
|
250
|
+
export const specificServiceMap : Record<ServiceTypes, ServiceSpecificName> = {
|
|
251
|
+
"EventServices": "eventService",
|
|
252
|
+
"EntertainmentServices": "entertainmentService",
|
|
253
|
+
"Vendors": "vendor",
|
|
254
|
+
"Exhibitors": "exhibitor",
|
|
255
|
+
"Sponsors": "sponsor",
|
|
256
|
+
"Venues": "venue",
|
|
257
|
+
"Organizations": "organization"
|
|
258
|
+
} as const;
|
|
259
|
+
|
|
260
|
+
export const serviceTypeToField = (serviceType : ServiceTypes) : ServiceSpecificName => {
|
|
261
|
+
return specificServiceMap[serviceType];
|
|
262
|
+
}
|
|
111
263
|
export const SERVICE_PACKAGE_DATA_TO_INCLUDE = {
|
|
112
264
|
serviceAddons: true
|
|
113
265
|
} satisfies Prisma.ServicePackageInclude;
|
|
@@ -160,52 +312,36 @@ export const SERVICE_DATA_TO_INCLUDE = {
|
|
|
160
312
|
}
|
|
161
313
|
} satisfies Prisma.ServiceInclude;
|
|
162
314
|
|
|
163
|
-
// Create the final object dynamically
|
|
164
|
-
function createAllTrueObject<T extends string>(keys: T[]): Record<T, true> {
|
|
165
|
-
return keys.reduce((acc, key) => {
|
|
166
|
-
acc[key] = true;
|
|
167
|
-
return acc;
|
|
168
|
-
}, {} as Record<T, true>);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Define the keys and values in a single object
|
|
172
|
-
const serviceKeysObject = {
|
|
173
|
-
eventService: true,
|
|
174
|
-
entertainmentService: true,
|
|
175
|
-
vendor: true,
|
|
176
|
-
exhibitor: true,
|
|
177
|
-
sponsor: true,
|
|
178
|
-
venue: true,
|
|
179
|
-
organization: true,
|
|
180
|
-
} as const;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
export type ServiceSpecificName = keyof typeof serviceKeysObject;
|
|
184
|
-
|
|
185
|
-
const serviceKeysArray = Object.keys(serviceKeysObject);
|
|
186
|
-
|
|
187
|
-
export type ServiceSpecificType = ServiceExt[ServiceSpecificName];
|
|
188
|
-
|
|
189
|
-
export const serviceTypeToField = (serviceType : ServiceTypes) : ServiceSpecificName => {
|
|
190
|
-
const specificServiceMap : Record<ServiceTypes, ServiceSpecificName> = {
|
|
191
|
-
"EventServices": "eventService",
|
|
192
|
-
"EntertainmentServices": "entertainmentService",
|
|
193
|
-
"Vendors": "vendor",
|
|
194
|
-
"Exhibitors": "exhibitor",
|
|
195
|
-
"Sponsors": "sponsor",
|
|
196
|
-
"Venues": "venue",
|
|
197
|
-
"Organizations": "organization"
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
return specificServiceMap[serviceType];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
315
|
//full service data to include, includes specific service data
|
|
204
316
|
export const SERVICE_FULL_DATA_TO_INCLUDE = {
|
|
205
317
|
...SERVICE_DATA_TO_INCLUDE,
|
|
206
318
|
...createAllTrueObject(serviceKeysArray)
|
|
207
319
|
} satisfies Prisma.ServiceInclude;
|
|
208
320
|
|
|
321
|
+
export const SERVICE_FULL_DATA_TO_CLONE = [
|
|
322
|
+
'media',
|
|
323
|
+
'targetAudience',
|
|
324
|
+
'serviceLinks',
|
|
325
|
+
// ...Object.values(specificServiceMap)
|
|
326
|
+
] as const;
|
|
327
|
+
|
|
328
|
+
type ServiceExtMinusDataToCloneType = Omit<ServiceExt, UnionFromArray<typeof SERVICE_FULL_DATA_TO_CLONE>>;
|
|
329
|
+
export const SERVICE_FULL_DATA_TO_REMOVE: RemoveCommonProperties<Service, ServiceExtMinusDataToCloneType>[] = [
|
|
330
|
+
'creator',
|
|
331
|
+
'owner',
|
|
332
|
+
'bookings',
|
|
333
|
+
] as const;
|
|
334
|
+
|
|
335
|
+
export const VENUE_DATA_TO_CLONE = [
|
|
336
|
+
|
|
337
|
+
] as const;
|
|
338
|
+
|
|
339
|
+
type VenueExtMinusDataToCloneType = Omit<Venue, UnionFromArray<typeof VENUE_DATA_TO_CLONE>>;
|
|
340
|
+
export const VENUE_DATA_TO_REMOVE: RemoveCommonProperties<Venue, VenueExtMinusDataToCloneType>[] = [
|
|
341
|
+
// 'bashEvents',
|
|
342
|
+
] as const;
|
|
343
|
+
//-----------------------------------------
|
|
344
|
+
|
|
209
345
|
export interface BashNotificationExt extends BashNotification {
|
|
210
346
|
creator?: PublicUser;
|
|
211
347
|
bashEvent?: BashEvent;
|
|
@@ -269,119 +405,6 @@ export const STRIPE_ACCOUNT_DATA_TO_INCLUDE = {
|
|
|
269
405
|
export interface StripeAccountExt extends StripeAccount {
|
|
270
406
|
logo?: Media | null;
|
|
271
407
|
}
|
|
272
|
-
|
|
273
|
-
//---------------Services------------------
|
|
274
|
-
export interface ServiceExt extends Service {
|
|
275
|
-
owner?: PublicUser | null;
|
|
276
|
-
creator?: PublicUser | null;
|
|
277
|
-
|
|
278
|
-
stripeAccount?: StripeAccount | null;
|
|
279
|
-
|
|
280
|
-
// availableDateTimes?: Availability[];
|
|
281
|
-
|
|
282
|
-
bookings?: Booking[];
|
|
283
|
-
// rates?: Rate[];
|
|
284
|
-
targetAudience?: TargetAudience | null;
|
|
285
|
-
media?: Media[];
|
|
286
|
-
serviceLinks?: ServiceLinkExt[];
|
|
287
|
-
|
|
288
|
-
eventService?: EventService;
|
|
289
|
-
entertainmentService?: EntertainmentService;
|
|
290
|
-
vendor?: Vendor;
|
|
291
|
-
exhibitor?: Exhibitor;
|
|
292
|
-
sponsor?: Sponsor;
|
|
293
|
-
venue?: Venue;
|
|
294
|
-
organization?: Organization;
|
|
295
|
-
volunteerService?: VolunteerService;
|
|
296
|
-
bashEvent: BashEvent[];
|
|
297
|
-
|
|
298
|
-
serviceRatesAssociation?: ServiceRatesAssociationExt | null;
|
|
299
|
-
associatedBashesReferencingMe?: AssociatedBash[];
|
|
300
|
-
associatedServicesReferencingMe?: AssociatedService[];
|
|
301
|
-
|
|
302
|
-
// googleReviews: GoogleReview[];
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export interface ServiceRateExt extends ServiceRate {
|
|
306
|
-
serviceSpecialRates?: ServiceSpecialRates;
|
|
307
|
-
serviceDailyRates?: ServiceDailyRates;
|
|
308
|
-
serviceRatesAssociation?: ServiceRatesAssociation;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
export interface ServicePackageExt extends ServicePackage {
|
|
312
|
-
serviceAddons: ServiceAddon[];
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export interface ServiceDailyRatesExt extends ServiceDailyRates {
|
|
316
|
-
serviceRate?: ServiceRate;
|
|
317
|
-
}
|
|
318
|
-
export interface ServiceSpecialRatesExt extends ServiceSpecialRates {
|
|
319
|
-
serviceRate?: ServiceRate;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export interface ServiceRatesAssociationExt extends ServiceRatesAssociation {
|
|
323
|
-
serviceGeneralRates?: ServiceRate | null;
|
|
324
|
-
serviceDailyRates?: ServiceDailyRatesExt[];
|
|
325
|
-
serviceSpecialRates?: ServiceSpecialRatesExt[];
|
|
326
|
-
|
|
327
|
-
addons?: ServiceAddon[];
|
|
328
|
-
packages?: ServicePackageExt[];
|
|
329
|
-
media?: Media[];
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
export interface EventServiceExt extends EventService {
|
|
334
|
-
service: ServiceExt;
|
|
335
|
-
crowdSize?: AmountOfGuests;
|
|
336
|
-
serviceRange?: ServiceRange;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export interface EntertainmentServiceExt extends EntertainmentService {
|
|
340
|
-
service: ServiceExt;
|
|
341
|
-
crowdSize?: AmountOfGuests;
|
|
342
|
-
serviceRange?: ServiceRange;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export interface ExhibitorExt extends Exhibitor {
|
|
346
|
-
service: ServiceExt;
|
|
347
|
-
crowdSize?: AmountOfGuests;
|
|
348
|
-
serviceRange?: ServiceRange;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
export interface SponsorExt extends Sponsor {
|
|
352
|
-
service: ServiceExt;
|
|
353
|
-
crowdSize?: AmountOfGuests;
|
|
354
|
-
serviceRange?: ServiceRange;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
export interface VendorExt extends Vendor {
|
|
358
|
-
service: ServiceExt;
|
|
359
|
-
crowdSize?: AmountOfGuests;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export interface VenueExt extends Venue {
|
|
363
|
-
service: ServiceExt;
|
|
364
|
-
// crowdSize?: AmountOfGuests;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
export interface OrganizationExt extends Organization {
|
|
368
|
-
service: ServiceExt;
|
|
369
|
-
amountOfGuests?: AmountOfGuests;
|
|
370
|
-
}
|
|
371
|
-
//-----------------------------------------
|
|
372
|
-
|
|
373
|
-
export interface VolunteerServiceExt extends VolunteerService {
|
|
374
|
-
service?: ServiceExt;
|
|
375
|
-
serviceRange?: ServiceRange | null;
|
|
376
|
-
media?: Media[];
|
|
377
|
-
links?: Link[];
|
|
378
|
-
// availableDateTimes?: Availability[];
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export interface ServiceLinkExt extends ServiceLink {
|
|
382
|
-
link: Link;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
408
|
export interface InvitationExt extends Invitation {
|
|
386
409
|
creator: PublicUser;
|
|
387
410
|
sentTo: PublicUser;
|
package/src/index.ts
CHANGED
|
@@ -11,5 +11,6 @@ export * from "./utils/sortUtils";
|
|
|
11
11
|
export * from "./utils/apiUtils";
|
|
12
12
|
export * from "./utils/urlUtils";
|
|
13
13
|
export * from "./utils/promoCodesUtils";
|
|
14
|
-
export * from "./utils/
|
|
14
|
+
export * from "./utils/service/serviceUtils";
|
|
15
|
+
export * from "./utils/service/venueUtils";
|
|
15
16
|
export * from "./utils/stripeAccountUtils";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ServiceCancelationPolicy as ServiceCancelationPolicyOption } from "@prisma/client";
|
|
2
|
+
|
|
3
|
+
export type ServiceCancelationRefundPolicy = {
|
|
4
|
+
days?: number;
|
|
5
|
+
hours?: number;
|
|
6
|
+
refundPercentage: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ServiceCancelationPolicyData = {
|
|
10
|
+
name: string,
|
|
11
|
+
description?: string,
|
|
12
|
+
refundPolicy: ServiceCancelationRefundPolicy[],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ServiceCancelationPolicyMap = {
|
|
16
|
+
[key in ServiceCancelationPolicyOption]: ServiceCancelationPolicyData;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ServiceCancelationPolicyData: ServiceCancelationPolicyMap = {
|
|
20
|
+
[ServiceCancelationPolicyOption.VeryFlexible]: {
|
|
21
|
+
name: "Very Flexible",
|
|
22
|
+
refundPolicy: [
|
|
23
|
+
{
|
|
24
|
+
hours: 24,
|
|
25
|
+
refundPercentage: 100
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
[ServiceCancelationPolicyOption.Flexible]: {
|
|
30
|
+
name: "Flexible",
|
|
31
|
+
refundPolicy: [
|
|
32
|
+
{
|
|
33
|
+
days: 7,
|
|
34
|
+
refundPercentage: 100
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
hours: 24,
|
|
38
|
+
refundPercentage: 50
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
[ServiceCancelationPolicyOption.Standard30Day]: {
|
|
43
|
+
name: "Standard 30 Day",
|
|
44
|
+
refundPolicy: [
|
|
45
|
+
{
|
|
46
|
+
days: 30,
|
|
47
|
+
refundPercentage: 100
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
days: 7,
|
|
51
|
+
refundPercentage: 50
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
[ServiceCancelationPolicyOption.Standard90Day]: {
|
|
56
|
+
name: "Very Flexible",
|
|
57
|
+
refundPolicy: [
|
|
58
|
+
{
|
|
59
|
+
days: 90,
|
|
60
|
+
refundPercentage: 100
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
days: 14,
|
|
64
|
+
refundPercentage: 50
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
} as const;
|
|
69
|
+
|
|
70
|
+
function generateDescription(refundPolicy: ServiceCancelationRefundPolicy[]): string {
|
|
71
|
+
const descriptions = refundPolicy.map((policy, index) => {
|
|
72
|
+
const unit = policy.days ? 'days' : 'hours';
|
|
73
|
+
const timeValue = policy.days ?? policy.hours;
|
|
74
|
+
|
|
75
|
+
const refundText = policy.refundPercentage === 100
|
|
76
|
+
? "a full refund (including all Fees)"
|
|
77
|
+
: `${policy.refundPercentage}% refund (excluding Fees)`;
|
|
78
|
+
|
|
79
|
+
if (index === 0) {
|
|
80
|
+
return `Guests may cancel their Booking until ${timeValue} ${unit} before the event start time and will receive ${refundText} of their Booking Price.`;
|
|
81
|
+
} else {
|
|
82
|
+
const previousTime = refundPolicy[index - 1].days ?? refundPolicy[index - 1].hours;
|
|
83
|
+
return `Guests may cancel their Booking between ${timeValue} ${unit} and ${previousTime} ${unit} before the event start time and receive ${refundText} of their Booking Price.`;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const lastTime = refundPolicy[refundPolicy.length - 1].days ?? refundPolicy[refundPolicy.length - 1].hours;
|
|
88
|
+
descriptions.push(`Cancellations submitted less than ${lastTime} ${refundPolicy[refundPolicy.length - 1].days ? 'days' : 'hours'} before the Event start time are not refundable.`);
|
|
89
|
+
|
|
90
|
+
return descriptions.join(" ");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Object.keys(ServiceCancelationPolicyData).forEach((policyKey) => {
|
|
94
|
+
const policy = ServiceCancelationPolicyData[policyKey as ServiceCancelationPolicyOption];
|
|
95
|
+
policy.description = generateDescription(policy.refundPolicy);
|
|
96
|
+
});
|