@myrjfa/state 3.0.1 → 3.0.2
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Planning preferences only; these are not booking quotes or live prices. */
|
|
2
|
+
export declare function getItineraryDailyBudgetRange(budgetType: string): {
|
|
3
|
+
min: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function clampItineraryDailyBudget(dailyBudget: number, budgetType: string): number;
|
|
7
|
+
export declare function calculateItineraryBudget(dailyBudget: number, numberOfDays: number, numberOfPeople: number): number;
|
|
8
|
+
//# sourceMappingURL=itineraryBudget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itineraryBudget.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/itineraryBudget.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAI9F;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAIzF;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAIlH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Planning preferences only; these are not booking quotes or live prices. */
|
|
2
|
+
export function getItineraryDailyBudgetRange(budgetType) {
|
|
3
|
+
if (budgetType === "backpacker")
|
|
4
|
+
return { min: 1000, max: 3000 };
|
|
5
|
+
if (budgetType === "luxury")
|
|
6
|
+
return { min: 8000 };
|
|
7
|
+
return { min: 3000, max: 8000 };
|
|
8
|
+
}
|
|
9
|
+
export function clampItineraryDailyBudget(dailyBudget, budgetType) {
|
|
10
|
+
const { min, max } = getItineraryDailyBudgetRange(budgetType);
|
|
11
|
+
if (!Number.isFinite(dailyBudget))
|
|
12
|
+
return min;
|
|
13
|
+
return Math.max(min, Math.min(max ?? Infinity, Math.trunc(dailyBudget)));
|
|
14
|
+
}
|
|
15
|
+
export function calculateItineraryBudget(dailyBudget, numberOfDays, numberOfPeople) {
|
|
16
|
+
if (![dailyBudget, numberOfDays, numberOfPeople].every((value) => Number.isSafeInteger(value) && value > 0))
|
|
17
|
+
return 0;
|
|
18
|
+
const total = dailyBudget * numberOfDays * numberOfPeople;
|
|
19
|
+
return Number.isSafeInteger(total) ? total : 0;
|
|
20
|
+
}
|