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

Commit 5574436

Browse files
authored
Merge pull request #540 from mahidulalvi-bonic/feature/interview-update
Updated deleting & reconnecting calendars API integration.
2 parents 14e7e01 + b4551de commit 5574436

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ import "./styles.module.scss";
1818
*/
1919
const Confirm = ({
2020
scheduleDetails,
21-
candidateId,
22-
userProfile,
21+
candidate,
2322
onGoBack,
2423
onContinue,
2524
onShowingLoader,
2625
}) => {
27-
const { handle } = userProfile;
26+
const { handle, id: candidateId } = candidate;
2827
const { duration } = scheduleDetails;
2928

3029
/**
@@ -83,8 +82,7 @@ const Confirm = ({
8382

8483
Confirm.propTypes = {
8584
scheduleDetails: PT.object,
86-
userProfile: PT.object,
87-
candidateId: PT.string,
85+
candidate: PT.object,
8886
onGoBack: PT.func,
8987
onContinue: PT.func,
9088
onShowingLoader: PT.func,

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/Success/index.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import "./styles.module.scss";
77
/**
88
* The success component shown once the interview is scheduled successfully
99
*/
10-
const Success = ({ userProfile, onContinue }) => {
11-
const { handle } = userProfile;
10+
const Success = ({ candidate, onContinue }) => {
11+
const { handle } = candidate;
1212
return (
1313
<div styleName="success-wrapper">
1414
<div styleName="success-text">
@@ -29,7 +29,7 @@ const Success = ({ userProfile, onContinue }) => {
2929
};
3030

3131
Success.propTypes = {
32-
userProfile: PT.object,
32+
candidate: PT.object,
3333
};
3434

3535
export default Success;

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

+19-14
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
/**
@@ -203,16 +209,15 @@ const InterviewPopup = ({
203209
return (
204210
<Confirm
205211
scheduleDetails={scheduleDetails}
206-
userProfile={v5UserProfile}
207212
onContinue={onChangeStage}
208213
onGoBack={onGoingBack}
209214
onShowingLoader={onShowingLoader}
210-
candidateId={candidate.id}
215+
candidate={candidate}
211216
/>
212217
);
213218
case POPUP_STAGES.SUCCESS:
214219
return (
215-
<Success userProfile={v5UserProfile} onContinue={onChangeStage} />
220+
<Success candidate={candidate} onContinue={onChangeStage} />
216221
);
217222
default:
218223
return null;

0 commit comments

Comments
 (0)