@meetelise/chat 1.36.0 → 1.37.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/dist/src/WebComponent/FeeCalculator/fee-calculator.d.ts +1 -0
- package/dist/src/services/fees/downloadQuotePdf.d.ts +12 -0
- package/package.json +1 -1
- package/public/dist/index.js +8 -2
- package/src/WebComponent/FeeCalculator/fee-calculator.ts +27 -1
- package/src/services/fees/downloadQuotePdf.ts +71 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DesiredAddon, DesiredRentableItem } from "../../WebComponent/FeeCalculator/model";
|
|
2
|
+
declare type DownloadQuotePdfRequest = {
|
|
3
|
+
buildingSlug: string;
|
|
4
|
+
unitId: number;
|
|
5
|
+
unitNumber: string;
|
|
6
|
+
addons: DesiredAddon[];
|
|
7
|
+
rentableItems: DesiredRentableItem[];
|
|
8
|
+
leaseTerm: number;
|
|
9
|
+
moveInDate: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const downloadQuotePdf: ({ buildingSlug, unitId, unitNumber, addons, rentableItems, leaseTerm, moveInDate, }: DownloadQuotePdfRequest) => Promise<void>;
|
|
12
|
+
export default downloadQuotePdf;
|
package/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -4523,7 +4523,7 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
4523
4523
|
</p>
|
|
4524
4524
|
</div>
|
|
4525
4525
|
</div>
|
|
4526
|
-
`:B``}};Kr.styles=Vr,Yr([le({type:Object})],Kr.prototype,"incentive",void 0),Kr=Yr([ae("incentive-banner")],Kr);var Xr=function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Zr=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.primaryColor=Ie,this.backgroundColor=De,this.onCloseClicked=null,this.onClickEmailOption=null,this.onClickPhoneOption=null,this.onClickSSTOption=null,this.onClickTextUsOption=null,this.isLoading=!1,this.selectedLayoutIds=[-1],this.selectedUnit=null,this.desiredAddons=[],this.desiredRentableItems=[],this.leaseTerm=12,this.moveInDate=pi,this.buildingWebchatView=null,this.incentives=[],this.quote=null,this.groupedFees={[qo.OneTime]:[],[qo.Monthly]:[],[qo.Quarterly]:[],[qo.Annually]:[],[qo.PerOccurrence]:[]},this.rentableItems=[],this.debouncedCalculateQuote=tr()((async()=>{var e;if(!this.selectedUnit||!this.moveInDate)return;const i=this.moveInDate<new Date(this.selectedUnit.earliestAvailable)?this.selectedUnit.earliestAvailable:null===(e=this.moveInDate)||void 0===e?void 0:e.toISOString().split("T")[0];try{this.quote=await(async({buildingSlug:e,unitId:i,addons:n,rentableItems:o,leaseTerm:r,moveInDate:a})=>{try{const s=await t().post(`https://app.meetelise.com/platformApi/webchat/${e}/fees/calculate`,gi({unitId:i,addons:n,rentableItems:o,leaseTerm:r,moveInDate:a}));if(s.data){const e=fi(s.data);return{...e,units:e.units.map((e=>({...e,fees:e.fees.map(Jo)})))}}}catch(t){xn({logType:Cn.error,buildingSlug:e,logTitle:"[ERROR_CALCULATING_QUOTE]",logData:{error:t}})}return{units:[]}})({buildingSlug:this.buildingSlug,unitId:this.selectedUnit.id,addons:this.desiredAddons,rentableItems:this.desiredRentableItems,leaseTerm:this.leaseTerm,moveInDate:i})}finally{this.isLoading=!1}}),1e3),this.firstUpdated=async()=>{this.style.setProperty("--primary-color",this.primaryColor),this.style.setProperty("--background-color",this.backgroundColor),await this.setupCalculator()},this.setupCalculator=async()=>{if(!this.buildingSlug||!this.orgSlug)return;this.isLoading=!0;const[e,t]=await Promise.all([Dn(this.orgSlug,this.buildingSlug),Xo(this.buildingSlug)]);e&&t&&(this.buildingWebchatView=e,this.groupedFees=this.groupFees(t.fees),this.rentableItems=t.rentableItems,this.isLoading=!1)},this.calculateQuote=async()=>{this.selectedUnit&&this.moveInDate&&(this.isLoading=!0,this.debouncedCalculateQuote())},this.handleUnitSelect=e=>{this.selectedUnit=e,this.calculateQuote()},this.handleMoveInDateChange=e=>{this.moveInDate=e,this.calculateQuote()},this.handleLeaseTermChange=e=>{this.leaseTerm=e,this.calculateQuote()},this.handleAddonSelect=e=>{const t=this.desiredAddons.some((t=>t.id===e.id));t&&e.quantities.every((e=>0===e.quantity))?this.desiredAddons=this.desiredAddons.filter((t=>t.id!==e.id)):t?this.desiredAddons=this.desiredAddons.map((t=>t.id===e.id?{...t,quantities:e.quantities}:t)):this.desiredAddons.push(e),this.calculateQuote()},this.handleRentableItemSelect=e=>{this.desiredRentableItems.some((t=>t.id===e.id))?this.desiredRentableItems=this.desiredRentableItems.filter((t=>t.id!==e.id)):this.desiredRentableItems.push(e),this.calculateQuote()},this.groupFees=e=>e.reduce(((e,t)=>{const i=t.frequency||qo.OneTime;return e[i]=[...e[i]||[],t],e}),{}),this.handleClickEmailOption=e=>{this.handleClose(),this.onClickEmailOption&&this.onClickEmailOption(e)},this.handleClickPhoneOption=e=>{this.handleClose(),this.onClickPhoneOption&&this.onClickPhoneOption(e)},this.handleClickSSTOption=e=>{this.handleClose(),this.onClickSSTOption&&this.onClickSSTOption(e)},this.handleClickTextUsOption=e=>{this.handleClose(),this.onClickTextUsOption&&this.onClickTextUsOption(e)},this.handleClose=()=>{var e;null===(e=this.onCloseClicked)||void 0===e||e.call(this)},this.handleSelectLayout=e=>{this.selectedLayoutIds=e}}get layouts(){var e,t;return null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.layoutOptions)&&void 0!==t?t:[]}updated(e){(e.has("primaryColor")||e.has("backgroundColor"))&&(this.style.setProperty("--primary-color",this.primaryColor),this.style.setProperty("--background-color",this.backgroundColor))}disconnectedCallback(){super.disconnectedCallback(),this.debouncedCalculateQuote.cancel()}render(){return B`
|
|
4526
|
+
`:B``}};Kr.styles=Vr,Yr([le({type:Object})],Kr.prototype,"incentive",void 0),Kr=Yr([ae("incentive-banner")],Kr);var Xr=function(e,t,i,n){var o,r=arguments.length,a=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(t,i,a):o(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};let Zr=class extends oe{constructor(){super(...arguments),this.buildingSlug="",this.orgSlug="",this.primaryColor=Ie,this.backgroundColor=De,this.onCloseClicked=null,this.onClickEmailOption=null,this.onClickPhoneOption=null,this.onClickSSTOption=null,this.onClickTextUsOption=null,this.isLoading=!1,this.selectedLayoutIds=[-1],this.selectedUnit=null,this.desiredAddons=[],this.desiredRentableItems=[],this.leaseTerm=12,this.moveInDate=pi,this.buildingWebchatView=null,this.incentives=[],this.quote=null,this.groupedFees={[qo.OneTime]:[],[qo.Monthly]:[],[qo.Quarterly]:[],[qo.Annually]:[],[qo.PerOccurrence]:[]},this.rentableItems=[],this.debouncedCalculateQuote=tr()((async()=>{var e;if(!this.selectedUnit||!this.moveInDate)return;const i=this.moveInDate<new Date(this.selectedUnit.earliestAvailable)?this.selectedUnit.earliestAvailable:null===(e=this.moveInDate)||void 0===e?void 0:e.toISOString().split("T")[0];try{this.quote=await(async({buildingSlug:e,unitId:i,addons:n,rentableItems:o,leaseTerm:r,moveInDate:a})=>{try{const s=await t().post(`https://app.meetelise.com/platformApi/webchat/${e}/fees/calculate`,gi({unitId:i,addons:n,rentableItems:o,leaseTerm:r,moveInDate:a}));if(s.data){const e=fi(s.data);return{...e,units:e.units.map((e=>({...e,fees:e.fees.map(Jo)})))}}}catch(t){xn({logType:Cn.error,buildingSlug:e,logTitle:"[ERROR_CALCULATING_QUOTE]",logData:{error:t}})}return{units:[]}})({buildingSlug:this.buildingSlug,unitId:this.selectedUnit.id,addons:this.desiredAddons,rentableItems:this.desiredRentableItems,leaseTerm:this.leaseTerm,moveInDate:i})}finally{this.isLoading=!1}}),1e3),this.firstUpdated=async()=>{this.style.setProperty("--primary-color",this.primaryColor),this.style.setProperty("--background-color",this.backgroundColor),await this.setupCalculator()},this.setupCalculator=async()=>{if(!this.buildingSlug||!this.orgSlug)return;this.isLoading=!0;const[e,t]=await Promise.all([Dn(this.orgSlug,this.buildingSlug),Xo(this.buildingSlug)]);e&&t&&(this.buildingWebchatView=e,this.groupedFees=this.groupFees(t.fees),this.rentableItems=t.rentableItems,this.isLoading=!1)},this.calculateQuote=async()=>{this.selectedUnit&&this.moveInDate&&(this.isLoading=!0,this.debouncedCalculateQuote())},this.handleUnitSelect=e=>{this.selectedUnit=e,this.calculateQuote()},this.handleMoveInDateChange=e=>{this.moveInDate=e,this.calculateQuote()},this.handleLeaseTermChange=e=>{this.leaseTerm=e,this.calculateQuote()},this.handleAddonSelect=e=>{const t=this.desiredAddons.some((t=>t.id===e.id));t&&e.quantities.every((e=>0===e.quantity))?this.desiredAddons=this.desiredAddons.filter((t=>t.id!==e.id)):t?this.desiredAddons=this.desiredAddons.map((t=>t.id===e.id?{...t,quantities:e.quantities}:t)):this.desiredAddons.push(e),this.calculateQuote()},this.handleRentableItemSelect=e=>{this.desiredRentableItems.some((t=>t.id===e.id))?this.desiredRentableItems=this.desiredRentableItems.filter((t=>t.id!==e.id)):this.desiredRentableItems.push(e),this.calculateQuote()},this.groupFees=e=>e.reduce(((e,t)=>{const i=t.frequency||qo.OneTime;return e[i]=[...e[i]||[],t],e}),{}),this.handleClickEmailOption=e=>{this.handleClose(),this.onClickEmailOption&&this.onClickEmailOption(e)},this.handleClickPhoneOption=e=>{this.handleClose(),this.onClickPhoneOption&&this.onClickPhoneOption(e)},this.handleClickSSTOption=e=>{this.handleClose(),this.onClickSSTOption&&this.onClickSSTOption(e)},this.handleClickTextUsOption=e=>{this.handleClose(),this.onClickTextUsOption&&this.onClickTextUsOption(e)},this.handleClose=()=>{var e;null===(e=this.onCloseClicked)||void 0===e||e.call(this)},this.handleSelectLayout=e=>{this.selectedLayoutIds=e},this.handleShare=async()=>{var e;if(!this.selectedUnit||!this.moveInDate)return;const i=this.moveInDate<new Date(this.selectedUnit.earliestAvailable)?this.selectedUnit.earliestAvailable:null===(e=this.moveInDate)||void 0===e?void 0:e.toISOString().split("T")[0];await(async({buildingSlug:e,unitId:i,unitNumber:n,addons:o,rentableItems:r,leaseTerm:a,moveInDate:s})=>{try{const l=await t().post(`https://app.meetelise.com/platformApi/webchat/${e}/fees/calculate/download`,gi({unitId:i,addons:o,rentableItems:r,leaseTerm:a,moveInDate:s}),{responseType:"blob"}),u=new Blob([l.data],{type:"application/pdf"}),c=URL.createObjectURL(u),d=document.createElement("a");d.href=c,d.download=`estimate-${n}.pdf`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(c)}catch(t){xn({logType:Cn.error,buildingSlug:e,logTitle:"[ERROR_DOWNLOADING_QUOTE_PDF]",logData:{error:t}})}})({buildingSlug:this.buildingSlug,unitId:this.selectedUnit.id,unitNumber:this.selectedUnit.unitNumber,addons:this.desiredAddons,rentableItems:this.desiredRentableItems,leaseTerm:this.leaseTerm,moveInDate:i})}}get layouts(){var e,t;return null!==(t=null===(e=this.buildingWebchatView)||void 0===e?void 0:e.layoutOptions)&&void 0!==t?t:[]}updated(e){(e.has("primaryColor")||e.has("backgroundColor"))&&(this.style.setProperty("--primary-color",this.primaryColor),this.style.setProperty("--background-color",this.backgroundColor))}disconnectedCallback(){super.disconnectedCallback(),this.debouncedCalculateQuote.cancel()}render(){return B`
|
|
4527
4527
|
<div
|
|
4528
4528
|
class="fee-calculator-container"
|
|
4529
4529
|
@keydown=${e=>e.stopPropagation()}
|
|
@@ -4533,8 +4533,14 @@ xmlns="http://www.w3.org/2000/svg"
|
|
|
4533
4533
|
<h1>Estimated Cost Calculator</h1>
|
|
4534
4534
|
|
|
4535
4535
|
<div class="calculator-header-right">
|
|
4536
|
+
<button
|
|
4537
|
+
class="share-button"
|
|
4538
|
+
@click=${this.handleShare}
|
|
4539
|
+
?disabled=${!this.selectedUnit}
|
|
4540
|
+
>
|
|
4541
|
+
<span>Export</span>
|
|
4542
|
+
</button>
|
|
4536
4543
|
<!-- TODO(Leo): Return once reqs are clear; also need apps link -->
|
|
4537
|
-
<!-- <button class="share-button">Share</button> -->
|
|
4538
4544
|
<!-- <button class="apply-button">Apply</button> -->
|
|
4539
4545
|
<button
|
|
4540
4546
|
aria-label="Close fee calculator"
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
calculateQuote,
|
|
16
16
|
CalculateQuoteResponse,
|
|
17
17
|
} from "../../services/fees/calculateQuote";
|
|
18
|
+
import downloadQuotePdf from "../../services/fees/downloadQuotePdf";
|
|
18
19
|
import { defaultBackgroundColor, defaultPrimaryColor } from "../../themes";
|
|
19
20
|
import debounce from "lodash/debounce";
|
|
20
21
|
import { XOutlineIcon } from "../icons/XOutlineIcon";
|
|
@@ -273,6 +274,25 @@ export class FeeCalculator extends LitElement {
|
|
|
273
274
|
this.selectedLayoutIds = layoutIds;
|
|
274
275
|
};
|
|
275
276
|
|
|
277
|
+
handleShare = async (): Promise<void> => {
|
|
278
|
+
if (!this.selectedUnit || !this.moveInDate) return;
|
|
279
|
+
|
|
280
|
+
const moveInDate =
|
|
281
|
+
this.moveInDate < new Date(this.selectedUnit.earliestAvailable)
|
|
282
|
+
? this.selectedUnit.earliestAvailable
|
|
283
|
+
: this.moveInDate?.toISOString().split("T")[0];
|
|
284
|
+
|
|
285
|
+
await downloadQuotePdf({
|
|
286
|
+
buildingSlug: this.buildingSlug,
|
|
287
|
+
unitId: this.selectedUnit.id,
|
|
288
|
+
unitNumber: this.selectedUnit.unitNumber,
|
|
289
|
+
addons: this.desiredAddons,
|
|
290
|
+
rentableItems: this.desiredRentableItems,
|
|
291
|
+
leaseTerm: this.leaseTerm,
|
|
292
|
+
moveInDate,
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
|
|
276
296
|
render(): TemplateResult {
|
|
277
297
|
return html`
|
|
278
298
|
<div
|
|
@@ -284,8 +304,14 @@ export class FeeCalculator extends LitElement {
|
|
|
284
304
|
<h1>Estimated Cost Calculator</h1>
|
|
285
305
|
|
|
286
306
|
<div class="calculator-header-right">
|
|
307
|
+
<button
|
|
308
|
+
class="share-button"
|
|
309
|
+
@click=${this.handleShare}
|
|
310
|
+
?disabled=${!this.selectedUnit}
|
|
311
|
+
>
|
|
312
|
+
<span>Export</span>
|
|
313
|
+
</button>
|
|
287
314
|
<!-- TODO(Leo): Return once reqs are clear; also need apps link -->
|
|
288
|
-
<!-- <button class="share-button">Share</button> -->
|
|
289
315
|
<!-- <button class="apply-button">Apply</button> -->
|
|
290
316
|
<button
|
|
291
317
|
aria-label="Close fee calculator"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
import { LogType, sendLoggingEvent } from "../../analytics";
|
|
4
|
+
import { snakify } from "../../utils";
|
|
5
|
+
import {
|
|
6
|
+
DesiredAddon,
|
|
7
|
+
DesiredRentableItem,
|
|
8
|
+
} from "../../WebComponent/FeeCalculator/model";
|
|
9
|
+
import { BASE_DOMAIN } from "../../globals";
|
|
10
|
+
|
|
11
|
+
type DownloadQuotePdfRequest = {
|
|
12
|
+
buildingSlug: string;
|
|
13
|
+
unitId: number;
|
|
14
|
+
unitNumber: string;
|
|
15
|
+
addons: DesiredAddon[];
|
|
16
|
+
rentableItems: DesiredRentableItem[];
|
|
17
|
+
leaseTerm: number;
|
|
18
|
+
moveInDate: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const BASE_URL = BASE_DOMAIN;
|
|
22
|
+
|
|
23
|
+
export const downloadQuotePdf = async ({
|
|
24
|
+
buildingSlug,
|
|
25
|
+
unitId,
|
|
26
|
+
unitNumber,
|
|
27
|
+
addons,
|
|
28
|
+
rentableItems,
|
|
29
|
+
leaseTerm,
|
|
30
|
+
moveInDate,
|
|
31
|
+
}: DownloadQuotePdfRequest): Promise<void> => {
|
|
32
|
+
try {
|
|
33
|
+
const response = await axios.post(
|
|
34
|
+
`${BASE_URL}/platformApi/webchat/${buildingSlug}/fees/calculate/download`,
|
|
35
|
+
snakify({
|
|
36
|
+
unitId,
|
|
37
|
+
addons,
|
|
38
|
+
rentableItems,
|
|
39
|
+
leaseTerm,
|
|
40
|
+
moveInDate,
|
|
41
|
+
}),
|
|
42
|
+
{
|
|
43
|
+
responseType: "blob",
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const file = new Blob([response.data], { type: "application/pdf" });
|
|
48
|
+
|
|
49
|
+
// Create a link element to trigger the download
|
|
50
|
+
const fileURL = URL.createObjectURL(file);
|
|
51
|
+
const downloadLink = document.createElement("a");
|
|
52
|
+
downloadLink.href = fileURL;
|
|
53
|
+
downloadLink.download = `estimate-${unitNumber}.pdf`;
|
|
54
|
+
|
|
55
|
+
document.body.appendChild(downloadLink);
|
|
56
|
+
downloadLink.click();
|
|
57
|
+
document.body.removeChild(downloadLink);
|
|
58
|
+
|
|
59
|
+
// Clean up the object URL
|
|
60
|
+
URL.revokeObjectURL(fileURL);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
sendLoggingEvent({
|
|
63
|
+
logType: LogType.error,
|
|
64
|
+
buildingSlug,
|
|
65
|
+
logTitle: "[ERROR_DOWNLOADING_QUOTE_PDF]",
|
|
66
|
+
logData: { error },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default downloadQuotePdf;
|