@bash-app/bash-common 30.18.0 → 30.20.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": "30.18.0",
3
+ "version": "30.20.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",
@@ -313,7 +313,7 @@ model BashEvent {
313
313
  venue Venue? @relation(fields: [venueId], references: [id])
314
314
  userPromoCodeRedemption UserPromoCodeRedemption[]
315
315
  averageRating Float? @default(0)
316
- serviceBookings ServiceBooking[] // Add this field to create the reverse relation
316
+ serviceBookings ServiceBooking[] // Add this field to create the reverse relation
317
317
  }
318
318
 
319
319
  model Coordinates {
@@ -689,6 +689,7 @@ enum UserIntent {
689
689
  EventSeeker
690
690
  EventOrganizer
691
691
  VenueOwner
692
+ Lonely
692
693
  }
693
694
 
694
695
  enum BashStatus {
@@ -1245,7 +1246,9 @@ model Service {
1245
1246
  cancellationPolicy ServiceCancellationPolicy? @default(None)
1246
1247
  // refundPolicy String?
1247
1248
  // insurancePolicy String?
1248
- // hoursOfOperation Json? @default("{}")
1249
+ availableHours String?
1250
+ allowsInstantBooking Boolean @default(false)
1251
+ instantBookingLeadTimeHours Int @default(0)
1249
1252
 
1250
1253
  displayGoogleReviewsOnDetailPage Boolean @default(true)
1251
1254
  displayBashReviewsOnDetailPage Boolean @default(true)
@@ -1928,7 +1931,7 @@ model ServiceBooking {
1928
1931
  daysTotalATBCents Int //ATB=At Time of Booking
1929
1932
  totalATBCents Int
1930
1933
 
1931
- bashEventId String?
1934
+ bashEventId String?
1932
1935
  bashEvent BashEvent? @relation(fields: [bashEventId], references: [id])
1933
1936
 
1934
1937
  @@index([status])
@@ -12,9 +12,10 @@ const PARSE_TIME_REG = /^(\d{1,2}):(\d{2}) ?([APM]{0,2})$/i;
12
12
 
13
13
  // export const LUXON_DATETIME_FORMAT_STANDARD = "MM/dd/yyyy - hh:mm a";
14
14
  export const LUXON_DATETIME_FORMAT_STANDARD = "D t";
15
- export const LUXON_DATETIME_FORMAT_ISO_LIKE = "yyyy-MM-dd hh:mm"; //"D t";
15
+ export const LUXON_DATETIME_FORMAT_ISO_LIKE = "D t"; //"D t";
16
16
  // export const LUXON_DATE_FORMAT_STANDARD = "yyyy/MM/dd";
17
17
  // export const LUXON_DATE_FORMAT_ISO = "yyyy/MM/dd";
18
+ export const LUXON_DATETIME_FORMAT_DATE = "D"; //"D t";
18
19
  export const LUXON_TIME_FORMAT_AM_PM = "h:mm a";
19
20
 
20
21
  export const MINUTES_PER_DAY = 1440;
@@ -199,6 +200,10 @@ export function dateTimeFormatTime(dateTime?: DateTime | null) {
199
200
  return dateTime?.toFormat(LUXON_TIME_FORMAT_AM_PM) ?? "";
200
201
  }
201
202
 
203
+ export function dateTimeFormatDate(dateTime?: DateTime | null) {
204
+ return dateTime?.toFormat(LUXON_DATETIME_FORMAT_DATE) ?? "";
205
+ }
206
+
202
207
  export function dateTimeWithinRange(
203
208
  dateTime: DateTime,
204
209
  dateRange: LuxonDateRange
@@ -278,6 +283,21 @@ export function dateTimeFormatDateRange(
278
283
  )}`;
279
284
  }
280
285
 
286
+ export function dateTimeFormatDateRangeDate(
287
+ startDateTimeArg: DateTime | null,
288
+ endDateTimeArg: DateTime | null
289
+ ): string {
290
+ if (startDateTimeArg?.day === endDateTimeArg?.day) {
291
+ return `${dateTimeFormatDate(startDateTimeArg)} to ${dateTimeFormatDate(
292
+ endDateTimeArg
293
+ )}`;
294
+ }
295
+
296
+ return `${dateTimeFormatDate(startDateTimeArg)} to ${dateTimeFormatDate(
297
+ endDateTimeArg
298
+ )}`;
299
+ }
300
+
281
301
  export interface DateTimeFormatDateRangeListResult {
282
302
  start: string;
283
303
  end: string;
@@ -9,3 +9,13 @@ export function isPositiveFloat(str: string): boolean {
9
9
  export function isPrice(str: string): boolean {
10
10
  return /^\d*\.?\d{0,2}$/.test(str);
11
11
  }
12
+
13
+ export function isUrlInputtingProtocol(str: string): boolean {
14
+ return /^(?:(?:|h|ht|htt|http|https)|(?:http|https):(?:\/{0,2})?)$/.test(str);
15
+ }
16
+
17
+ export function isUrl(str: string): boolean {
18
+ return /(?:^https?:\/\/[^\s\/$?#;&=@:]*$)|(?:^https?:\/{0,2}$)|(?:^[^\s\/$?#;&=@:]*$)/.test(
19
+ str
20
+ );
21
+ }
@@ -1,31 +1,25 @@
1
1
  import {
2
- Service,
3
2
  ServiceRate,
4
3
  ServiceRatePricingType,
5
4
  ServiceRateType,
6
5
  } from "@prisma/client";
6
+ import { DateTime } from "luxon";
7
7
  import {
8
8
  ServiceDailyRatesExt,
9
- ServiceRateExt,
10
9
  ServiceRatesAssociationExt,
11
10
  ServiceSpecialRatesExt,
12
11
  } from "../../extendedSchemas";
13
12
  import {
14
13
  LuxonDateRange,
15
- dateTimeFromDate,
16
- dateRangeWithinDateRange,
17
- dateRangeDurationMatch,
18
- dateTimeRangeToInterval,
19
14
  dateRangeNormalizeToMWY,
15
+ dateTimeFromDate,
20
16
  dateTimeRangeIntersection,
21
- dateTimeRangeHours,
22
17
  } from "../luxonUtils";
23
- import { DateTime } from "luxon";
18
+ import { ServiceBookingPriceBreakdownBaseT } from "./serviceBookingTypes";
24
19
  import {
25
20
  ServiceDailyRatesExtT,
26
21
  ServiceSpecialRatesExtT,
27
22
  } from "./serviceRateTypes";
28
- import { ServiceBookingPriceBreakdownBaseT } from "./serviceBookingTypes";
29
23
 
30
24
  export const SERVICE_DAILY_RATE_HOURS_MIN = 8;
31
25
 
@@ -302,23 +296,23 @@ export function serviceRatesAssociationGetBlockedDates(
302
296
 
303
297
  export function serviceRatesAssociationGetSpecialRates(
304
298
  serviceRatesAssociation: ServiceRatesAssociationExt | null | undefined,
305
- timezone: string | undefined | null
299
+ timezone: string | undefined | null,
300
+ filterPastDates: boolean = false
306
301
  ) {
307
302
  return (
308
303
  serviceRatesAssociation?.serviceSpecialRates
309
304
  ?.filter((rate) => rate.isAvailable)
310
305
  .map((rate) => {
311
- const rateRange = {
312
- start: dateTimeFromDate(
313
- rate.startDate,
314
- undefined,
315
- timezone ?? undefined
316
- ),
317
- end: dateTimeFromDate(rate.endDate, undefined, timezone ?? undefined),
318
- } as LuxonDateRange;
319
-
320
- return rateRange;
321
- // return dateRangeNormalizeToMWY(rateRange, referenceRange);
322
- }) ?? []
306
+ return serviceRateToLuxonRate(
307
+ rate,
308
+ timezone
309
+ ) as ServiceSpecialRatesExtT;
310
+ })
311
+ .filter(
312
+ (rate: ServiceSpecialRatesExtT) =>
313
+ !filterPastDates ||
314
+ (rate.dateTimeRange.start >= DateTime.now() &&
315
+ rate.dateTimeRange.end >= DateTime.now())
316
+ ) ?? []
323
317
  );
324
318
  }