@meetelise/chat 1.40.1 → 1.40.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.
- package/dist/src/WebComponent/Scheduler/date-picker.d.ts +2 -0
- package/dist/src/WebComponent/Scheduler/time-picker.d.ts +3 -1
- package/dist/src/getAvailabilities.d.ts +10 -0
- package/package.json +1 -1
- package/public/dist/index.js +161 -159
- package/src/WebComponent/Scheduler/date-picker.ts +11 -1
- package/src/WebComponent/Scheduler/time-picker.ts +14 -2
- package/src/WebComponent/Scheduler/tour-scheduler.ts +66 -0
- package/src/getAvailabilities.ts +10 -1
|
@@ -32,12 +32,15 @@ export class DatePicker extends LitElement {
|
|
|
32
32
|
@property({ attribute: "year", type: Number })
|
|
33
33
|
defaultYear?: number;
|
|
34
34
|
|
|
35
|
+
@property({ attribute: true })
|
|
36
|
+
defaultDate?: Date;
|
|
37
|
+
|
|
35
38
|
@property({ attribute: false })
|
|
36
39
|
availabilities?: {
|
|
37
40
|
[day: string]: Date[];
|
|
38
41
|
};
|
|
39
42
|
|
|
40
|
-
private _selectedDate?: Date =
|
|
43
|
+
private _selectedDate?: Date = this.defaultDate;
|
|
41
44
|
set selectedDate(date: Date | undefined) {
|
|
42
45
|
const old = this._selectedDate;
|
|
43
46
|
this._selectedDate = date;
|
|
@@ -55,6 +58,13 @@ export class DatePicker extends LitElement {
|
|
|
55
58
|
return this._selectedDate;
|
|
56
59
|
}
|
|
57
60
|
|
|
61
|
+
protected firstUpdated(): void {
|
|
62
|
+
if (!this.defaultDate) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.selectedDate = this.defaultDate;
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
now = new Date();
|
|
59
69
|
|
|
60
70
|
private _monthShown =
|
|
@@ -31,14 +31,26 @@ export class TimePicker extends LitElement {
|
|
|
31
31
|
@property({ attribute: true })
|
|
32
32
|
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
33
33
|
|
|
34
|
+
@property({ attribute: true })
|
|
35
|
+
defaultSelectedTime?: TimePickerOption | null = null;
|
|
36
|
+
|
|
34
37
|
@state()
|
|
35
|
-
private selected?: TimePickerOption;
|
|
38
|
+
private selected?: TimePickerOption | null = this.defaultSelectedTime;
|
|
36
39
|
|
|
37
40
|
@property({ attribute: false })
|
|
38
|
-
get selectedTime(): undefined | TimePickerOption {
|
|
41
|
+
get selectedTime(): undefined | TimePickerOption | null {
|
|
39
42
|
return this.selected;
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
willUpdate(changedProperties: Map<string, unknown>): void {
|
|
46
|
+
if (
|
|
47
|
+
changedProperties.has("defaultSelectedTime") &&
|
|
48
|
+
this.selected === null
|
|
49
|
+
) {
|
|
50
|
+
this.selected = this.defaultSelectedTime;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
static styles = css`
|
|
43
55
|
* {
|
|
44
56
|
box-sizing: border-box;
|
|
@@ -10,9 +10,12 @@ import "./date-picker.ts";
|
|
|
10
10
|
import "./time-picker.ts";
|
|
11
11
|
import "../me-select.ts";
|
|
12
12
|
import {
|
|
13
|
+
dateStringToDateWithTimeZoneOffset,
|
|
14
|
+
dateToDateWithTimeZoneOffset,
|
|
13
15
|
DateWithTimeZoneOffset,
|
|
14
16
|
getAvailabilitiesGroupedByDay,
|
|
15
17
|
getExistenceOfAvailabilitiesByTourType,
|
|
18
|
+
getRawAvailabilities,
|
|
16
19
|
getTimezoneForBuilding,
|
|
17
20
|
resetAvailabilitiesCache,
|
|
18
21
|
} from "../../getAvailabilities";
|
|
@@ -46,6 +49,7 @@ import { TourWithAgentIcon } from "../icons/TourWithAgentIcon";
|
|
|
46
49
|
import { shouldOpenTourLink } from "../../fetchBuildingWebchatView";
|
|
47
50
|
import formatInTimeZone from "date-fns-tz/formatInTimeZone";
|
|
48
51
|
import { getTimezoneAbbreviation } from "../../getTimezoneString";
|
|
52
|
+
import startOfDay from "date-fns/startOfDay";
|
|
49
53
|
|
|
50
54
|
@customElement("tour-scheduler")
|
|
51
55
|
export class TourScheduler extends LitElement {
|
|
@@ -234,6 +238,40 @@ export class TourScheduler extends LitElement {
|
|
|
234
238
|
}
|
|
235
239
|
}, 0) === 1;
|
|
236
240
|
|
|
241
|
+
const availabilities = await getRawAvailabilities(this.buildingId);
|
|
242
|
+
const highestRankedTourType =
|
|
243
|
+
availabilities.rankOrderedSupportedTourTypes?.[0];
|
|
244
|
+
const availableTimesForHighestRankedTourType = highestRankedTourType
|
|
245
|
+
? availabilities.availability?.[highestRankedTourType]
|
|
246
|
+
?.availableTourStartTimes
|
|
247
|
+
: [];
|
|
248
|
+
const firstAvailableTimeSlotForHighestRankedTourType =
|
|
249
|
+
availableTimesForHighestRankedTourType?.[0];
|
|
250
|
+
if (
|
|
251
|
+
highestRankedTourType &&
|
|
252
|
+
firstAvailableTimeSlotForHighestRankedTourType &&
|
|
253
|
+
highestRankedTourType !==
|
|
254
|
+
TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.Unknown &&
|
|
255
|
+
highestRankedTourType !==
|
|
256
|
+
TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.MediaTour
|
|
257
|
+
) {
|
|
258
|
+
this.selectedDate =
|
|
259
|
+
typeof firstAvailableTimeSlotForHighestRankedTourType === "string"
|
|
260
|
+
? startOfDay(
|
|
261
|
+
parseISO(firstAvailableTimeSlotForHighestRankedTourType)
|
|
262
|
+
)
|
|
263
|
+
: startOfDay(firstAvailableTimeSlotForHighestRankedTourType);
|
|
264
|
+
this.tourType = rankedOrderTourTypeToTourType[highestRankedTourType];
|
|
265
|
+
this.selectedTime =
|
|
266
|
+
typeof firstAvailableTimeSlotForHighestRankedTourType === "string"
|
|
267
|
+
? dateStringToDateWithTimeZoneOffset(
|
|
268
|
+
firstAvailableTimeSlotForHighestRankedTourType
|
|
269
|
+
)
|
|
270
|
+
: dateToDateWithTimeZoneOffset(
|
|
271
|
+
firstAvailableTimeSlotForHighestRankedTourType
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
237
275
|
if (hasOneShowTourType) {
|
|
238
276
|
this.tourType = Object.keys(this.shouldShowTourType).find(
|
|
239
277
|
(key) => this.shouldShowTourType[key as TourType]
|
|
@@ -756,6 +794,7 @@ export class TourScheduler extends LitElement {
|
|
|
756
794
|
this.availabilitiesGroupedByDay,
|
|
757
795
|
(dates) => dates.map((date) => new Date(date.offset))
|
|
758
796
|
)}
|
|
797
|
+
.defaultDate=${this.selectedDate}
|
|
759
798
|
@change=${(e: Event) => {
|
|
760
799
|
// if the user clicked a tour type that is suppose to redirect, we redirect that use when they select a date
|
|
761
800
|
// This can happen if the user clicks, is redirect, and then comes back to the webchat
|
|
@@ -792,6 +831,24 @@ export class TourScheduler extends LitElement {
|
|
|
792
831
|
<time-picker
|
|
793
832
|
?selecteddateexists=${!!this.selectedDate}
|
|
794
833
|
.timezone=${this.calendarTimeZone}
|
|
834
|
+
.defaultSelectedTime=${this.selectedTime
|
|
835
|
+
? {
|
|
836
|
+
dateWithTimeZoneOffset: this.selectedTime,
|
|
837
|
+
displayTime: format(
|
|
838
|
+
parseISO(
|
|
839
|
+
`${this.selectedTime.datetime}${this.selectedTime.offset}`
|
|
840
|
+
),
|
|
841
|
+
"h:mmaaa"
|
|
842
|
+
),
|
|
843
|
+
displayTimeZoned: formatInTimeZone(
|
|
844
|
+
parseISO(
|
|
845
|
+
`${this.selectedTime.datetime}${this.selectedTime.offset}`
|
|
846
|
+
),
|
|
847
|
+
this.calendarTimeZone,
|
|
848
|
+
"h:mmaaa"
|
|
849
|
+
),
|
|
850
|
+
}
|
|
851
|
+
: null}
|
|
795
852
|
.options=${this.selectedDate
|
|
796
853
|
? this.availabilitiesGroupedByDay[
|
|
797
854
|
format(this.selectedDate, "y-MM-dd")
|
|
@@ -1423,6 +1480,15 @@ const tourTypeMap = {
|
|
|
1423
1480
|
TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing,
|
|
1424
1481
|
};
|
|
1425
1482
|
|
|
1483
|
+
const rankedOrderTourTypeToTourType = {
|
|
1484
|
+
[TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.WithAgent]:
|
|
1485
|
+
TourType.Guided,
|
|
1486
|
+
[TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.SelfGuided]:
|
|
1487
|
+
TourType.Self,
|
|
1488
|
+
[TourAvailabilityResponseRankOrderedSupportedTourTypesEnum.VirtualShowing]:
|
|
1489
|
+
TourType.Virtual,
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1426
1492
|
const tourTypeForSubmission = {
|
|
1427
1493
|
[TourType.Guided]: "escorted-tour",
|
|
1428
1494
|
[TourType.Self]: "self-guided-tour",
|
package/src/getAvailabilities.ts
CHANGED
|
@@ -181,9 +181,18 @@ export const getAvailabilitiesGroupedByDay = async (
|
|
|
181
181
|
* // returns { datetime: '2022-06-27T09:00:00', offset: '-07:00' }
|
|
182
182
|
* dateStringToDateWithTimeZoneOffset('2022-06-27T09:00:00-07:00')
|
|
183
183
|
* */
|
|
184
|
-
const dateStringToDateWithTimeZoneOffset = (
|
|
184
|
+
export const dateStringToDateWithTimeZoneOffset = (
|
|
185
185
|
dateString: string
|
|
186
186
|
): DateWithTimeZoneOffset => ({
|
|
187
187
|
datetime: dateString.slice(0, 19),
|
|
188
188
|
offset: dateString.slice(19),
|
|
189
189
|
});
|
|
190
|
+
|
|
191
|
+
export const dateToDateWithTimeZoneOffset = (
|
|
192
|
+
date: Date
|
|
193
|
+
): DateWithTimeZoneOffset => {
|
|
194
|
+
const datetime = format(date, "yyyy-MM-dd'T'HH:mm:ss");
|
|
195
|
+
const offset = format(date, "xxx");
|
|
196
|
+
|
|
197
|
+
return { datetime, offset };
|
|
198
|
+
};
|