Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit a5fa998

Browse files
committed
Updated deleting & reconnecting calendars API integration.
When connecting a calendar while there is a pre-existing connected calendar, the UI shows the newly connected calendar as the primary and gives option to remove it. Previously, it would still show the previous calendar as primary. And when removing a calendar, the UI shows the POPUP_STAGES.CONNECT_CALENDAR modal view if there are no remaining connected calendars. But if there is, the UI shows the POPUP_STAGES.MANAGE_CALENDAR view. Previously, it would show the user POPUP_STAGES.MANAGE_AVAILABILITY view.
1 parent f9db0d4 commit a5fa998

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/routes/PositionDetails/components/InterviewPopup/ConnectCalendar/index.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ const ConnectCalendar = ({
6363
{isConnected && (
6464
<>
6565
<div styleName="connected-section">
66-
<span styleName="connected-to-text">Currently connected to: </span>
67-
<span styleName="email-address">
68-
{` ${calendar && calendar.accountEmail}`}
66+
<span styleName="connected-to-text">
67+
{'Currently connected to: '}
68+
<span styleName="email-address">
69+
{calendar && calendar.email}
70+
</span>
6971
</span>
7072
{!showLoader && (
7173
<button

src/routes/PositionDetails/components/InterviewPopup/index.jsx

+17-11
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,24 @@ const InterviewPopup = ({
6565
/**
6666
* Gets the settings from the backend and checks if the calendar is already available
6767
*/
68-
const getSettings = () => {
68+
const getSettings = (options = { preferredStage: POPUP_STAGES.MANAGE_AVAILABILITY }) => {
6969
setLoading(true);
7070
getUserSettings(v5UserProfile.id)
7171
.then((res) => {
7272
setUserSettings(res.data);
7373
setScheduleDetails(prepareSlots(res.data));
74-
setStage(POPUP_STAGES.MANAGE_AVAILABILITY);
74+
75+
let nextStage = options.preferredStage;
76+
if (
77+
options.preferredStage === POPUP_STAGES.CONNECT_CALENDAR &&
78+
_.findIndex(res.data.nylasCalendars, (item) => item.isPrimary) !== -1
79+
) {
80+
// checks if any connected calendars are available by above conditions
81+
// if available, modify nextStage to POPUP_STAGES.MANAGE_CALENDAR
82+
nextStage = POPUP_STAGES.MANAGE_CALENDAR;
83+
}
84+
85+
setStage(nextStage);
7586
})
7687
.catch((e) => {
7788
if (e.response && e.response.status === 404) {
@@ -87,7 +98,7 @@ const InterviewPopup = ({
8798
};
8899

89100
/**
90-
* Get the calendar which is not of provider nylas
101+
* Get the calendar which is not of provider nylas & is a primary calendar
91102
* @param {*} settings
92103
* @returns
93104
*/
@@ -96,10 +107,10 @@ const InterviewPopup = ({
96107
const calendar =
97108
(settings.nylasCalendars &&
98109
settings.nylasCalendars.filter(
99-
(item) => item.accountProvider !== "nylas"
110+
(item) => item.accountProvider !== "nylas" && item.isPrimary
100111
)) ||
101112
[];
102-
// Take the first calendar which are other than nylas calendar
113+
// Take the first calendar which are other than nylas calendar & which is primary
103114
return calendar[0];
104115
};
105116

@@ -146,12 +157,7 @@ const InterviewPopup = ({
146157
* Removes the calendar from the state once it is removed from the server
147158
*/
148159
const onCalendarRemoved = () => {
149-
setUserSettings({
150-
...userSettings,
151-
nylasCalendars: [],
152-
});
153-
154-
setStage(POPUP_STAGES.CONNECT_CALENDAR);
160+
getSettings({ preferredStage: POPUP_STAGES.CONNECT_CALENDAR });
155161
};
156162

157163
/**

0 commit comments

Comments
 (0)