@star-insure/sdk 1.1.18 → 1.1.20
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/lib/calculatePricing.d.ts +14 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/inertiaOptions.d.ts +1 -1
- package/dist/sdk.cjs.development.js +81 -3
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +80 -4
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/models/quotes/QuoteRequest.d.ts +1 -2
- package/package.json +1 -1
- package/src/lib/calculatePricing.tsx +64 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/inertiaOptions.tsx +1 -1
- package/src/lib/quoteRequestForm.tsx +1 -1
- package/src/types/models/quotes/QuoteRequest.ts +1 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PolicyEnhancement, QuoteRequestPurchaseOption } from "../types";
|
|
2
|
+
interface CalculationArguments {
|
|
3
|
+
option: QuoteRequestPurchaseOption;
|
|
4
|
+
selectedEnhancements: PolicyEnhancement['id'][];
|
|
5
|
+
brokerFee?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function calcMonthlyEnhancementPrice(enhancement: PolicyEnhancement): number;
|
|
8
|
+
export declare function calcPurchaseOptionPricing({ option, selectedEnhancements, brokerFee }: CalculationArguments): {
|
|
9
|
+
monthly: number;
|
|
10
|
+
annually: number;
|
|
11
|
+
monthlyWithGst: number;
|
|
12
|
+
annuallyWithGst: number;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { VisitOptions } from '@inertiajs/inertia/types';
|
|
|
2
2
|
interface Options {
|
|
3
3
|
successMessage?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function useInertiaOptions({ successMessage }
|
|
5
|
+
export declare function useInertiaOptions({ successMessage }?: Options): VisitOptions;
|
|
6
6
|
export {};
|
|
@@ -244,8 +244,9 @@ var useToast = function useToast() {
|
|
|
244
244
|
return React.useContext(ToastContext);
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
function useInertiaOptions(
|
|
248
|
-
var _ref
|
|
247
|
+
function useInertiaOptions(_temp) {
|
|
248
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
249
|
+
_ref$successMessage = _ref.successMessage,
|
|
249
250
|
successMessage = _ref$successMessage === void 0 ? '' : _ref$successMessage;
|
|
250
251
|
|
|
251
252
|
var _useToast = useToast(),
|
|
@@ -713,7 +714,7 @@ function _extends() {
|
|
|
713
714
|
var initialData = {
|
|
714
715
|
id: undefined,
|
|
715
716
|
status: 'new',
|
|
716
|
-
source: '
|
|
717
|
+
source: 'phone',
|
|
717
718
|
reference: '',
|
|
718
719
|
client_number: '',
|
|
719
720
|
first_name: '',
|
|
@@ -986,6 +987,81 @@ function calculateAge(date) {
|
|
|
986
987
|
return age;
|
|
987
988
|
}
|
|
988
989
|
|
|
990
|
+
function calculateMonthly(_ref) {
|
|
991
|
+
var option = _ref.option,
|
|
992
|
+
selectedEnhancements = _ref.selectedEnhancements;
|
|
993
|
+
var premium = option.monthly_premium || 0;
|
|
994
|
+
var enhancementsCost = selectedEnhancements.reduce(function (acc, id) {
|
|
995
|
+
var _option$enhancements;
|
|
996
|
+
|
|
997
|
+
var enhancement = (_option$enhancements = option.enhancements) == null ? void 0 : _option$enhancements.find(function (e) {
|
|
998
|
+
return e.id === id;
|
|
999
|
+
});
|
|
1000
|
+
if (!enhancement) return acc;
|
|
1001
|
+
var enhancementPremium = calcMonthlyEnhancementPrice(enhancement);
|
|
1002
|
+
|
|
1003
|
+
if (!acc) {
|
|
1004
|
+
return enhancementPremium;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
return acc + enhancementPremium;
|
|
1008
|
+
}, 0) || 0;
|
|
1009
|
+
return premium + enhancementsCost;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function calculateAnnually(_ref2) {
|
|
1013
|
+
var option = _ref2.option,
|
|
1014
|
+
selectedEnhancements = _ref2.selectedEnhancements,
|
|
1015
|
+
_ref2$brokerFee = _ref2.brokerFee,
|
|
1016
|
+
brokerFee = _ref2$brokerFee === void 0 ? 0 : _ref2$brokerFee;
|
|
1017
|
+
var premium = option.premium || 0;
|
|
1018
|
+
var fsl = option.fsl || 0;
|
|
1019
|
+
var enhancementsCost = selectedEnhancements.reduce(function (acc, id) {
|
|
1020
|
+
var _option$enhancements2;
|
|
1021
|
+
|
|
1022
|
+
var enhancement = (_option$enhancements2 = option.enhancements) == null ? void 0 : _option$enhancements2.find(function (e) {
|
|
1023
|
+
return e.id === id;
|
|
1024
|
+
});
|
|
1025
|
+
if (!enhancement) return acc;
|
|
1026
|
+
return (acc || 0) + (enhancement.premium || 0);
|
|
1027
|
+
}, 0) || 0;
|
|
1028
|
+
return premium + fsl + enhancementsCost + brokerFee;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
function calcMonthlyEnhancementPrice(enhancement) {
|
|
1032
|
+
if (!enhancement.premium) return 0;
|
|
1033
|
+
var monthlyPremium = enhancement.premium / 100 / 12;
|
|
1034
|
+
|
|
1035
|
+
if (enhancement.disable_rounding) {
|
|
1036
|
+
return Math.round(monthlyPremium * 100);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
return Math.round(Math.ceil(monthlyPremium) * 100);
|
|
1040
|
+
}
|
|
1041
|
+
function calcPurchaseOptionPricing(_ref3) {
|
|
1042
|
+
var option = _ref3.option,
|
|
1043
|
+
selectedEnhancements = _ref3.selectedEnhancements,
|
|
1044
|
+
_ref3$brokerFee = _ref3.brokerFee,
|
|
1045
|
+
brokerFee = _ref3$brokerFee === void 0 ? 0 : _ref3$brokerFee;
|
|
1046
|
+
var monthly = calculateMonthly({
|
|
1047
|
+
option: option,
|
|
1048
|
+
selectedEnhancements: selectedEnhancements
|
|
1049
|
+
});
|
|
1050
|
+
var annually = calculateAnnually({
|
|
1051
|
+
option: option,
|
|
1052
|
+
selectedEnhancements: selectedEnhancements,
|
|
1053
|
+
brokerFee: brokerFee
|
|
1054
|
+
});
|
|
1055
|
+
var monthlyWithGst = addGst(monthly);
|
|
1056
|
+
var annuallyWithGst = addGst(annually);
|
|
1057
|
+
return {
|
|
1058
|
+
monthly: monthly,
|
|
1059
|
+
annually: annually,
|
|
1060
|
+
monthlyWithGst: monthlyWithGst,
|
|
1061
|
+
annuallyWithGst: annuallyWithGst
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
|
|
989
1065
|
function Button(_ref) {
|
|
990
1066
|
var className = _ref.className,
|
|
991
1067
|
href = _ref.href,
|
|
@@ -1981,6 +2057,8 @@ exports.ToastProvider = ToastProvider;
|
|
|
1981
2057
|
exports.Toasts = Toasts;
|
|
1982
2058
|
exports.addGst = addGst;
|
|
1983
2059
|
exports.autocomplete = autocomplete;
|
|
2060
|
+
exports.calcMonthlyEnhancementPrice = calcMonthlyEnhancementPrice;
|
|
2061
|
+
exports.calcPurchaseOptionPricing = calcPurchaseOptionPricing;
|
|
1984
2062
|
exports.calculateAge = calculateAge;
|
|
1985
2063
|
exports.formatDateForTable = formatDateForTable;
|
|
1986
2064
|
exports.formatDateNice = formatDateNice;
|