arky-sdk 0.3.86 → 0.3.88
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/dist/index.cjs +2 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -18
- package/dist/index.d.ts +2 -18
- package/dist/index.js +2 -198
- package/dist/index.js.map +1 -1
- package/dist/svg-3F_m7296.d.cts +133 -0
- package/dist/svg-4hIdMU6f.d.ts +133 -0
- package/dist/utils.cjs +0 -193
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -179
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/promo-CZi1KfyM.d.cts +0 -271
- package/dist/promo-gWLL0twu.d.ts +0 -271
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Price, Payment } from './types.cjs';
|
|
2
|
+
|
|
3
|
+
interface Block {
|
|
4
|
+
id: string;
|
|
5
|
+
key: string;
|
|
6
|
+
type: string;
|
|
7
|
+
properties: any;
|
|
8
|
+
value: any;
|
|
9
|
+
}
|
|
10
|
+
interface Collection {
|
|
11
|
+
id: string;
|
|
12
|
+
blocks: Block[];
|
|
13
|
+
}
|
|
14
|
+
interface CollectionEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
collection_id: string;
|
|
17
|
+
blocks: Block[];
|
|
18
|
+
}
|
|
19
|
+
declare function getBlockLabel(block: any, locale?: string): string;
|
|
20
|
+
declare function formatBlockValue(block: any): string;
|
|
21
|
+
declare function prepareBlocksForSubmission(formData: any): any[];
|
|
22
|
+
declare function extractBlockValues(blocks: any[]): Record<string, any>;
|
|
23
|
+
declare function getBlockTextValue(block: any, locale?: string): string;
|
|
24
|
+
declare const getBlockValue: (entry: any, blockKey: string) => any;
|
|
25
|
+
declare const getBlockValues: (entry: any, blockKey: string) => any;
|
|
26
|
+
declare const getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
|
|
27
|
+
declare const getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
|
|
28
|
+
declare const getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
29
|
+
declare const translateMap: (labels: any, lang: string, fallback?: string) => any;
|
|
30
|
+
|
|
31
|
+
declare function convertToMajor(minorAmount: number): number;
|
|
32
|
+
declare function convertToMinor(majorAmount: number): number;
|
|
33
|
+
declare function getCurrencyFromMarket(marketId: string): string;
|
|
34
|
+
declare function formatCurrencyAmount(amount: number, currency: string, options?: {
|
|
35
|
+
showSymbols?: boolean;
|
|
36
|
+
decimalPlaces?: number;
|
|
37
|
+
customSymbol?: string;
|
|
38
|
+
}): string;
|
|
39
|
+
declare function formatMinor(amountMinor: number, currency: string, options?: {
|
|
40
|
+
showSymbols?: boolean;
|
|
41
|
+
decimalPlaces?: number;
|
|
42
|
+
customSymbol?: string;
|
|
43
|
+
}): string;
|
|
44
|
+
declare function formatPayment(payment: Payment, options?: {
|
|
45
|
+
showSymbols?: boolean;
|
|
46
|
+
decimalPlaces?: number;
|
|
47
|
+
showBreakdown?: boolean;
|
|
48
|
+
}): string;
|
|
49
|
+
declare function getMarketPrice(prices: Price[], marketId: string, businessMarkets?: any[], options?: {
|
|
50
|
+
showSymbols?: boolean;
|
|
51
|
+
decimalPlaces?: number;
|
|
52
|
+
showCompareAt?: boolean;
|
|
53
|
+
fallbackMarket?: string;
|
|
54
|
+
}): string;
|
|
55
|
+
declare function getPriceAmount(prices: Price[], marketId: string, fallbackMarket?: string): number;
|
|
56
|
+
declare function createPaymentForCheckout(subtotalMinor: number, marketId: string, currency: string, paymentMethod: any, options?: {
|
|
57
|
+
discount?: number;
|
|
58
|
+
taxAmount?: number;
|
|
59
|
+
taxRateBps?: number;
|
|
60
|
+
promoCode?: {
|
|
61
|
+
id: string;
|
|
62
|
+
code: string;
|
|
63
|
+
type: string;
|
|
64
|
+
value: number;
|
|
65
|
+
};
|
|
66
|
+
}): Payment;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Maps currency codes to their display symbols
|
|
70
|
+
*/
|
|
71
|
+
declare function getCurrencySymbol(currency: string): string;
|
|
72
|
+
|
|
73
|
+
interface ValidationResult {
|
|
74
|
+
isValid: boolean;
|
|
75
|
+
error?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function validatePhoneNumber(phone: string): ValidationResult;
|
|
78
|
+
declare function validateEmail(email: string): ValidationResult;
|
|
79
|
+
declare function validateVerificationCode(code: string): ValidationResult;
|
|
80
|
+
declare function validateRequired(value: any, fieldName?: string): ValidationResult;
|
|
81
|
+
|
|
82
|
+
declare const tzGroups: {
|
|
83
|
+
label: string;
|
|
84
|
+
zones: {
|
|
85
|
+
label: string;
|
|
86
|
+
value: string;
|
|
87
|
+
}[];
|
|
88
|
+
}[];
|
|
89
|
+
declare function findTimeZone(groups: typeof tzGroups): string;
|
|
90
|
+
|
|
91
|
+
declare const locales: readonly ["en", "sr-latn"];
|
|
92
|
+
/**
|
|
93
|
+
* * returns "slugified" text.
|
|
94
|
+
* @param text: string - text to slugify
|
|
95
|
+
*/
|
|
96
|
+
declare function slugify(text: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
|
|
99
|
+
* @param text: string - text to humanize
|
|
100
|
+
*/
|
|
101
|
+
declare function humanize(text: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
|
|
104
|
+
* @param text: string - text to categorify
|
|
105
|
+
* @returns string - categorified text
|
|
106
|
+
*/
|
|
107
|
+
declare function categorify(text: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* * returns a nicely formatted string of the date passed
|
|
110
|
+
* @param date: string | number | Date - date to format
|
|
111
|
+
* @param locale: string - locale to format the date in
|
|
112
|
+
* @returns string - formatted date
|
|
113
|
+
*/
|
|
114
|
+
declare function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string;
|
|
115
|
+
|
|
116
|
+
declare function fetchSvgContent(mediaObject: any): Promise<string | null>;
|
|
117
|
+
/**
|
|
118
|
+
* Server-side helper for Astro components to fetch SVG content during SSR
|
|
119
|
+
*
|
|
120
|
+
* @param mediaObject The media object from the CMS
|
|
121
|
+
* @returns The SVG content as a string, or empty string on failure
|
|
122
|
+
*/
|
|
123
|
+
declare function getSvgContentForAstro(mediaObject: any): Promise<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Client-side helper to fetch and inject SVG content into DOM elements
|
|
126
|
+
*
|
|
127
|
+
* @param mediaObject The media object from the CMS
|
|
128
|
+
* @param targetElement The DOM element to inject the SVG into
|
|
129
|
+
* @param className Optional CSS class to add to the SVG
|
|
130
|
+
*/
|
|
131
|
+
declare function injectSvgIntoElement(mediaObject: any, targetElement: HTMLElement, className?: string): Promise<void>;
|
|
132
|
+
|
|
133
|
+
export { translateMap as A, type Block as B, type Collection as C, convertToMajor as D, convertToMinor as E, getCurrencyFromMarket as F, formatCurrencyAmount as G, tzGroups as H, validateEmail as I, validateVerificationCode as J, validateRequired as K, type ValidationResult as V, getBlockTextValue as a, getMarketPrice as b, getPriceAmount as c, formatPayment as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, formatMinor as h, createPaymentForCheckout as i, getCurrencySymbol as j, findTimeZone as k, humanize as l, categorify as m, formatDate as n, getSvgContentForAstro as o, prepareBlocksForSubmission as p, fetchSvgContent as q, injectSvgIntoElement as r, slugify as s, type CollectionEntry as t, getBlockValue as u, validatePhoneNumber as v, getBlockValues as w, getBlockObjectValues as x, getBlockFromArray as y, getImageUrl as z };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Price, Payment } from './types.js';
|
|
2
|
+
|
|
3
|
+
interface Block {
|
|
4
|
+
id: string;
|
|
5
|
+
key: string;
|
|
6
|
+
type: string;
|
|
7
|
+
properties: any;
|
|
8
|
+
value: any;
|
|
9
|
+
}
|
|
10
|
+
interface Collection {
|
|
11
|
+
id: string;
|
|
12
|
+
blocks: Block[];
|
|
13
|
+
}
|
|
14
|
+
interface CollectionEntry {
|
|
15
|
+
id: string;
|
|
16
|
+
collection_id: string;
|
|
17
|
+
blocks: Block[];
|
|
18
|
+
}
|
|
19
|
+
declare function getBlockLabel(block: any, locale?: string): string;
|
|
20
|
+
declare function formatBlockValue(block: any): string;
|
|
21
|
+
declare function prepareBlocksForSubmission(formData: any): any[];
|
|
22
|
+
declare function extractBlockValues(blocks: any[]): Record<string, any>;
|
|
23
|
+
declare function getBlockTextValue(block: any, locale?: string): string;
|
|
24
|
+
declare const getBlockValue: (entry: any, blockKey: string) => any;
|
|
25
|
+
declare const getBlockValues: (entry: any, blockKey: string) => any;
|
|
26
|
+
declare const getBlockObjectValues: (entry: any, blockKey: string, locale?: string) => any;
|
|
27
|
+
declare const getBlockFromArray: (entry: any, blockKey: string, locale?: string) => any;
|
|
28
|
+
declare const getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
|
|
29
|
+
declare const translateMap: (labels: any, lang: string, fallback?: string) => any;
|
|
30
|
+
|
|
31
|
+
declare function convertToMajor(minorAmount: number): number;
|
|
32
|
+
declare function convertToMinor(majorAmount: number): number;
|
|
33
|
+
declare function getCurrencyFromMarket(marketId: string): string;
|
|
34
|
+
declare function formatCurrencyAmount(amount: number, currency: string, options?: {
|
|
35
|
+
showSymbols?: boolean;
|
|
36
|
+
decimalPlaces?: number;
|
|
37
|
+
customSymbol?: string;
|
|
38
|
+
}): string;
|
|
39
|
+
declare function formatMinor(amountMinor: number, currency: string, options?: {
|
|
40
|
+
showSymbols?: boolean;
|
|
41
|
+
decimalPlaces?: number;
|
|
42
|
+
customSymbol?: string;
|
|
43
|
+
}): string;
|
|
44
|
+
declare function formatPayment(payment: Payment, options?: {
|
|
45
|
+
showSymbols?: boolean;
|
|
46
|
+
decimalPlaces?: number;
|
|
47
|
+
showBreakdown?: boolean;
|
|
48
|
+
}): string;
|
|
49
|
+
declare function getMarketPrice(prices: Price[], marketId: string, businessMarkets?: any[], options?: {
|
|
50
|
+
showSymbols?: boolean;
|
|
51
|
+
decimalPlaces?: number;
|
|
52
|
+
showCompareAt?: boolean;
|
|
53
|
+
fallbackMarket?: string;
|
|
54
|
+
}): string;
|
|
55
|
+
declare function getPriceAmount(prices: Price[], marketId: string, fallbackMarket?: string): number;
|
|
56
|
+
declare function createPaymentForCheckout(subtotalMinor: number, marketId: string, currency: string, paymentMethod: any, options?: {
|
|
57
|
+
discount?: number;
|
|
58
|
+
taxAmount?: number;
|
|
59
|
+
taxRateBps?: number;
|
|
60
|
+
promoCode?: {
|
|
61
|
+
id: string;
|
|
62
|
+
code: string;
|
|
63
|
+
type: string;
|
|
64
|
+
value: number;
|
|
65
|
+
};
|
|
66
|
+
}): Payment;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Maps currency codes to their display symbols
|
|
70
|
+
*/
|
|
71
|
+
declare function getCurrencySymbol(currency: string): string;
|
|
72
|
+
|
|
73
|
+
interface ValidationResult {
|
|
74
|
+
isValid: boolean;
|
|
75
|
+
error?: string;
|
|
76
|
+
}
|
|
77
|
+
declare function validatePhoneNumber(phone: string): ValidationResult;
|
|
78
|
+
declare function validateEmail(email: string): ValidationResult;
|
|
79
|
+
declare function validateVerificationCode(code: string): ValidationResult;
|
|
80
|
+
declare function validateRequired(value: any, fieldName?: string): ValidationResult;
|
|
81
|
+
|
|
82
|
+
declare const tzGroups: {
|
|
83
|
+
label: string;
|
|
84
|
+
zones: {
|
|
85
|
+
label: string;
|
|
86
|
+
value: string;
|
|
87
|
+
}[];
|
|
88
|
+
}[];
|
|
89
|
+
declare function findTimeZone(groups: typeof tzGroups): string;
|
|
90
|
+
|
|
91
|
+
declare const locales: readonly ["en", "sr-latn"];
|
|
92
|
+
/**
|
|
93
|
+
* * returns "slugified" text.
|
|
94
|
+
* @param text: string - text to slugify
|
|
95
|
+
*/
|
|
96
|
+
declare function slugify(text: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* * returns "humanized" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest
|
|
99
|
+
* @param text: string - text to humanize
|
|
100
|
+
*/
|
|
101
|
+
declare function humanize(text: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* * returns "categorified" text. runs slugify() and then replaces - with space and upper cases everything
|
|
104
|
+
* @param text: string - text to categorify
|
|
105
|
+
* @returns string - categorified text
|
|
106
|
+
*/
|
|
107
|
+
declare function categorify(text: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* * returns a nicely formatted string of the date passed
|
|
110
|
+
* @param date: string | number | Date - date to format
|
|
111
|
+
* @param locale: string - locale to format the date in
|
|
112
|
+
* @returns string - formatted date
|
|
113
|
+
*/
|
|
114
|
+
declare function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string;
|
|
115
|
+
|
|
116
|
+
declare function fetchSvgContent(mediaObject: any): Promise<string | null>;
|
|
117
|
+
/**
|
|
118
|
+
* Server-side helper for Astro components to fetch SVG content during SSR
|
|
119
|
+
*
|
|
120
|
+
* @param mediaObject The media object from the CMS
|
|
121
|
+
* @returns The SVG content as a string, or empty string on failure
|
|
122
|
+
*/
|
|
123
|
+
declare function getSvgContentForAstro(mediaObject: any): Promise<string>;
|
|
124
|
+
/**
|
|
125
|
+
* Client-side helper to fetch and inject SVG content into DOM elements
|
|
126
|
+
*
|
|
127
|
+
* @param mediaObject The media object from the CMS
|
|
128
|
+
* @param targetElement The DOM element to inject the SVG into
|
|
129
|
+
* @param className Optional CSS class to add to the SVG
|
|
130
|
+
*/
|
|
131
|
+
declare function injectSvgIntoElement(mediaObject: any, targetElement: HTMLElement, className?: string): Promise<void>;
|
|
132
|
+
|
|
133
|
+
export { translateMap as A, type Block as B, type Collection as C, convertToMajor as D, convertToMinor as E, getCurrencyFromMarket as F, formatCurrencyAmount as G, tzGroups as H, validateEmail as I, validateVerificationCode as J, validateRequired as K, type ValidationResult as V, getBlockTextValue as a, getMarketPrice as b, getPriceAmount as c, formatPayment as d, extractBlockValues as e, formatBlockValue as f, getBlockLabel as g, formatMinor as h, createPaymentForCheckout as i, getCurrencySymbol as j, findTimeZone as k, humanize as l, categorify as m, formatDate as n, getSvgContentForAstro as o, prepareBlocksForSubmission as p, fetchSvgContent as q, injectSvgIntoElement as r, slugify as s, type CollectionEntry as t, getBlockValue as u, validatePhoneNumber as v, getBlockValues as w, getBlockObjectValues as x, getBlockFromArray as y, getImageUrl as z };
|
package/dist/utils.cjs
CHANGED
|
@@ -662,189 +662,9 @@ function validateRequired(value, fieldName = "This field") {
|
|
|
662
662
|
return { isValid: true };
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
-
// src/utils/time.ts
|
|
666
|
-
function formatTime(ts, tz) {
|
|
667
|
-
return new Date(ts * 1e3).toLocaleTimeString([], {
|
|
668
|
-
hour: "2-digit",
|
|
669
|
-
minute: "2-digit",
|
|
670
|
-
timeZone: tz
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
function formatSlotTime(from, to, tz) {
|
|
674
|
-
return `${formatTime(from, tz)} \u2013 ${formatTime(to, tz)}`;
|
|
675
|
-
}
|
|
676
|
-
function getTzOffset(date, tz) {
|
|
677
|
-
const utc = new Date(date.toLocaleString("en-US", { timeZone: "UTC" }));
|
|
678
|
-
const local = new Date(date.toLocaleString("en-US", { timeZone: tz }));
|
|
679
|
-
return (utc.getTime() - local.getTime()) / 6e4;
|
|
680
|
-
}
|
|
681
|
-
function toUtcTimestamp(year, month, day, mins, tz) {
|
|
682
|
-
const midnight = new Date(Date.UTC(year, month - 1, day));
|
|
683
|
-
const offset = getTzOffset(midnight, tz);
|
|
684
|
-
return Math.floor(midnight.getTime() / 1e3) + (mins + offset) * 60;
|
|
685
|
-
}
|
|
686
|
-
function formatDateDisplay(dateStr, tz) {
|
|
687
|
-
if (!dateStr) return "";
|
|
688
|
-
const date = /* @__PURE__ */ new Date(dateStr + "T00:00:00");
|
|
689
|
-
return date.toLocaleDateString("en-US", {
|
|
690
|
-
weekday: "short",
|
|
691
|
-
month: "short",
|
|
692
|
-
day: "numeric",
|
|
693
|
-
timeZone: tz
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
function getIsoDate(date, tz) {
|
|
697
|
-
return date.toLocaleDateString("en-CA", { timeZone: tz });
|
|
698
|
-
}
|
|
699
|
-
function parseIsoDate(isoDate) {
|
|
700
|
-
const [year, month, day] = isoDate.split("-").map(Number);
|
|
701
|
-
return { year, month, day };
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// src/utils/slots.ts
|
|
705
|
-
function getTotalDuration(durations) {
|
|
706
|
-
return durations.reduce((sum, d) => sum + d.duration, 0);
|
|
707
|
-
}
|
|
708
|
-
function isBlocked(from, to, timeline, limit) {
|
|
709
|
-
const before = timeline.filter((p) => p.timestamp <= from).sort((a, b) => b.timestamp - a.timestamp);
|
|
710
|
-
if (before.length > 0 && before[0].concurrent >= limit) return true;
|
|
711
|
-
for (const p of timeline) {
|
|
712
|
-
if (p.timestamp >= from && p.timestamp < to && p.concurrent >= limit) {
|
|
713
|
-
return true;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return false;
|
|
717
|
-
}
|
|
718
|
-
function getWorkingHoursForDate(wt, date, tz) {
|
|
719
|
-
if (!wt) return [];
|
|
720
|
-
const dayName = date.toLocaleDateString("en-US", { weekday: "long", timeZone: tz }).toLowerCase();
|
|
721
|
-
const m = date.getMonth() + 1;
|
|
722
|
-
const d = date.getDate();
|
|
723
|
-
const ts = Math.floor(date.getTime() / 1e3);
|
|
724
|
-
const specific = wt.specificDates?.find((s) => s.date === ts);
|
|
725
|
-
if (specific) return specific.workingHours || [];
|
|
726
|
-
const outcast = wt.outcastDates?.find((o) => o.month === m && o.day === d);
|
|
727
|
-
if (outcast) return outcast.workingHours || [];
|
|
728
|
-
return wt.workingDays?.find((w) => w.day === dayName)?.workingHours || [];
|
|
729
|
-
}
|
|
730
|
-
function computeSlotsForDate(opts) {
|
|
731
|
-
const { providers, date, durations, timezone, slotInterval } = opts;
|
|
732
|
-
const total = getTotalDuration(durations);
|
|
733
|
-
const interval = slotInterval || total;
|
|
734
|
-
const slots = [];
|
|
735
|
-
const nowTs = Math.floor(Date.now() / 1e3);
|
|
736
|
-
const today = /* @__PURE__ */ new Date();
|
|
737
|
-
today.setHours(0, 0, 0, 0);
|
|
738
|
-
if (date < today) return [];
|
|
739
|
-
const [year, month, day] = date.toLocaleDateString("en-CA", { timeZone: timezone }).split("-").map(Number);
|
|
740
|
-
for (const provider of providers) {
|
|
741
|
-
const workingHours = getWorkingHoursForDate(provider.workingTime, date, timezone);
|
|
742
|
-
for (const wh of workingHours) {
|
|
743
|
-
for (let m = wh.from; m + total <= wh.to; m += interval) {
|
|
744
|
-
const from = toUtcTimestamp(year, month, day, m, timezone);
|
|
745
|
-
const to = from + total * 60;
|
|
746
|
-
if (from < nowTs) continue;
|
|
747
|
-
if (!isBlocked(from, to, provider.timeline, provider.concurrentLimit)) {
|
|
748
|
-
slots.push({ from, to, providerId: provider.id });
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
return slots.sort((a, b) => a.from - b.from);
|
|
754
|
-
}
|
|
755
|
-
function hasAvailableSlots(opts) {
|
|
756
|
-
return computeSlotsForDate(opts).length > 0;
|
|
757
|
-
}
|
|
758
|
-
function buildCalendar(opts) {
|
|
759
|
-
const {
|
|
760
|
-
currentMonth,
|
|
761
|
-
selectedDate,
|
|
762
|
-
startDate,
|
|
763
|
-
endDate,
|
|
764
|
-
providers,
|
|
765
|
-
selectedProvider,
|
|
766
|
-
durations,
|
|
767
|
-
timezone,
|
|
768
|
-
isMultiDay
|
|
769
|
-
} = opts;
|
|
770
|
-
const year = currentMonth.getFullYear();
|
|
771
|
-
const month = currentMonth.getMonth();
|
|
772
|
-
const first = new Date(year, month, 1);
|
|
773
|
-
const last = new Date(year, month + 1, 0);
|
|
774
|
-
const today = /* @__PURE__ */ new Date();
|
|
775
|
-
today.setHours(0, 0, 0, 0);
|
|
776
|
-
const cells = [];
|
|
777
|
-
const pad = (first.getDay() + 6) % 7;
|
|
778
|
-
for (let i = 0; i < pad; i++) {
|
|
779
|
-
cells.push({
|
|
780
|
-
date: /* @__PURE__ */ new Date(0),
|
|
781
|
-
iso: "",
|
|
782
|
-
available: false,
|
|
783
|
-
isSelected: false,
|
|
784
|
-
isInRange: false,
|
|
785
|
-
isToday: false,
|
|
786
|
-
blank: true
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
const activeProviders = selectedProvider ? providers.filter((p) => p.id === selectedProvider.id) : providers;
|
|
790
|
-
for (let d = 1; d <= last.getDate(); d++) {
|
|
791
|
-
const date = new Date(year, month, d);
|
|
792
|
-
const iso = `${year}-${String(month + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
|
|
793
|
-
const available = activeProviders.length > 0 && hasAvailableSlots({ providers: activeProviders, date, durations, timezone });
|
|
794
|
-
const isToday = date.getTime() === today.getTime();
|
|
795
|
-
let isSelected = false;
|
|
796
|
-
let isInRange = false;
|
|
797
|
-
if (isMultiDay) {
|
|
798
|
-
isSelected = iso === startDate || iso === endDate;
|
|
799
|
-
if (startDate && endDate) {
|
|
800
|
-
isInRange = iso > startDate && iso < endDate;
|
|
801
|
-
}
|
|
802
|
-
} else {
|
|
803
|
-
isSelected = iso === selectedDate;
|
|
804
|
-
}
|
|
805
|
-
cells.push({
|
|
806
|
-
date,
|
|
807
|
-
iso,
|
|
808
|
-
available,
|
|
809
|
-
isSelected,
|
|
810
|
-
isInRange,
|
|
811
|
-
isToday,
|
|
812
|
-
blank: false
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
return cells;
|
|
816
|
-
}
|
|
817
|
-
function getMonthYear(date) {
|
|
818
|
-
return date.toLocaleDateString("en-US", { month: "long", year: "numeric" });
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
// src/utils/promo.ts
|
|
822
|
-
function mapQuoteError(code, fallback) {
|
|
823
|
-
switch (code) {
|
|
824
|
-
case "PROMO.MIN_ORDER":
|
|
825
|
-
return fallback || "Promo requires a higher minimum order.";
|
|
826
|
-
case "PROMO.NOT_ACTIVE":
|
|
827
|
-
return "Promo code is not active.";
|
|
828
|
-
case "PROMO.NOT_YET_VALID":
|
|
829
|
-
return "Promo code is not yet valid.";
|
|
830
|
-
case "PROMO.EXPIRED":
|
|
831
|
-
return "Promo code has expired.";
|
|
832
|
-
case "PROMO.MAX_USES":
|
|
833
|
-
return "Promo code usage limit exceeded.";
|
|
834
|
-
case "PROMO.MAX_USES_PER_USER":
|
|
835
|
-
return "You have already used this promo code.";
|
|
836
|
-
case "PROMO.NOT_FOUND":
|
|
837
|
-
return "Promo code not found.";
|
|
838
|
-
default:
|
|
839
|
-
return fallback || "Failed to fetch quote.";
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
|
|
843
665
|
exports.ERROR_CODES = ERROR_CODES;
|
|
844
666
|
exports.ERROR_CONSTANTS = ERROR_CONSTANTS;
|
|
845
|
-
exports.buildCalendar = buildCalendar;
|
|
846
667
|
exports.categorify = categorify;
|
|
847
|
-
exports.computeSlotsForDate = computeSlotsForDate;
|
|
848
668
|
exports.convertServerErrorToRequestError = convertServerErrorToRequestError;
|
|
849
669
|
exports.convertToMajor = convertToMajor;
|
|
850
670
|
exports.convertToMinor = convertToMinor;
|
|
@@ -856,11 +676,8 @@ exports.findTimeZone = findTimeZone;
|
|
|
856
676
|
exports.formatBlockValue = formatBlockValue;
|
|
857
677
|
exports.formatCurrencyAmount = formatCurrencyAmount;
|
|
858
678
|
exports.formatDate = formatDate;
|
|
859
|
-
exports.formatDateDisplay = formatDateDisplay;
|
|
860
679
|
exports.formatMinor = formatMinor;
|
|
861
680
|
exports.formatPayment = formatPayment;
|
|
862
|
-
exports.formatSlotTime = formatSlotTime;
|
|
863
|
-
exports.formatTime = formatTime;
|
|
864
681
|
exports.getBlockFromArray = getBlockFromArray;
|
|
865
682
|
exports.getBlockLabel = getBlockLabel;
|
|
866
683
|
exports.getBlockObjectValues = getBlockObjectValues;
|
|
@@ -871,24 +688,14 @@ exports.getCurrencyFromMarket = getCurrencyFromMarket;
|
|
|
871
688
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
872
689
|
exports.getErrorMessage = getErrorMessage;
|
|
873
690
|
exports.getImageUrl = getImageUrl;
|
|
874
|
-
exports.getIsoDate = getIsoDate;
|
|
875
691
|
exports.getMarketPrice = getMarketPrice;
|
|
876
|
-
exports.getMonthYear = getMonthYear;
|
|
877
692
|
exports.getPriceAmount = getPriceAmount;
|
|
878
693
|
exports.getSvgContentForAstro = getSvgContentForAstro;
|
|
879
|
-
exports.getTotalDuration = getTotalDuration;
|
|
880
|
-
exports.getTzOffset = getTzOffset;
|
|
881
|
-
exports.getWorkingHoursForDate = getWorkingHoursForDate;
|
|
882
|
-
exports.hasAvailableSlots = hasAvailableSlots;
|
|
883
694
|
exports.humanize = humanize;
|
|
884
695
|
exports.injectSvgIntoElement = injectSvgIntoElement;
|
|
885
|
-
exports.isBlocked = isBlocked;
|
|
886
696
|
exports.isErrorCode = isErrorCode;
|
|
887
|
-
exports.mapQuoteError = mapQuoteError;
|
|
888
|
-
exports.parseIsoDate = parseIsoDate;
|
|
889
697
|
exports.prepareBlocksForSubmission = prepareBlocksForSubmission;
|
|
890
698
|
exports.slugify = slugify;
|
|
891
|
-
exports.toUtcTimestamp = toUtcTimestamp;
|
|
892
699
|
exports.transformErrors = transformErrors;
|
|
893
700
|
exports.translateMap = translateMap;
|
|
894
701
|
exports.tzGroups = tzGroups;
|