Skip to content

Commit

Permalink
improve forms value when we switch edit recurring
Browse files Browse the repository at this point in the history
Signed-off-by: AHMAD KADRI <[email protected]>
  • Loading branch information
ahmadkadri committed Sep 12, 2023
1 parent 74e40bf commit 6fe4e92
Showing 1 changed file with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ export const ScheduleMeeting = ({
[],
);

const handleChangeWidgets = useCallback(
(value: string[]) => {
setWidgets(value);

// Skip setting it to dirty in the first call as the widget picker always
// triggers once at startup
if (widgets.length > 0) {
setIsDirty(true);
}
},
[widgets.length],
);

const handleChangeRecurrence = useCallback(
(rrule: string | undefined, isValid: boolean, isDirty: boolean) => {
setRecurrence({ rrule, isValid, isDirty });
},
[],
);

const handleSwitchEditRecurring = useCallback(
(_, checked: boolean) => {
setIsEditRecurring(checked);
Expand All @@ -318,29 +338,21 @@ export const ScheduleMeeting = ({
initialMeeting.calendarEntries[0].dtend,
),
);
if (isEditRecurring) {
setTitle(initialMeeting.title);
setDescription(initialMeeting.description ?? '');
setIsMessagingEnabled(initialIsMessagingEnabled);
setParticipants(initialMeeting.participants.map((p) => p.userId));
setWidgets(initialMeeting.widgets);
setRecurrence({
rrule: initialMeeting?.calendarEntries[0].rrule,
isValid: true,
isDirty: false,
});
}
}
},
[initialMeeting, isEditRecurring],
);

const handleChangeWidgets = useCallback(
(value: string[]) => {
setWidgets(value);

// Skip setting it to dirty in the first call as the widget picker always
// triggers once at startup
if (widgets.length > 0) {
setIsDirty(true);
}
},
[widgets.length],
);

const handleChangeRecurrence = useCallback(
(rrule: string | undefined, isValid: boolean, isDirty: boolean) => {
setRecurrence({ rrule, isValid, isDirty });
},
[],
[initialIsMessagingEnabled, initialMeeting, isEditRecurring],
);

const minStartTimeOverride = isEditingRecurringMeeting
Expand Down

0 comments on commit 6fe4e92

Please sign in to comment.