Skip to content

Commit 8ff075e

Browse files
refactor(calendar-web): convert event handlers to arrow functions and adjust time building logic
1 parent e1cf84e commit 8ff075e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

packages/pluggableWidgets/calendar-web/src/helpers/CalendarPropsBuilder.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ export class CalendarPropsBuilder {
108108

109109
private buildTime(hour: number): Date {
110110
const time = new Date();
111-
time.setHours(hour, 0, 0, 0);
111+
time.setMinutes(0, 0, 0);
112+
113+
if (hour >= 24) {
114+
time.setHours(23, 59, 59);
115+
} else {
116+
time.setHours(hour);
117+
}
118+
112119
return time;
113120
}
114121

@@ -126,7 +133,7 @@ export class CalendarPropsBuilder {
126133
return new Set(visibleDays);
127134
}
128135

129-
private handleEventDropOrResize({ event, start, end }: EventDropOrResize): void {
136+
private handleEventDropOrResize = ({ event, start, end }: EventDropOrResize): void => {
130137
const action = this.props.onChange?.get(event.item);
131138

132139
if (action?.canExecute) {
@@ -137,9 +144,9 @@ export class CalendarPropsBuilder {
137144
newEnd: end
138145
});
139146
}
140-
}
147+
};
141148

142-
private handleRangeChange(date: Date, view: string, _action: NavigateAction): void {
149+
private handleRangeChange = (date: Date, view: string, _action: NavigateAction): void => {
143150
const action = this.props.onRangeChange;
144151

145152
if (action?.canExecute) {
@@ -150,9 +157,9 @@ export class CalendarPropsBuilder {
150157
currentView: view
151158
});
152159
}
153-
}
160+
};
154161

155-
private handleSelectEvent(event: CalendarEvent): void {
162+
private handleSelectEvent = (event: CalendarEvent): void => {
156163
const action = this.props.onClickEvent?.get(event.item);
157164

158165
if (action?.canExecute) {
@@ -163,9 +170,9 @@ export class CalendarPropsBuilder {
163170
title: event.title
164171
});
165172
}
166-
}
173+
};
167174

168-
private handleSelectSlot(slotInfo: { start: Date; end: Date; action: string }): void {
175+
private handleSelectSlot = (slotInfo: { start: Date; end: Date; action: string }): void => {
169176
const action = this.props.onCreateEvent;
170177

171178
if (action?.canExecute && this.props.enableCreate) {
@@ -175,5 +182,5 @@ export class CalendarPropsBuilder {
175182
allDay: slotInfo.action === "select"
176183
});
177184
}
178-
}
185+
};
179186
}

0 commit comments

Comments
 (0)