@meetelise/chat 1.20.128 → 1.20.129

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.128",
3
+ "version": "1.20.129",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -923,7 +923,7 @@ otherwise there's some empty space at the bottom of the button, which interferes
923
923
  .loading-entire-tour-icon {
924
924
  padding: 24px;
925
925
  }
926
- `;class ii{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:ri(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.116"})})}}const ri=()=>{var e,t,n;const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null;return{entrataCampaignSource:i.get("switch_cls[id]"),realpageCampaignSource:i.get("ilm"),utmCampaignSource:i.get("utm_source"),yardiCampaignSource:r}};var oi;!function(e){e.error="error",e.info="info",e.warn="warn"}(oi||(oi={}));const ai=async({logType:e,buildingSlug:n,orgSlug:i,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=n?n:"","org-slug":null!=i?i:"","log-type":null!=e?e:oi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};var si=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let ui=class extends re{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.buildingName="",this.tourType=null,this.shouldShowTourType={[li.Guided]:!0,[li.Self]:!0,[li.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.brandColor=Fe,this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{const e=await(async()=>{var e,t,n,i,r,o;return{[li.Guided]:!!(null===(t=null===(e=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[li.Self]:!!(null===(i=null===(n=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[li.Virtual]:!!(null===(o=null===(r=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})(),t=Object.values(e).every((e=>!1===e));if(t)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:null,logType:oi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});this.shouldShowTourType={[li.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[li.Guided],[li.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[li.Self],[li.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[li.Virtual]},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)?this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e])):"1ac49f90-6150-11ed-b327-1b3f05e7b9db"===this.buildingSlug&&this.shouldShowTourType[li.Self]&&(this.tourType=li.Self),null!==this.tourType?(this.availabilitiesGroupedByDay=await On(di[this.tourType]),this.waitingForAvailabilities=!1):this.waitingForAvailabilities=!1},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await On(di[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];Zn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:ci[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unitNumbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:ci[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await zn({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>k`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>k`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>k`<action-confirm-button
926
+ `;class ii{constructor(e,t,n,i){this.org=e,this.building=t,this.chatId=n,this.incomingProcessedLeadSource=i,this.featureFlags={}}setFeatureFlags(e){this.featureFlags={...this.featureFlags,...e}}ping(e){var t;fetch("https://app.meetelise.com/platformApi/connectors/talk_js/analytics",{method:"POST",credentials:"omit",keepalive:!0,headers:{"content-type":"application/json; charset=UTF-8"},body:JSON.stringify({eventType:e,chatId:this.chatId,url:location.href,org:this.org,building:this.building,referrer:document.referrer,featureFlags:this.featureFlags,campaignSources:ri(),incomingProcessedLeadSource:this.incomingProcessedLeadSource,webchatVersion:null!==(t="MISSING_ENV_VAR".npm_package_version)&&void 0!==t?t:"1.20.116"})})}}const ri=()=>{var e,t,n;const i=new URL(window.location.href).searchParams,r=null!==(n=null===(t=null===(e=window.RCTPCampaign)||void 0===e?void 0:e.CampaignDetails)||void 0===t?void 0:t.Source)&&void 0!==n?n:null;return{entrataCampaignSource:i.get("switch_cls[id]"),realpageCampaignSource:i.get("ilm"),utmCampaignSource:i.get("utm_source"),yardiCampaignSource:r}};var oi;!function(e){e.error="error",e.info="info",e.warn="warn"}(oi||(oi={}));const ai=async({logType:e,buildingSlug:n,orgSlug:i,logTitle:r,logData:o})=>{await t().post("https://app.meetelise.com/platformApi/webchat/logging",{...o},{headers:{"Content-Type":"application/json","building-slug":null!=n?n:"","org-slug":null!=i?i:"","log-type":null!=e?e:oi.error,"log-title":r.toUpperCase().replace(/\s/g,"_")}})};var si=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let ui=class extends re{constructor(){super(...arguments),this.layoutOptions=[],this.unitOptions=[],this.tourTypeOptions=[],this.chatId="",this.buildingId=0,this.buildingSlug="",this.sgtUrl="",this.escortedToursLink="",this.virtualToursLink="",this.orgSlug="",this.buildingName="",this.tourType=null,this.shouldShowTourType={[li.Guided]:!0,[li.Self]:!0,[li.Virtual]:!0},this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.waitingForAvailabilities=!0,this.mobilePageIndex=0,this.isSubmitting=!1,this.tourIsBooked=!1,this.leadSources=[],this.currentLeadSource="",this.featureFlagShowDropdown="",this.compactDesign=!1,this.brandColor=Fe,this.errorGettingAvailabilities=!1,this.firstUpdated=async()=>{try{const e=await(async()=>{var e,t,n,i,r,o;return{[li.Guided]:!!(null===(t=null===(e=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent))||void 0===e?void 0:e.availableTourStartTimes)||void 0===t?void 0:t.length),[li.Self]:!!(null===(i=null===(n=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided))||void 0===n?void 0:n.availableTourStartTimes)||void 0===i?void 0:i.length),[li.Virtual]:!!(null===(o=null===(r=await xn(nn.TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing))||void 0===r?void 0:r.availableTourStartTimes)||void 0===o?void 0:o.length)}})();ai({logTitle:"AVAILABILITIES_EXIST_FOR_TOUR_TYPE",logData:e,logType:oi.info,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});const t=Object.values(e).every((e=>!1===e));if(t)return this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,void ai({logTitle:"NO_AVAILABILITIES_EXIST",logData:null,logType:oi.warn,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug});if(this.shouldShowTourType={[li.Guided]:this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")&&e[li.Guided],[li.Self]:this.tourTypeOptions.map((e=>e.value)).includes("SELF_GUIDED")&&e[li.Self],[li.Virtual]:this.tourTypeOptions.map((e=>e.value)).includes("VIRTUAL_SHOWING")&&e[li.Virtual]},1===Object.values(this.shouldShowTourType).reduce(((e,t)=>!0===t?e+1:e),0)?this.tourType=Object.keys(this.shouldShowTourType).find((e=>this.shouldShowTourType[e])):"1ac49f90-6150-11ed-b327-1b3f05e7b9db"===this.buildingSlug&&this.shouldShowTourType[li.Self]&&(this.tourType=li.Self),null===this.tourType)return void(this.waitingForAvailabilities=!1);this.availabilitiesGroupedByDay=await On(di[this.tourType]),this.waitingForAvailabilities=!1}catch(e){this.errorGettingAvailabilities=!0,this.waitingForAvailabilities=!1,ai({logTitle:"ERROR_LOADING_AVAILABILITIES",logData:{error:e},logType:oi.error,buildingSlug:this.buildingSlug,orgSlug:this.orgSlug})}},this.willUpdate=async e=>{e.has("tourType")&&this.tourType&&(this.availabilitiesGroupedByDay=await On(di[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Re(e)){if("Backspace"===e.key){if(Re(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Re(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>null!==this.tourType,dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t,n;return(!!(null===(e=this.firstNameInput)||void 0===e?void 0:e.value)||!!(null===(t=this.lastNameInput)||void 0===t?void 0:t.value))&&(null===(n=this.emailInput)||void 0===n?void 0:n.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e,n;if(!this.selectedDate||!this.selectedTime||null===this.tourType)return;const i=new URLSearchParams(window.location.search),r=this.selectedLeadSource&&this.selectedLeadSource.value?this.selectedLeadSource.value:this.currentLeadSource,o=[...new Set(r?[r,"property-website"]:["property-website"])];Zn("scheduleTourSubmitted",{email:this.email,phone:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,firstName:this.firstNameInput.value,lastName:this.lastNameInput.value,tourType:ci[this.tourType],tourTime:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unitNumbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,originatingSource:o.find((e=>"property-website"!==e))||null});const a={referrer:document.referrer,email_address:this.email,phone_number:`+1${null===(n=this.phoneNumber.match(/\d/g))||void 0===n?void 0:n.join("")}`,building_id:this.buildingId,first_name:this.firstNameInput.value,last_name:this.lastNameInput.value,tour_type:ci[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`,layouts:this.layoutTypeSelect.value?[this.layoutTypeSelect.value]:null,unit_numbers:this.unitTypeSelect&&this.unitTypeSelect.value?[this.unitTypeSelect.value]:null,lead_sources:[...new Set(r?[r,"property-website"]:["property-website"])],query_params:Object.fromEntries(i.entries())};this.isSubmitting=!0;try{await t().post("https://app.meetelise.com/platformApi/state/create/v2/scheduleMe",a,{headers:{"building-slug":this.buildingSlug,"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG","org-slug":this.orgSlug}}),await zn({chatId:this.chatId,website:window.location.origin,referrer:document.referrer,buildingSlug:this.buildingSlug,selectedLeadSource:null!=r?r:""}),this.isSubmitting=!1,this.tourIsBooked=!0}catch(e){const t=e.response.data.detail||"Failed to book tour";alert(t),this.isSubmitting=!1,this.tourIsBooked=!1}},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>k`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>k`${this.dateAndTimeMenu()}`},{validate:()=>this.validators.leadInfo(),nextButtonText:null,renderNextButton:()=>k`<action-confirm-button
927
927
  id="schedule-bttn"
