@bash-app/bash-common 29.23.0 → 29.23.1

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.
@@ -1,78 +1,78 @@
1
- import dayjs from "dayjs";
2
- import {
3
- NumberOfTicketsForDate,
4
- URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM,
5
- URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM,
6
- URL_PARAMS_TICKET_LIST_DELIM,
7
- URL_PARAMS_TICKETS_DATE_DELIM
8
- } from "../definitions";
9
- import { DATETIME_FORMAT_ISO_LIKE } from "./dateTimeUtils";
10
-
11
-
12
- /**
13
- * Returns A string structured like: [ticketTierId]__[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~,...
14
- * @param ticketList A map where the key is the ticketTierId
15
- */
16
- export function ticketListToString(ticketList: Map<string, NumberOfTicketsForDate[]>): string {
17
- const ticketListArr: string[] = [];
18
-
19
- for (const [ticketTierId, ticketListArgs] of ticketList.entries()) {
20
- let ticketsExist = true;
21
- const ticketArgs: string[] = [`${ticketTierId}${URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM}`];
22
- for (const ticketNumAndDates of ticketListArgs) {
23
- if (ticketNumAndDates.numberOfTickets > 0) {
24
- ticketsExist = true;
25
- ticketArgs.push(
26
- `${ticketNumAndDates.numberOfTickets}${URL_PARAMS_TICKETS_DATE_DELIM}${ticketNumAndDates.ticketDateTime}`);
27
- }
28
- else {
29
- ticketsExist = false;
30
- }
31
- }
32
- if (ticketsExist) {
33
- ticketListArr.push(ticketArgs.join(URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM));
34
- }
35
- }
36
- return ticketListArr.join(URL_PARAMS_TICKET_LIST_DELIM);
37
- }
38
-
39
- /**
40
- * Returns map where the key is the ticketTierId
41
- * @param ticketListStr A string structured like: [ticketTierId]__[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...,...
42
- */
43
- export function ticketListStrToTicketList(ticketListStr: string): Map<string, NumberOfTicketsForDate[]> {
44
- const ticketList: Map<string, NumberOfTicketsForDate[]> = new Map();
45
-
46
- // [ticketTierId]__~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...,...
47
- const ticketListArgs = ticketListStr.split(URL_PARAMS_TICKET_LIST_DELIM);
48
-
49
- ticketListArgs.forEach((tierIdAndTicketNumbersAndDates: string): void => {
50
- const ticketNumAndDatesArr: NumberOfTicketsForDate[] = [];
51
- // [ticketTierId]__~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...
52
- const [ticketTierId, ticketNumAndDatesStr] = tierIdAndTicketNumbersAndDates.split(URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM);
53
- if (!ticketNumAndDatesArr) {
54
- throw new Error(`Could not parse ticketListStr. Maybe it is just an amount?`);
55
- }
56
- // ~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...
57
- const ticketNumAndDates = ticketNumAndDatesStr.split(URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM)
58
- .filter((ticketNumAndDateStr): boolean => !!ticketNumAndDateStr);
59
-
60
- for (const ticketNumAndDateStr of ticketNumAndDates) {
61
- // [numberOfTickets];;[date]
62
- const [numberOfTickets, ticketDateTimeStr] = ticketNumAndDateStr.split(URL_PARAMS_TICKETS_DATE_DELIM);
63
- const ticketDateTime = dayjs(ticketDateTimeStr);
64
- let ticketDateTimeFormattedStr: string | undefined = undefined;
65
-
66
- if (ticketDateTime.isValid()) {
67
- ticketDateTimeFormattedStr = ticketDateTime.format(DATETIME_FORMAT_ISO_LIKE);
68
- }
69
-
70
- ticketNumAndDatesArr.push({
71
- numberOfTickets: parseInt(numberOfTickets),
72
- ticketDateTime: ticketDateTimeFormattedStr,
73
- });
74
- }
75
- ticketList.set(ticketTierId, ticketNumAndDatesArr);
76
- });
77
- return ticketList;
78
- }
1
+ import dayjs from "dayjs";
2
+ import {
3
+ NumberOfTicketsForDate,
4
+ URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM,
5
+ URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM,
6
+ URL_PARAMS_TICKET_LIST_DELIM,
7
+ URL_PARAMS_TICKETS_DATE_DELIM
8
+ } from "../definitions";
9
+ import { DATETIME_FORMAT_ISO_LIKE } from "./dateTimeUtils";
10
+
11
+
12
+ /**
13
+ * Returns A string structured like: [ticketTierId]__[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~,...
14
+ * @param ticketList A map where the key is the ticketTierId
15
+ */
16
+ export function ticketListToString(ticketList: Map<string, NumberOfTicketsForDate[]>): string {
17
+ const ticketListArr: string[] = [];
18
+
19
+ for (const [ticketTierId, ticketListArgs] of ticketList.entries()) {
20
+ let ticketsExist = true;
21
+ const ticketArgs: string[] = [`${ticketTierId}${URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM}`];
22
+ for (const ticketNumAndDates of ticketListArgs) {
23
+ if (ticketNumAndDates.numberOfTickets > 0) {
24
+ ticketsExist = true;
25
+ ticketArgs.push(
26
+ `${ticketNumAndDates.numberOfTickets}${URL_PARAMS_TICKETS_DATE_DELIM}${ticketNumAndDates.ticketDateTime}`);
27
+ }
28
+ else {
29
+ ticketsExist = false;
30
+ }
31
+ }
32
+ if (ticketsExist) {
33
+ ticketListArr.push(ticketArgs.join(URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM));
34
+ }
35
+ }
36
+ return ticketListArr.join(URL_PARAMS_TICKET_LIST_DELIM);
37
+ }
38
+
39
+ /**
40
+ * Returns map where the key is the ticketTierId
41
+ * @param ticketListStr A string structured like: [ticketTierId]__[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...,...
42
+ */
43
+ export function ticketListStrToTicketList(ticketListStr: string): Map<string, NumberOfTicketsForDate[]> {
44
+ const ticketList: Map<string, NumberOfTicketsForDate[]> = new Map();
45
+
46
+ // [ticketTierId]__~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...,...
47
+ const ticketListArgs = ticketListStr.split(URL_PARAMS_TICKET_LIST_DELIM);
48
+
49
+ ticketListArgs.forEach((tierIdAndTicketNumbersAndDates: string): void => {
50
+ const ticketNumAndDatesArr: NumberOfTicketsForDate[] = [];
51
+ // [ticketTierId]__~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...
52
+ const [ticketTierId, ticketNumAndDatesStr] = tierIdAndTicketNumbersAndDates.split(URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM);
53
+ if (!ticketNumAndDatesArr) {
54
+ throw new Error(`Could not parse ticketListStr. Maybe it is just an amount?`);
55
+ }
56
+ // ~~[numberOfTickets];;[date]~~[numberOfTickets];;[date]~~...
57
+ const ticketNumAndDates = ticketNumAndDatesStr.split(URL_PARAMS_NUMBER_OF_TICKETS_TICKETS_DATE_DELIM)
58
+ .filter((ticketNumAndDateStr): boolean => !!ticketNumAndDateStr);
59
+
60
+ for (const ticketNumAndDateStr of ticketNumAndDates) {
61
+ // [numberOfTickets];;[date]
62
+ const [numberOfTickets, ticketDateTimeStr] = ticketNumAndDateStr.split(URL_PARAMS_TICKETS_DATE_DELIM);
63
+ const ticketDateTime = dayjs(ticketDateTimeStr);
64
+ let ticketDateTimeFormattedStr: string | undefined = undefined;
65
+
66
+ if (ticketDateTime.isValid()) {
67
+ ticketDateTimeFormattedStr = ticketDateTime.format(DATETIME_FORMAT_ISO_LIKE);
68
+ }
69
+
70
+ ticketNumAndDatesArr.push({
71
+ numberOfTickets: parseInt(numberOfTickets),
72
+ ticketDateTime: ticketDateTimeFormattedStr,
73
+ });
74
+ }
75
+ ticketList.set(ticketTierId, ticketNumAndDatesArr);
76
+ });
77
+ return ticketList;
78
+ }
@@ -1,29 +1,29 @@
1
- import {isProduction} from "./apiUtils";
2
- import {BASH_DETAIL_URL} from "../definitions";
3
-
4
-
5
- const API_HOST = process.env.REACT_APP_API ?? "http://localhost:3500";
6
-
7
-
8
- export function getFrontendHost(): string {
9
- const host = isProduction()
10
- ? `${window.location.protocol}//${window.location.host}`
11
- : `${window.location.protocol}//${window.location.hostname}:3000`;
12
- return host;
13
- }
14
-
15
- export function getBackendHost(): string {
16
- const host = isProduction()
17
- ? API_HOST
18
- : `${window.location.protocol}//${window.location.hostname}:3500`;
19
- return host;
20
- }
21
-
22
- export function getSsrBashDetailUrl(bashEventId: string | undefined): string {
23
- if (bashEventId) {
24
- const url = `/api/ssr${BASH_DETAIL_URL}/${bashEventId}`;
25
- return url;
26
- }
27
- console.error(`BashEventId was not specified for the ssr bash detail url`);
28
- return '';
29
- }
1
+ import {isProduction} from "./apiUtils";
2
+ import {BASH_DETAIL_URL} from "../definitions";
3
+
4
+
5
+ const API_HOST = process.env.REACT_APP_API ?? "http://localhost:3500";
6
+
7
+
8
+ export function getFrontendHost(): string {
9
+ const host = isProduction()
10
+ ? `${window.location.protocol}//${window.location.host}`
11
+ : `${window.location.protocol}//${window.location.hostname}:3000`;
12
+ return host;
13
+ }
14
+
15
+ export function getBackendHost(): string {
16
+ const host = isProduction()
17
+ ? API_HOST
18
+ : `${window.location.protocol}//${window.location.hostname}:3500`;
19
+ return host;
20
+ }
21
+
22
+ export function getSsrBashDetailUrl(bashEventId: string | undefined): string {
23
+ if (bashEventId) {
24
+ const url = `/api/ssr${BASH_DETAIL_URL}/${bashEventId}`;
25
+ return url;
26
+ }
27
+ console.error(`BashEventId was not specified for the ssr bash detail url`);
28
+ return '';
29
+ }
@@ -1,30 +1,30 @@
1
- import { VenuePricingPlan as VenuePricingPlanOption } from "@prisma/client";
2
-
3
- export type VenuePricingPlanData = {
4
- name: string,
5
- description: string,
6
- percentageFee: number;
7
- monthlyFee: number;
8
- flatFee: number;
9
- };
10
-
11
- export type VenuePricingPlanMap = {
12
- [key in VenuePricingPlanOption]: VenuePricingPlanData;
13
- };
14
-
15
- export const VenuePricingPlanData: VenuePricingPlanMap = {
16
- [VenuePricingPlanOption.Percentage]: {
17
- name: "Pay per booking,",
18
- description: "15% of each booking goes to Bash.",
19
- percentageFee: 0.15,
20
- monthlyFee: 0.0,
21
- flatFee: 0.0
22
- },
23
- [VenuePricingPlanOption.Subscription]: {
24
- name: "Monthly subscription",
25
- description: "Pay $100/month and keep 100% of each booking.",
26
- percentageFee: 0.0,
27
- monthlyFee: 100.0,
28
- flatFee: 0.0
29
- }
1
+ import { VenuePricingPlan as VenuePricingPlanOption } from "@prisma/client";
2
+
3
+ export type VenuePricingPlanData = {
4
+ name: string,
5
+ description: string,
6
+ percentageFee: number;
7
+ monthlyFee: number;
8
+ flatFee: number;
9
+ };
10
+
11
+ export type VenuePricingPlanMap = {
12
+ [key in VenuePricingPlanOption]: VenuePricingPlanData;
13
+ };
14
+
15
+ export const VenuePricingPlanData: VenuePricingPlanMap = {
16
+ [VenuePricingPlanOption.Percentage]: {
17
+ name: "Pay per booking,",
18
+ description: "15% of each booking goes to Bash.",
19
+ percentageFee: 0.15,
20
+ monthlyFee: 0.0,
21
+ flatFee: 0.0
22
+ },
23
+ [VenuePricingPlanOption.Subscription]: {
24
+ name: "Monthly subscription",
25
+ description: "Pay $100/month and keep 100% of each booking.",
26
+ percentageFee: 0.0,
27
+ monthlyFee: 100.0,
28
+ flatFee: 0.0
29
+ }
30
30
  };
package/tsconfig.json CHANGED
@@ -1,19 +1,19 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "esModuleInterop": true,
7
- "noEmit": true,
8
- "outDir": "./dist",
9
- "rootDir": "./src",
10
- "strict": true,
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "jsx": "react-jsx",
14
- "noImplicitAny": true,
15
- "sourceMap": true,
16
- },
17
- "include": ["src/**/*.ts", "src/**/*.tsx"],
18
- "exclude": ["node_modules"]
19
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "esModuleInterop": true,
7
+ "noEmit": true,
8
+ "outDir": "./dist",
9
+ "rootDir": "./src",
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "jsx": "react-jsx",
14
+ "noImplicitAny": true,
15
+ "sourceMap": true,
16
+ },
17
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
18
+ "exclude": ["node_modules"]
19
+ }