@meetelise/chat 1.34.2 → 1.34.3
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 +1 -1
- package/dist/src/MyPubnub.d.ts +0 -116
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector.d.ts +0 -28
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector.d.ts +0 -18
- package/dist/src/WebComponent/FeeCalculator/components/addons/common-addon-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector.d.ts +0 -22
- package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.d.ts +0 -46
- package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card.d.ts +0 -21
- package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item.d.ts +0 -13
- package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.d.ts +0 -34
- package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.d.ts +0 -18
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner-styles.d.ts +0 -1
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner.d.ts +0 -8
- package/dist/src/WebComponent/FeeCalculator/components/incentive-banner/index.d.ts +0 -1
- package/dist/src/WebComponent/FeeCalculator/components/index.d.ts +0 -5
- package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card.d.ts +0 -13
- package/dist/src/WebComponent/FeeCalculator/constants.d.ts +0 -3
- package/dist/src/WebComponent/FeeCalculator/fee-calculator-styles.d.ts +0 -1
- package/dist/src/WebComponent/FeeCalculator/fee-calculator.d.ts +0 -55
- package/dist/src/WebComponent/FeeCalculator/index.d.ts +0 -2
- package/dist/src/WebComponent/FeeCalculator/model/building-fee-view.d.ts +0 -41
- package/dist/src/WebComponent/FeeCalculator/model/building-fee.d.ts +0 -82
- package/dist/src/WebComponent/FeeCalculator/model/desired-addon.d.ts +0 -5
- package/dist/src/WebComponent/FeeCalculator/model/desired-rentable-item.d.ts +0 -4
- package/dist/src/WebComponent/FeeCalculator/model/index.d.ts +0 -13
- package/dist/src/WebComponent/FeeCalculator/model/item-combination.d.ts +0 -6
- package/dist/src/WebComponent/FeeCalculator/model/item-quantity.d.ts +0 -4
- package/dist/src/WebComponent/FeeCalculator/model/pricing-matrix.d.ts +0 -18
- package/dist/src/WebComponent/FeeCalculator/model/pricing-rule.d.ts +0 -8
- package/dist/src/WebComponent/FeeCalculator/model/rent-frequency.d.ts +0 -1
- package/dist/src/WebComponent/FeeCalculator/model/rentable-item-summary.d.ts +0 -9
- package/dist/src/WebComponent/FeeCalculator/model/rentable-item.d.ts +0 -9
- package/dist/src/WebComponent/FeeCalculator/model/transaction-category.d.ts +0 -23
- package/dist/src/WebComponent/FeeCalculator/model/unit-fee-bundle.d.ts +0 -31
- package/dist/src/WebComponent/LeadSourceClient.d.ts +0 -46
- package/dist/src/WebComponent/OfficeHours.d.ts +0 -21
- package/dist/src/WebComponent/Scheduler/date-picker.d.ts +0 -28
- package/dist/src/WebComponent/Scheduler/time-picker.d.ts +0 -14
- package/dist/src/WebComponent/Scheduler/tour-scheduler.d.ts +0 -101
- package/dist/src/WebComponent/Scheduler/tour-type-option.d.ts +0 -13
- package/dist/src/WebComponent/Scheduler/tourSchedulerStyles.d.ts +0 -1
- package/dist/src/WebComponent/actions/InputStyles.d.ts +0 -1
- package/dist/src/WebComponent/actions/action-confirm-button.d.ts +0 -13
- package/dist/src/WebComponent/actions/call-us-window.d.ts +0 -37
- package/dist/src/WebComponent/actions/collapse-expand-button.d.ts +0 -8
- package/dist/src/WebComponent/actions/details-window.d.ts +0 -14
- package/dist/src/WebComponent/actions/email-us-window.d.ts +0 -46
- package/dist/src/WebComponent/actions/formatPhoneNumber.d.ts +0 -17
- package/dist/src/WebComponent/actions/minimize-expand-button.d.ts +0 -8
- package/dist/src/WebComponent/chat-additional-actions.d.ts +0 -28
- package/dist/src/WebComponent/health-chat.d.ts +0 -47
- package/dist/src/WebComponent/healthchat-styles.d.ts +0 -1
- package/dist/src/WebComponent/icons/ApplyOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/BookTourOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/CalculatorOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/ChatOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/ChevronLeftIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/ChevronRightIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/ContactResidentIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/DollarOutlineIcon.d.ts +0 -7
- package/dist/src/WebComponent/icons/EmailOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/HeyThereEmojiIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/PhoneOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/SendMessageIcon.d.ts +0 -3
- package/dist/src/WebComponent/icons/TourSelfGuidedIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/TourVirtuallyIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/TourWithAgentIcon.d.ts +0 -2
- package/dist/src/WebComponent/icons/XOutlineIcon.d.ts +0 -2
- package/dist/src/WebComponent/index.d.ts +0 -2
- package/dist/src/WebComponent/launcher/Launcher.d.ts +0 -99
- package/dist/src/WebComponent/launcher/launcherStyles.d.ts +0 -1
- package/dist/src/WebComponent/launcher/mobile-launcher.d.ts +0 -27
- package/dist/src/WebComponent/launcher/typeEmojiStyles.d.ts +0 -1
- package/dist/src/WebComponent/launcher/typeMiniStyles.d.ts +0 -1
- package/dist/src/WebComponent/launcher/typeMobileStyles.d.ts +0 -1
- package/dist/src/WebComponent/leasing-chat-styles.d.ts +0 -1
- package/dist/src/WebComponent/loaders/index.d.ts +0 -4
- package/dist/src/WebComponent/loaders/mega-loader.d.ts +0 -7
- package/dist/src/WebComponent/loaders/skeleton-card.d.ts +0 -12
- package/dist/src/WebComponent/loaders/skeleton-loader-styles.d.ts +0 -3
- package/dist/src/WebComponent/loaders/skeleton-loader.d.ts +0 -13
- package/dist/src/WebComponent/me-chat.d.ts +0 -91
- package/dist/src/WebComponent/me-select.d.ts +0 -24
- package/dist/src/WebComponent/mini-loader.d.ts +0 -5
- package/dist/src/WebComponent/pubnub-chat-styles.d.ts +0 -1
- package/dist/src/WebComponent/pubnub-chat.d.ts +0 -49
- package/dist/src/WebComponent/pubnub-media.d.ts +0 -14
- package/dist/src/WebComponent/pubnub-message-styles.d.ts +0 -1
- package/dist/src/WebComponent/pubnub-message.d.ts +0 -39
- package/dist/src/WebComponent/simple-launcher/simple-launcher-styles.d.ts +0 -1
- package/dist/src/WebComponent/simple-launcher/simple-launcher.d.ts +0 -12
- package/dist/src/WebComponent/utilities-chat.d.ts +0 -47
- package/dist/src/WebComponent/utilities-styles.d.ts +0 -1
- package/dist/src/WebComponent/utils.d.ts +0 -31
- package/dist/src/analytics.d.ts +0 -64
- package/dist/src/disclaimers.d.ts +0 -9
- package/dist/src/fetchBuildingABTestType.d.ts +0 -8
- package/dist/src/fetchBuildingInfo.d.ts +0 -57
- package/dist/src/fetchBuildingWebchatView.d.ts +0 -124
- package/dist/src/fetchFeatureFlag.d.ts +0 -14
- package/dist/src/fetchLeadSources.d.ts +0 -4
- package/dist/src/fetchPhoneNumberFromSource.d.ts +0 -6
- package/dist/src/getAvailabilities.d.ts +0 -45
- package/dist/src/getBuildingPhoneNumber.d.ts +0 -1
- package/dist/src/getShouldAllowScheduling.d.ts +0 -1
- package/dist/src/getShouldShowWebchat.d.ts +0 -3
- package/dist/src/getTimezoneString.d.ts +0 -1
- package/dist/src/globals.d.ts +0 -2
- package/dist/src/gtm.d.ts +0 -6
- package/dist/src/handleChatId.d.ts +0 -11
- package/dist/src/insertDNIIntoWebsite.d.ts +0 -5
- package/dist/src/insertLeadSourceIntoSchedulerLinks.d.ts +0 -4
- package/dist/src/main/MEChat.d.ts +0 -74
- package/dist/src/main/utils.d.ts +0 -2
- package/dist/src/postLeadSources.d.ts +0 -3
- package/dist/src/rentgrata.d.ts +0 -4
- package/dist/src/replaceSelectButtonsWithNewLink.d.ts +0 -5
- package/dist/src/services/fees/calculateQuote.d.ts +0 -14
- package/dist/src/services/fees/fetchBuildingFeesV2.d.ts +0 -10
- package/dist/src/services/fees/fetchBuildingUnits.d.ts +0 -29
- package/dist/src/services/fees/utils.d.ts +0 -1
- package/dist/src/svgIcons.d.ts +0 -5
- package/dist/src/themes.d.ts +0 -5
- package/dist/src/types/incentive-v2.d.ts +0 -23
- package/dist/src/types/rest-sdk.types.d.ts +0 -11
- package/dist/src/types/webchat-no-show-reason.d.ts +0 -1
- package/dist/src/utils/queryParamBuilder.d.ts +0 -8
- package/dist/src/utils.d.ts +0 -13
- package/src/MyPubnub.ts +0 -792
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector-styles.ts +0 -35
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-matrix-qty-selector/addon-item-matrix-qty-selector.ts +0 -206
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector-styles.ts +0 -6
- package/src/WebComponent/FeeCalculator/components/addons/addon-item-qty-selector/addon-item-qty-selector.ts +0 -101
- package/src/WebComponent/FeeCalculator/components/addons/common-addon-styles.ts +0 -82
- package/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector-styles.ts +0 -9
- package/src/WebComponent/FeeCalculator/components/addons/rentable-item-qty-selector/rentable-item-qty-selector.ts +0 -124
- package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.ts +0 -142
- package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.ts +0 -243
- package/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.ts +0 -65
- package/src/WebComponent/FeeCalculator/components/fee-card/fee-card.ts +0 -91
- package/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.ts +0 -44
- package/src/WebComponent/FeeCalculator/components/fee-item/fee-item.ts +0 -38
- package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.ts +0 -151
- package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.ts +0 -248
- package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.ts +0 -82
- package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.ts +0 -76
- package/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner-styles.ts +0 -40
- package/src/WebComponent/FeeCalculator/components/incentive-banner/incentive-banner.ts +0 -43
- package/src/WebComponent/FeeCalculator/components/incentive-banner/index.ts +0 -1
- package/src/WebComponent/FeeCalculator/components/index.ts +0 -5
- package/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.ts +0 -39
- package/src/WebComponent/FeeCalculator/components/promo-card/promo-card.ts +0 -39
- package/src/WebComponent/FeeCalculator/constants.ts +0 -5
- package/src/WebComponent/FeeCalculator/fee-calculator-styles.ts +0 -310
- package/src/WebComponent/FeeCalculator/fee-calculator.ts +0 -341
- package/src/WebComponent/FeeCalculator/index.ts +0 -4
- package/src/WebComponent/FeeCalculator/model/building-fee-view.ts +0 -84
- package/src/WebComponent/FeeCalculator/model/building-fee.ts +0 -126
- package/src/WebComponent/FeeCalculator/model/desired-addon.ts +0 -6
- package/src/WebComponent/FeeCalculator/model/desired-rentable-item.ts +0 -4
- package/src/WebComponent/FeeCalculator/model/index.ts +0 -13
- package/src/WebComponent/FeeCalculator/model/item-combination.ts +0 -16
- package/src/WebComponent/FeeCalculator/model/item-quantity.ts +0 -4
- package/src/WebComponent/FeeCalculator/model/pricing-matrix.ts +0 -45
- package/src/WebComponent/FeeCalculator/model/pricing-rule.ts +0 -9
- package/src/WebComponent/FeeCalculator/model/rent-frequency.ts +0 -1
- package/src/WebComponent/FeeCalculator/model/rentable-item-summary.ts +0 -10
- package/src/WebComponent/FeeCalculator/model/rentable-item.ts +0 -10
- package/src/WebComponent/FeeCalculator/model/transaction-category.ts +0 -23
- package/src/WebComponent/FeeCalculator/model/unit-fee-bundle.ts +0 -54
- package/src/WebComponent/LeadSourceClient.ts +0 -332
- package/src/WebComponent/MEChat.css +0 -5
- package/src/WebComponent/OfficeHours.ts +0 -73
- package/src/WebComponent/Scheduler/date-picker.ts +0 -405
- package/src/WebComponent/Scheduler/time-picker.ts +0 -190
- package/src/WebComponent/Scheduler/tour-scheduler.ts +0 -1416
- package/src/WebComponent/Scheduler/tour-type-option.ts +0 -112
- package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +0 -418
- package/src/WebComponent/actions/InputStyles.ts +0 -57
- package/src/WebComponent/actions/action-confirm-button.ts +0 -125
- package/src/WebComponent/actions/call-us-window.ts +0 -467
- package/src/WebComponent/actions/collapse-expand-button.ts +0 -65
- package/src/WebComponent/actions/details-window.ts +0 -150
- package/src/WebComponent/actions/email-us-window.ts +0 -556
- package/src/WebComponent/actions/formatPhoneNumber.ts +0 -72
- package/src/WebComponent/actions/minimize-expand-button.ts +0 -93
- package/src/WebComponent/chat-additional-actions.ts +0 -135
- package/src/WebComponent/health-chat.ts +0 -270
- package/src/WebComponent/healthchat-styles.ts +0 -119
- package/src/WebComponent/icons/ApplyOutlineIcon.ts +0 -22
- package/src/WebComponent/icons/BookTourOutlineIcon.ts +0 -13
- package/src/WebComponent/icons/CalculatorOutlineIcon.ts +0 -22
- package/src/WebComponent/icons/ChatOutlineIcon.ts +0 -10
- package/src/WebComponent/icons/ChevronLeftIcon.ts +0 -7
- package/src/WebComponent/icons/ChevronRightIcon.ts +0 -7
- package/src/WebComponent/icons/ContactResidentIcon.ts +0 -9
- package/src/WebComponent/icons/DollarOutlineIcon.ts +0 -26
- package/src/WebComponent/icons/EmailOutlineIcon.ts +0 -7
- package/src/WebComponent/icons/HeyThereEmojiIcon.ts +0 -12
- package/src/WebComponent/icons/PhoneOutlineIcon.ts +0 -7
- package/src/WebComponent/icons/SendMessageIcon.ts +0 -17
- package/src/WebComponent/icons/TourSelfGuidedIcon.ts +0 -17
- package/src/WebComponent/icons/TourVirtuallyIcon.ts +0 -17
- package/src/WebComponent/icons/TourWithAgentIcon.ts +0 -17
- package/src/WebComponent/icons/XOutlineIcon.ts +0 -8
- package/src/WebComponent/index.ts +0 -2
- package/src/WebComponent/launcher/Launcher.ts +0 -1284
- package/src/WebComponent/launcher/launcherStyles.ts +0 -500
- package/src/WebComponent/launcher/mobile-launcher.ts +0 -162
- package/src/WebComponent/launcher/typeEmojiStyles.ts +0 -161
- package/src/WebComponent/launcher/typeMiniStyles.ts +0 -60
- package/src/WebComponent/launcher/typeMobileStyles.ts +0 -50
- package/src/WebComponent/leasing-chat-styles.ts +0 -114
- package/src/WebComponent/loaders/index.ts +0 -7
- package/src/WebComponent/loaders/mega-loader.ts +0 -36
- package/src/WebComponent/loaders/skeleton-card.ts +0 -31
- package/src/WebComponent/loaders/skeleton-loader-styles.ts +0 -112
- package/src/WebComponent/loaders/skeleton-loader.ts +0 -34
- package/src/WebComponent/me-chat.ts +0 -1261
- package/src/WebComponent/me-select.ts +0 -322
- package/src/WebComponent/mini-loader.ts +0 -28
- package/src/WebComponent/pubnub-chat-styles.ts +0 -204
- package/src/WebComponent/pubnub-chat.ts +0 -928
- package/src/WebComponent/pubnub-media.ts +0 -208
- package/src/WebComponent/pubnub-message-styles.ts +0 -54
- package/src/WebComponent/pubnub-message.ts +0 -431
- package/src/WebComponent/simple-launcher/simple-launcher-styles.ts +0 -34
- package/src/WebComponent/simple-launcher/simple-launcher.ts +0 -100
- package/src/WebComponent/utilities-chat.ts +0 -270
- package/src/WebComponent/utilities-styles.ts +0 -110
- package/src/WebComponent/utils.ts +0 -82
- package/src/analytics.ts +0 -217
- package/src/assetUrls.ts +0 -6
- package/src/disclaimers.ts +0 -86
- package/src/fetchBuildingABTestType.ts +0 -21
- package/src/fetchBuildingInfo.ts +0 -87
- package/src/fetchBuildingWebchatView.ts +0 -176
- package/src/fetchFeatureFlag.ts +0 -250
- package/src/fetchLeadSources.ts +0 -98
- package/src/fetchPhoneNumberFromSource.ts +0 -31
- package/src/fetchWebchatPreferences.ts +0 -54
- package/src/getAvailabilities.ts +0 -179
- package/src/getBuildingPhoneNumber.ts +0 -26
- package/src/getShouldAllowScheduling.ts +0 -16
- package/src/getShouldShowWebchat.ts +0 -114
- package/src/getTimezoneString.ts +0 -39
- package/src/globals.ts +0 -3
- package/src/gtm.ts +0 -17
- package/src/handleChatId.ts +0 -101
- package/src/insertDNIIntoWebsite.ts +0 -146
- package/src/insertLeadSourceIntoSchedulerLinks.ts +0 -71
- package/src/main/MEChat.test.ts +0 -110
- package/src/main/MEChat.ts +0 -404
- package/src/main/utils.ts +0 -70
- package/src/postLeadSources.ts +0 -44
- package/src/rentgrata.ts +0 -74
- package/src/replaceSelectButtonsWithNewLink.ts +0 -90
- package/src/services/fees/calculateQuote.ts +0 -74
- package/src/services/fees/fetchBuildingFees.ts +0 -50
- package/src/services/fees/fetchBuildingFeesV2.ts +0 -56
- package/src/services/fees/fetchBuildingFloorplans.ts +0 -74
- package/src/services/fees/fetchBuildingUnits.ts +0 -86
- package/src/services/fees/utils.ts +0 -4
- package/src/svgIcons.ts +0 -14
- package/src/themes.ts +0 -65
- package/src/types/incentive-v2.ts +0 -24
- package/src/types/rest-sdk.types.ts +0 -13
- package/src/types/webchat-no-show-reason.ts +0 -6
- package/src/utils/queryParamBuilder.ts +0 -28
- package/src/utils.ts +0 -121
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
|
|
3
|
-
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
4
|
-
import { camelize, snakify } from "../../utils";
|
|
5
|
-
import {
|
|
6
|
-
DesiredAddon,
|
|
7
|
-
DesiredRentableItem,
|
|
8
|
-
UnitFeeBundle,
|
|
9
|
-
} from "../../WebComponent/FeeCalculator/model";
|
|
10
|
-
import { FeeEstimate } from "../../WebComponent/FeeCalculator/model/unit-fee-bundle";
|
|
11
|
-
import { BASE_DOMAIN } from "../../globals";
|
|
12
|
-
|
|
13
|
-
type CalculateQuoteRequest = {
|
|
14
|
-
buildingSlug: string;
|
|
15
|
-
unitId: number;
|
|
16
|
-
addons: DesiredAddon[];
|
|
17
|
-
rentableItems: DesiredRentableItem[];
|
|
18
|
-
leaseTerm: number;
|
|
19
|
-
moveInDate: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type CalculateQuoteResponse = {
|
|
23
|
-
units: UnitFeeBundle[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const BASE_URL = BASE_DOMAIN;
|
|
27
|
-
|
|
28
|
-
export const calculateQuote = async ({
|
|
29
|
-
buildingSlug,
|
|
30
|
-
unitId,
|
|
31
|
-
addons,
|
|
32
|
-
rentableItems,
|
|
33
|
-
leaseTerm,
|
|
34
|
-
moveInDate,
|
|
35
|
-
}: CalculateQuoteRequest): Promise<CalculateQuoteResponse> => {
|
|
36
|
-
try {
|
|
37
|
-
const feesResponse = await axios.post(
|
|
38
|
-
`${BASE_URL}/platformApi/webchat/${buildingSlug}/fees/calculate`,
|
|
39
|
-
snakify({
|
|
40
|
-
unitId,
|
|
41
|
-
addons,
|
|
42
|
-
rentableItems,
|
|
43
|
-
leaseTerm,
|
|
44
|
-
moveInDate,
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
if (feesResponse.data) {
|
|
49
|
-
const data = camelize<CalculateQuoteResponse>(feesResponse.data);
|
|
50
|
-
return {
|
|
51
|
-
...data,
|
|
52
|
-
units: data.units.map((unit) => ({
|
|
53
|
-
...unit,
|
|
54
|
-
fees: unit.fees.map(toFeeEstimateClass),
|
|
55
|
-
})),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
sendLoggingEvent({
|
|
60
|
-
logType: LogType.error,
|
|
61
|
-
buildingSlug,
|
|
62
|
-
logTitle: "[ERROR_CALCULATING_QUOTE]",
|
|
63
|
-
logData: { error },
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
units: [],
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const toFeeEstimateClass = (fee: FeeEstimate) => new FeeEstimate(fee);
|
|
73
|
-
|
|
74
|
-
export default calculateQuote;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
3
|
-
import { BuildingFee } from "../../WebComponent/FeeCalculator/model/building-fee";
|
|
4
|
-
import { camelize } from "../../utils";
|
|
5
|
-
import { IncentiveV2 } from "../../types/incentive-v2";
|
|
6
|
-
import { RentableItemSummary } from "../../WebComponent/FeeCalculator/model/rentable-item-summary";
|
|
7
|
-
import { BASE_DOMAIN } from "../../globals";
|
|
8
|
-
|
|
9
|
-
const BASE_URL = BASE_DOMAIN;
|
|
10
|
-
|
|
11
|
-
type BuildingFeeResponse = {
|
|
12
|
-
fees: BuildingFee[];
|
|
13
|
-
rentableItems: RentableItemSummary[];
|
|
14
|
-
buildingIncentives: IncentiveV2[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const fetchBuildingFees = async (
|
|
18
|
-
buildingSlug: string
|
|
19
|
-
): Promise<BuildingFeeResponse> => {
|
|
20
|
-
try {
|
|
21
|
-
const feesResponse = await axios.get(
|
|
22
|
-
`${BASE_URL}/platformApi/webchat/${buildingSlug}/fees`
|
|
23
|
-
);
|
|
24
|
-
if (feesResponse.data) {
|
|
25
|
-
const data = camelize<BuildingFeeResponse>(feesResponse.data);
|
|
26
|
-
return {
|
|
27
|
-
fees: data.fees.map(toBuildingFeeClass),
|
|
28
|
-
rentableItems: data.rentableItems,
|
|
29
|
-
buildingIncentives: data.buildingIncentives,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
sendLoggingEvent({
|
|
34
|
-
logType: LogType.error,
|
|
35
|
-
buildingSlug,
|
|
36
|
-
logTitle: "[ERROR_GETTING_FEES]",
|
|
37
|
-
logData: { error },
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
fees: [],
|
|
43
|
-
rentableItems: [],
|
|
44
|
-
buildingIncentives: [],
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const toBuildingFeeClass = (fee: BuildingFee) => new BuildingFee(fee);
|
|
49
|
-
|
|
50
|
-
export default fetchBuildingFees;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
3
|
-
import { BASE_DOMAIN } from "../../globals";
|
|
4
|
-
import { camelize } from "../../utils";
|
|
5
|
-
import { IncentiveV2 } from "../../types/incentive-v2";
|
|
6
|
-
import { RentableItemSummary } from "../../WebComponent/FeeCalculator/model/rentable-item-summary";
|
|
7
|
-
import { BuildingFeeView } from "../../WebComponent/FeeCalculator/model/building-fee-view";
|
|
8
|
-
import QueryParamBuilder from "../../utils/queryParamBuilder";
|
|
9
|
-
|
|
10
|
-
const BASE_URL = BASE_DOMAIN;
|
|
11
|
-
|
|
12
|
-
type BuildingFeeResponse = {
|
|
13
|
-
fees: BuildingFeeView[];
|
|
14
|
-
rentableItems: RentableItemSummary[];
|
|
15
|
-
buildingIncentives: IncentiveV2[];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const fetchBuildingFeesV2 = async (
|
|
19
|
-
buildingSlug: string,
|
|
20
|
-
layoutIds?: number[]
|
|
21
|
-
): Promise<BuildingFeeResponse> => {
|
|
22
|
-
try {
|
|
23
|
-
const params = new QueryParamBuilder().addArray(
|
|
24
|
-
"layout_ids",
|
|
25
|
-
layoutIds?.map((id) => id.toString())
|
|
26
|
-
);
|
|
27
|
-
const feesResponse = await axios.get(
|
|
28
|
-
`${BASE_URL}/platformApi/webchat/${buildingSlug}/fees?${params.build()}`
|
|
29
|
-
);
|
|
30
|
-
if (feesResponse.data) {
|
|
31
|
-
const data = camelize<BuildingFeeResponse>(feesResponse.data);
|
|
32
|
-
return {
|
|
33
|
-
fees: data.fees.map(toBuildingFeeClass),
|
|
34
|
-
rentableItems: data.rentableItems,
|
|
35
|
-
buildingIncentives: data.buildingIncentives,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
} catch (error) {
|
|
39
|
-
sendLoggingEvent({
|
|
40
|
-
logType: LogType.error,
|
|
41
|
-
buildingSlug,
|
|
42
|
-
logTitle: "[ERROR_GETTING_FEES]",
|
|
43
|
-
logData: { error },
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
fees: [],
|
|
49
|
-
rentableItems: [],
|
|
50
|
-
buildingIncentives: [],
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const toBuildingFeeClass = (fee: BuildingFeeView) => new BuildingFeeView(fee);
|
|
55
|
-
|
|
56
|
-
export default fetchBuildingFeesV2;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
3
|
-
import { BASE_DOMAIN } from "../../globals";
|
|
4
|
-
import { camelize } from "../../utils";
|
|
5
|
-
|
|
6
|
-
export type Floorplan = {
|
|
7
|
-
unitId: number;
|
|
8
|
-
name: string;
|
|
9
|
-
bedrooms: number;
|
|
10
|
-
bathrooms: number;
|
|
11
|
-
numAvailable: number;
|
|
12
|
-
startingPrice: number;
|
|
13
|
-
maxPrice: number;
|
|
14
|
-
earliestAvailable: string;
|
|
15
|
-
latestAvailable: string;
|
|
16
|
-
squareFeet: number;
|
|
17
|
-
url: string | null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type FetchFloorplansParams = {
|
|
21
|
-
buildingSlug: string;
|
|
22
|
-
numBedrooms?: number;
|
|
23
|
-
moveInDateEarliest?: Date;
|
|
24
|
-
moveInDateLatest?: Date;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const fetchBuildingFloorplans = async ({
|
|
28
|
-
buildingSlug,
|
|
29
|
-
numBedrooms,
|
|
30
|
-
moveInDateEarliest,
|
|
31
|
-
moveInDateLatest,
|
|
32
|
-
}: FetchFloorplansParams): Promise<Floorplan[]> => {
|
|
33
|
-
try {
|
|
34
|
-
const params = new URLSearchParams();
|
|
35
|
-
if (numBedrooms) {
|
|
36
|
-
params.append("num_bedrooms", numBedrooms.toString());
|
|
37
|
-
}
|
|
38
|
-
if (moveInDateEarliest) {
|
|
39
|
-
params.append(
|
|
40
|
-
"move_in_date_earliest",
|
|
41
|
-
moveInDateEarliest.toISOString().split("T")[0]
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
if (moveInDateLatest) {
|
|
45
|
-
params.append(
|
|
46
|
-
"move_in_date_latest",
|
|
47
|
-
moveInDateLatest.toISOString().split("T")[0]
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const queryString = params.toString() ? `?${params.toString()}` : "";
|
|
52
|
-
const floorplansResponse = await axios.get(
|
|
53
|
-
`${BASE_DOMAIN}/platformApi/webchat/${buildingSlug}/floorplans${queryString}`
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
if (floorplansResponse.data) {
|
|
57
|
-
return camelize<Floorplan[]>(floorplansResponse.data);
|
|
58
|
-
}
|
|
59
|
-
} catch (error) {
|
|
60
|
-
sendLoggingEvent({
|
|
61
|
-
logType: LogType.error,
|
|
62
|
-
buildingSlug,
|
|
63
|
-
logTitle: "[ERROR_GETTING_FLOORPLANS]",
|
|
64
|
-
logData: {
|
|
65
|
-
error,
|
|
66
|
-
params: { numBedrooms, moveInDateEarliest, moveInDateLatest },
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return [];
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export default fetchBuildingFloorplans;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
3
|
-
import { BASE_DOMAIN } from "../../globals";
|
|
4
|
-
import { camelize } from "../../utils";
|
|
5
|
-
import QueryParamBuilder from "../../utils/queryParamBuilder";
|
|
6
|
-
|
|
7
|
-
const BASE_URL = BASE_DOMAIN;
|
|
8
|
-
|
|
9
|
-
export type Unit = {
|
|
10
|
-
/**
|
|
11
|
-
* ID comes back in the format "u1234567890" - we strip the "u"
|
|
12
|
-
*/
|
|
13
|
-
id: number;
|
|
14
|
-
unitNumber: string;
|
|
15
|
-
layout: number;
|
|
16
|
-
externalFloorPlanDescriptionId: string;
|
|
17
|
-
numberOfBedrooms: number;
|
|
18
|
-
numberOfBathrooms: number;
|
|
19
|
-
squareFootage: number;
|
|
20
|
-
floor: number;
|
|
21
|
-
floorplanName: string;
|
|
22
|
-
floorplanUrl: string;
|
|
23
|
-
availabilityStage: string;
|
|
24
|
-
earliestAvailable: string;
|
|
25
|
-
latestAvailable: string;
|
|
26
|
-
startingPrice: number;
|
|
27
|
-
maxPrice: number;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type FetchPropertyUnitsParams = {
|
|
31
|
-
buildingSlug: string;
|
|
32
|
-
numBedrooms?: number;
|
|
33
|
-
moveInDateEarliest?: Date;
|
|
34
|
-
moveInDateLatest?: Date;
|
|
35
|
-
leaseTermMin?: number;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const fetchBuildingUnits = async ({
|
|
39
|
-
buildingSlug,
|
|
40
|
-
numBedrooms,
|
|
41
|
-
moveInDateEarliest,
|
|
42
|
-
moveInDateLatest,
|
|
43
|
-
leaseTermMin,
|
|
44
|
-
}: FetchPropertyUnitsParams): Promise<Unit[]> => {
|
|
45
|
-
try {
|
|
46
|
-
const queryParamBuilder = new QueryParamBuilder();
|
|
47
|
-
queryParamBuilder
|
|
48
|
-
.addSingle("num_bedrooms", numBedrooms?.toString())
|
|
49
|
-
.addSingle(
|
|
50
|
-
"move_in_date_earliest",
|
|
51
|
-
moveInDateEarliest?.toISOString().split("T")[0]
|
|
52
|
-
)
|
|
53
|
-
.addSingle(
|
|
54
|
-
"move_in_date_latest",
|
|
55
|
-
moveInDateLatest?.toISOString().split("T")[0]
|
|
56
|
-
)
|
|
57
|
-
.addSingle("lease_term_min", leaseTermMin?.toString());
|
|
58
|
-
|
|
59
|
-
const queryString = queryParamBuilder.build();
|
|
60
|
-
const propertyUnitsResponse = await axios.get(
|
|
61
|
-
`${BASE_URL}/platformApi/webchat/${buildingSlug}/units${queryString}`
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (propertyUnitsResponse.data) {
|
|
65
|
-
const camelizedUnits = camelize<Unit[]>(propertyUnitsResponse.data);
|
|
66
|
-
return camelizedUnits.map((unit) => ({
|
|
67
|
-
...unit,
|
|
68
|
-
id: parseInt(unit.id.toString().substring(1)),
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
sendLoggingEvent({
|
|
73
|
-
logType: LogType.error,
|
|
74
|
-
buildingSlug,
|
|
75
|
-
logTitle: "[ERROR_GETTING_UNITS]",
|
|
76
|
-
logData: {
|
|
77
|
-
error,
|
|
78
|
-
params: { numBedrooms, moveInDateEarliest, moveInDateLatest },
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return [];
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default fetchBuildingUnits;
|
package/src/svgIcons.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { svg } from "lit";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TODO(erol): PLEASE MOVE INTO EACH OWN ICON FILE UNDER /ICONS
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const CheckboxEmpty = svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
8
|
-
<rect x="1" y="1" width="22" height="22" stroke="black" stroke-width="2" rx="2"/>
|
|
9
|
-
</svg>
|
|
10
|
-
`;
|
|
11
|
-
export const CheckboxChecked = svg`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="17" viewBox="0 0 16 17" fill="none">
|
|
12
|
-
<rect y="0.09375" width="16" height="16" rx="2" fill="#4719CD"/>
|
|
13
|
-
<path d="M12 5.09375L6.5 10.5938L4 8.09375" stroke="white" stroke-linecap="round" stroke-linejoin="round"/>
|
|
14
|
-
</svg>`;
|
package/src/themes.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export const defaultPrimaryColor = "#646987"; // we have a brand color defined in the BE too, but this is a fallback
|
|
2
|
-
export const defaultBackgroundColor = "#ffffff"; // default background color for the chat widget
|
|
3
|
-
|
|
4
|
-
export const tintColor = (
|
|
5
|
-
originalColor: string,
|
|
6
|
-
tintOpacity: number
|
|
7
|
-
): string => {
|
|
8
|
-
const originalRgb = hexToRgb(originalColor);
|
|
9
|
-
const tintRgb = { r: 0, g: 0, b: 0 };
|
|
10
|
-
|
|
11
|
-
const newRgb = {
|
|
12
|
-
r: originalRgb.r + Math.round((tintRgb.r - originalRgb.r) * tintOpacity),
|
|
13
|
-
g: originalRgb.g + Math.round((tintRgb.g - originalRgb.g) * tintOpacity),
|
|
14
|
-
b: originalRgb.b + Math.round((tintRgb.b - originalRgb.b) * tintOpacity),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return rgbToHex(newRgb.r, newRgb.g, newRgb.b);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const hexToRgb = (hex: string): { r: number; g: number; b: number } => {
|
|
21
|
-
const r = parseInt(hex.substring(1, 3), 16);
|
|
22
|
-
const g = parseInt(hex.substring(3, 5), 16);
|
|
23
|
-
const b = parseInt(hex.substring(5, 7), 16);
|
|
24
|
-
return { r, g, b };
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const rgbToHex = (r: number, g: number, b: number): string => {
|
|
28
|
-
return (
|
|
29
|
-
"#" +
|
|
30
|
-
[r, g, b]
|
|
31
|
-
.map((c) => {
|
|
32
|
-
const hex = c.toString(16);
|
|
33
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
34
|
-
})
|
|
35
|
-
.join("")
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const hexToAlmostWhite = (hexColor: string, ratio: number): string => {
|
|
40
|
-
let r = parseInt(hexColor.substr(1, 2), 16);
|
|
41
|
-
let g = parseInt(hexColor.substr(3, 2), 16);
|
|
42
|
-
let b = parseInt(hexColor.substr(5, 2), 16);
|
|
43
|
-
|
|
44
|
-
// the ratio of white to add (1 = white, 0 = no change)
|
|
45
|
-
r = Math.round(r * (1 - ratio) + 255 * ratio);
|
|
46
|
-
g = Math.round(g * (1 - ratio) + 255 * ratio);
|
|
47
|
-
b = Math.round(b * (1 - ratio) + 255 * ratio);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
"#" +
|
|
51
|
-
r.toString(16).padStart(2, "0") +
|
|
52
|
-
g.toString(16).padStart(2, "0") +
|
|
53
|
-
b.toString(16).padStart(2, "0")
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const shouldUsePrimaryColorForChatFooter = (
|
|
58
|
-
orgId: number,
|
|
59
|
-
buildingId: number
|
|
60
|
-
): boolean => {
|
|
61
|
-
// Some clients are complaining that we are NOT ADA compliant with our black, default chat footer
|
|
62
|
-
// So we are temporarily adding this flag to allow them to use their brand color for the chat footer
|
|
63
|
-
// Don't want to suddenly change it for our clients so added this flag
|
|
64
|
-
return orgId === 2 || buildingId === 70392;
|
|
65
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type UnitData = {
|
|
2
|
-
unitIds: number[];
|
|
3
|
-
unitNumbers: string[];
|
|
4
|
-
layouts: number[];
|
|
5
|
-
floorplanNames: string[];
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type IncentiveV2 = {
|
|
9
|
-
id: number;
|
|
10
|
-
originalIncentiveString: string;
|
|
11
|
-
startDate: Date;
|
|
12
|
-
endDate: Date;
|
|
13
|
-
incentiveStatus: string;
|
|
14
|
-
source: string;
|
|
15
|
-
timeCreated: Date;
|
|
16
|
-
nofee: boolean;
|
|
17
|
-
numberOfFreeMonths: number;
|
|
18
|
-
leaseLength: number;
|
|
19
|
-
typeOfCustomerItAppliesTo: number;
|
|
20
|
-
typeOfIncentive: number;
|
|
21
|
-
numberOfMonthsOwnerPays: number;
|
|
22
|
-
unitData: UnitData;
|
|
23
|
-
qualifier: string;
|
|
24
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redeclare enum from rest-sdk to avoid pulling in entire module.
|
|
3
|
-
*/
|
|
4
|
-
export enum TourAvailabilityResponseRankOrderedSupportedTourTypesEnum {
|
|
5
|
-
Unknown = "UNKNOWN",
|
|
6
|
-
SelfGuided = "SELF_GUIDED",
|
|
7
|
-
VirtualShowing = "VIRTUAL_SHOWING",
|
|
8
|
-
WithAgent = "WITH_AGENT",
|
|
9
|
-
MediaTour = "MEDIA_TOUR",
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Types are safe to re-export as they are not included in runtime code.
|
|
13
|
-
export type { TourAvailabilityResponse } from "@meetelise/rest-sdk";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
class QueryParamBuilder {
|
|
2
|
-
private params: URLSearchParams;
|
|
3
|
-
|
|
4
|
-
constructor() {
|
|
5
|
-
this.params = new URLSearchParams();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
addSingle(key: string, value?: string): QueryParamBuilder {
|
|
9
|
-
if (!value) return this;
|
|
10
|
-
this.params.append(key, value);
|
|
11
|
-
return this;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
addArray(key: string, values?: string[]): QueryParamBuilder {
|
|
15
|
-
if (!values) return this;
|
|
16
|
-
values.forEach((value) => {
|
|
17
|
-
if (!value) return;
|
|
18
|
-
this.params.append(`${key}[]`, value);
|
|
19
|
-
});
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
build(): string {
|
|
24
|
-
return this.params.toString() ? `?${this.params.toString()}` : "";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default QueryParamBuilder;
|
package/src/utils.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import camelCase from "lodash/camelCase";
|
|
2
|
-
import snakeCase from "lodash/snakeCase";
|
|
3
|
-
import isArray from "lodash/isArray";
|
|
4
|
-
import isObject from "lodash/isObject";
|
|
5
|
-
import transform from "lodash/transform";
|
|
6
|
-
import addHours from "date-fns/addHours";
|
|
7
|
-
import isBefore from "date-fns/isBefore";
|
|
8
|
-
import { BASE_DOMAIN } from "./globals";
|
|
9
|
-
|
|
10
|
-
export const camelize = <T>(
|
|
11
|
-
snakeCasedObject: Record<string, unknown>,
|
|
12
|
-
keysToExclude?: (string | number | symbol)[]
|
|
13
|
-
): T =>
|
|
14
|
-
transform(
|
|
15
|
-
snakeCasedObject,
|
|
16
|
-
(acc: Record<string, unknown>, value, key, target) => {
|
|
17
|
-
const camelKey = keysToExclude?.includes(key)
|
|
18
|
-
? key
|
|
19
|
-
: isArray(target)
|
|
20
|
-
? key
|
|
21
|
-
: camelCase(String(key));
|
|
22
|
-
|
|
23
|
-
acc[camelKey] = isObject(value)
|
|
24
|
-
? camelize(value as Record<string, unknown>, keysToExclude)
|
|
25
|
-
: value;
|
|
26
|
-
}
|
|
27
|
-
) as T;
|
|
28
|
-
|
|
29
|
-
export const snakify = <T>(
|
|
30
|
-
snakeCasedObject: Record<string, unknown>,
|
|
31
|
-
keysToExclude?: (string | number | symbol)[]
|
|
32
|
-
): T =>
|
|
33
|
-
transform(
|
|
34
|
-
snakeCasedObject,
|
|
35
|
-
(acc: Record<string, unknown>, value, key, target) => {
|
|
36
|
-
const snakeKey = keysToExclude?.includes(key)
|
|
37
|
-
? key
|
|
38
|
-
: isArray(target)
|
|
39
|
-
? key
|
|
40
|
-
: snakeCase(String(key));
|
|
41
|
-
|
|
42
|
-
acc[snakeKey] = isObject(value)
|
|
43
|
-
? snakify(value as Record<string, unknown>, keysToExclude)
|
|
44
|
-
: value;
|
|
45
|
-
}
|
|
46
|
-
) as T;
|
|
47
|
-
|
|
48
|
-
export const isMobile = (): boolean =>
|
|
49
|
-
window.matchMedia("(max-width: 767px)").matches ||
|
|
50
|
-
window.matchMedia("(max-height: 400px)").matches;
|
|
51
|
-
|
|
52
|
-
export const isTimestampExpired = (
|
|
53
|
-
timestamp: Date,
|
|
54
|
-
ttlHours: number
|
|
55
|
-
): boolean => {
|
|
56
|
-
const expirationDate = addHours(timestamp, ttlHours);
|
|
57
|
-
return isBefore(expirationDate, Date.now());
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const getCookieValue = (name: string): string | null => {
|
|
61
|
-
try {
|
|
62
|
-
const cookies = document.cookie.split("; ");
|
|
63
|
-
const cookiePair = cookies
|
|
64
|
-
.map((cookie) => cookie.split("="))
|
|
65
|
-
.find(([cookieName]) => cookieName === name);
|
|
66
|
-
|
|
67
|
-
return cookiePair ? decodeURIComponent(cookiePair[1]) : null;
|
|
68
|
-
} catch (e) {
|
|
69
|
-
// For debugging purposes if something happens on a client website
|
|
70
|
-
// eslint-disable-next-line no-console
|
|
71
|
-
console.warn(`Error getting cookie value for name=${name}`, e);
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const isValidPhoneNumber = (phoneNumber: string): boolean => {
|
|
77
|
-
const phoneNumberRegex = /^\([2-9][0-8][0-9]\) [2-9][0-9][0-9]-[0-9]{4}$/;
|
|
78
|
-
return phoneNumberRegex.test(phoneNumber);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const isContainingEmail = (message: string): boolean => {
|
|
82
|
-
try {
|
|
83
|
-
const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/;
|
|
84
|
-
return emailRegex.test(message);
|
|
85
|
-
} catch (e) {
|
|
86
|
-
// eslint-disable-next-line no-console
|
|
87
|
-
console.warn(`Error checking if message contains email`, e);
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* FooBarBizzBazz -> Foo Bar Bizz Bazz
|
|
94
|
-
*/
|
|
95
|
-
export const sentenceTitleCase = (str: string): string => {
|
|
96
|
-
const spaced = str.replace(/([A-Z])/g, " $1").trim();
|
|
97
|
-
return spaced
|
|
98
|
-
.split(" ")
|
|
99
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
100
|
-
.join(" ");
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const formatCurrency = (
|
|
104
|
-
amount: number,
|
|
105
|
-
maximumFractionDigits = 0
|
|
106
|
-
): string => {
|
|
107
|
-
return Intl.NumberFormat("en-US", {
|
|
108
|
-
style: "currency",
|
|
109
|
-
currency: "USD",
|
|
110
|
-
minimumFractionDigits: 0,
|
|
111
|
-
maximumFractionDigits,
|
|
112
|
-
}).format(amount ?? 0);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const isTestEnv = (): boolean => {
|
|
116
|
-
const href = location.href;
|
|
117
|
-
if (href.startsWith(BASE_DOMAIN + "/settings/widgets")) return true;
|
|
118
|
-
if (href.startsWith(BASE_DOMAIN + "/demo")) return true;
|
|
119
|
-
if (href.startsWith("http://localhost")) return true;
|
|
120
|
-
return false;
|
|
121
|
-
};
|