928
928
  .onClick=${this.submit}
929
929
  .isLoading=${this.isSubmitting}
@@ -145,71 +145,91 @@ export class TourScheduler extends LitElement {
145
145
  errorGettingAvailabilities = false;
146
146
 
147
147
  firstUpdated = async (): Promise<void> => {
148
- const availabilitiesExistForTourType =
149
- await getExistenceOfAvailabilitiesByTourType();
150
-
151
- const allValuesAreFalse = Object.values(
152
- availabilitiesExistForTourType
153
- ).every((v) => v === false);
154
- if (allValuesAreFalse) {
155
- this.errorGettingAvailabilities = true;
156
- this.waitingForAvailabilities = false;
148
+ try {
149
+ const availabilitiesExistForTourType =
150
+ await getExistenceOfAvailabilitiesByTourType();
157
151
  sendLoggingEvent({
158
- logTitle: "ERROR_LOADING_AVAILABILITIES",
159
- logData: null,
160
- logType: LogType.warn,
152
+ logTitle: "AVAILABILITIES_EXIST_FOR_TOUR_TYPE",
153
+ logData: availabilitiesExistForTourType,
154
+ logType: LogType.info,
161
155
  buildingSlug: this.buildingSlug,
162
156
  orgSlug: this.orgSlug,
163
157
  });
164
- return;
165
- }
166
- this.shouldShowTourType = {
167
- [TourType.Guided]:
168
- this.tourTypeOptions.map((o) => o.value).includes("WITH_AGENT") &&
169
- availabilitiesExistForTourType[TourType.Guided],
170
- [TourType.Self]:
171
- this.tourTypeOptions.map((o) => o.value).includes("SELF_GUIDED") &&
172
- availabilitiesExistForTourType[TourType.Self],
173
- [TourType.Virtual]:
174
- this.tourTypeOptions.map((o) => o.value).includes("VIRTUAL_SHOWING") &&
175
- availabilitiesExistForTourType[TourType.Virtual],
176
- };
158
+ const allValuesAreFalse = Object.values(
159
+ availabilitiesExistForTourType
160
+ ).every((v) => v === false);
161
+ if (allValuesAreFalse) {
162
+ this.errorGettingAvailabilities = true;
163
+ this.waitingForAvailabilities = false;
164
+ sendLoggingEvent({
165
+ logTitle: "NO_AVAILABILITIES_EXIST",
166
+ logData: null,
167
+ logType: LogType.warn,
168
+ buildingSlug: this.buildingSlug,
169
+ orgSlug: this.orgSlug,
170
+ });
171
+ return;
172
+ }
173
+ this.shouldShowTourType = {
174
+ [TourType.Guided]:
175
+ this.tourTypeOptions.map((o) => o.value).includes("WITH_AGENT") &&
176
+ availabilitiesExistForTourType[TourType.Guided],
177
+ [TourType.Self]:
178
+ this.tourTypeOptions.map((o) => o.value).includes("SELF_GUIDED") &&
179
+ availabilitiesExistForTourType[TourType.Self],
180
+ [TourType.Virtual]:
181
+ this.tourTypeOptions
182
+ .map((o) => o.value)
183
+ .includes("VIRTUAL_SHOWING") &&
184
+ availabilitiesExistForTourType[TourType.Virtual],
185
+ };
177
186
 
178
- // if there is only a single option for tour type, have that be the default
179
- const hasOneShowTourType =
180
- Object.values(this.shouldShowTourType).reduce((acc, cur) => {
181
- if (cur === true) {
182
- return acc + 1;
183
- } else {
184
- return acc;
185
- }
186
- }, 0) === 1;
187
+ // if there is only a single option for tour type, have that be the default
188
+ const hasOneShowTourType =
189
+ Object.values(this.shouldShowTourType).reduce((acc, cur) => {
190
+ if (cur === true) {
191
+ return acc + 1;
192
+ } else {
193
+ return acc;
194
+ }
195
+ }, 0) === 1;
187
196
 
188
- if (hasOneShowTourType) {
189
- this.tourType = Object.keys(this.shouldShowTourType).find(
190
- (key) => this.shouldShowTourType[key as TourType]
191
- ) as TourType;
192
- } else {
193
- // if we have multiple tour types, then check if there is a default that the client wants selected
197
+ if (hasOneShowTourType) {
198
+ this.tourType = Object.keys(this.shouldShowTourType).find(
199
+ (key) => this.shouldShowTourType[key as TourType]
200
+ ) as TourType;
201
+ } else {
202
+ // if we have multiple tour types, then check if there is a default that the client wants selected
194
203
 
195
- // HACK: FOR THE DEMO, FOR https://www.sofioceanhills.com/ -
196
- // THIS SHOULD BE ADDED TO WEBCHAT CONFIGURATION
197
- if (
198
- this.buildingSlug === "1ac49f90-6150-11ed-b327-1b3f05e7b9db" &&
199
- this.shouldShowTourType[TourType.Self]
200
- ) {
201
- this.tourType = TourType.Self;
204
+ // HACK: FOR THE DEMO, FOR https://www.sofioceanhills.com/ -
205
+ // THIS SHOULD BE ADDED TO WEBCHAT CONFIGURATION
206
+ if (
207
+ this.buildingSlug === "1ac49f90-6150-11ed-b327-1b3f05e7b9db" &&
208
+ this.shouldShowTourType[TourType.Self]
209
+ ) {
210
+ this.tourType = TourType.Self;
211
+ }
202
212
  }
203
- }
204
213
 
205
- if (this.tourType === null) {
214
+ if (this.tourType === null) {
215
+ this.waitingForAvailabilities = false;
216
+ return;
217
+ }
218
+ this.availabilitiesGroupedByDay = await getAvailabilitiesGroupedByDay(
219
+ tourTypeMap[this.tourType]
220
+ );
206
221
  this.waitingForAvailabilities = false;
207
- return;
222
+ } catch (e) {
223
+ this.errorGettingAvailabilities = true;
224
+ this.waitingForAvailabilities = false;
225
+ sendLoggingEvent({
226
+ logTitle: "ERROR_LOADING_AVAILABILITIES",
227
+ logData: { error: e },
228
+ logType: LogType.error,
229
+ buildingSlug: this.buildingSlug,
230
+ orgSlug: this.orgSlug,
231
+ });
208
232
  }
209
- this.availabilitiesGroupedByDay = await getAvailabilitiesGroupedByDay(
210
- tourTypeMap[this.tourType]
211
- );
212
- this.waitingForAvailabilities = false;
213
233
  };
214
234
 
215
235
  protected willUpdate = async (