@bash-app/bash-common 29.28.3 → 29.30.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "29.28.3",
3
+ "version": "29.30.0",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -21,6 +21,7 @@
21
21
  "@aws-sdk/client-s3": "^3.529.0",
22
22
  "@aws-sdk/client-textract": "^3.529.0",
23
23
  "@aws-sdk/s3-request-presigner": "^3.529.0",
24
+ "@testing-library/jest-dom": "^6.6.3",
24
25
  "@types/qrcode": "^1.5.5",
25
26
  "qrcode": "^1.5.3"
26
27
  },
@@ -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,11 +989,14 @@ model Service {
982
989
  emergencyContact String?
983
990
  contactDetails String?
984
991
  // rates Rate[] @relation("MultipleRates")
985
- cancellationPolicy String?
986
- refundPolicy String?
987
- insurancePolicy String?
992
+ cancellationPolicy ServiceCancelationPolicy?
993
+ // refundPolicy String?
994
+ // insurancePolicy String?
988
995
  // hoursOfOperation Json? @default("{}")
989
996
 
997
+ displayGoogleReviewsOnDetailPage Boolean?
998
+ displayBashReviewsOnDetailPage Boolean?
999
+
990
1000
  stripeAccountId String?
991
1001
  stripeAccount StripeAccount? @relation(fields: [stripeAccountId], references: [id], onDelete: Restrict)
992
1002
 
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/venueUtils";
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
+ });
File without changes
@@ -1 +0,0 @@
1
- export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;