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

Updated deleting & reconnecting calendars API integration. #540

Merged
merged 2 commits into from Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import "./styles.module.scss";
*/
const Confirm = ({
scheduleDetails,
candidateId,
userProfile,
candidate,
onGoBack,
onContinue,
onShowingLoader,
}) => {
const { handle } = userProfile;
const { handle, id: candidateId } = candidate;
const { duration } = scheduleDetails;

/**
Expand Down Expand Up @@ -83,8 +82,7 @@ const Confirm = ({

Confirm.propTypes = {
scheduleDetails: PT.object,
userProfile: PT.object,
candidateId: PT.string,
candidate: PT.object,
onGoBack: PT.func,
onContinue: PT.func,
onShowingLoader: PT.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ const ConnectCalendar = ({
{isConnected && (
<>
<div styleName="connected-section">
<span styleName="connected-to-text">Currently connected to: </span>
<span styleName="email-address">
{` ${calendar && calendar.accountEmail}`}
<span styleName="connected-to-text">
{'Currently connected to: '}
<span styleName="email-address">
{calendar && calendar.email}
</span>
</span>
{!showLoader && (
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import "./styles.module.scss";
/**
* The success component shown once the interview is scheduled successfully
*/
const Success = ({ userProfile, onContinue }) => {
const { handle } = userProfile;
const Success = ({ candidate, onContinue }) => {
const { handle } = candidate;
return (
<div styleName="success-wrapper">
<div styleName="success-text">
Expand All @@ -29,7 +29,7 @@ const Success = ({ userProfile, onContinue }) => {
};

Success.propTypes = {
userProfile: PT.object,
candidate: PT.object,
};

export default Success;
33 changes: 19 additions & 14 deletions src/routes/PositionDetails/components/InterviewPopup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,24 @@ const InterviewPopup = ({
/**
* Gets the settings from the backend and checks if the calendar is already available
*/
const getSettings = () => {
const getSettings = (options = { preferredStage: POPUP_STAGES.MANAGE_AVAILABILITY }) => {
setLoading(true);
getUserSettings(v5UserProfile.id)
.then((res) => {
setUserSettings(res.data);
setScheduleDetails(prepareSlots(res.data));
setStage(POPUP_STAGES.MANAGE_AVAILABILITY);

let nextStage = options.preferredStage;
if (
options.preferredStage === POPUP_STAGES.CONNECT_CALENDAR &&
_.findIndex(res.data.nylasCalendars, (item) => item.isPrimary) !== -1
) {
// checks if any connected calendars are available by above conditions
// if available, modify nextStage to POPUP_STAGES.MANAGE_CALENDAR
nextStage = POPUP_STAGES.MANAGE_CALENDAR;
}

setStage(nextStage);
})
.catch((e) => {
if (e.response && e.response.status === 404) {
Expand All @@ -87,7 +98,7 @@ const InterviewPopup = ({
};

/**
* Get the calendar which is not of provider nylas
* Get the calendar which is not of provider nylas & is a primary calendar
* @param {*} settings
* @returns
*/
Expand All @@ -96,10 +107,10 @@ const InterviewPopup = ({
const calendar =
(settings.nylasCalendars &&
settings.nylasCalendars.filter(
(item) => item.accountProvider !== "nylas"
(item) => item.accountProvider !== "nylas" && item.isPrimary
)) ||
[];
// Take the first calendar which are other than nylas calendar
// Take the first calendar which are other than nylas calendar & which is primary
return calendar[0];
};

Expand Down Expand Up @@ -146,12 +157,7 @@ const InterviewPopup = ({
* Removes the calendar from the state once it is removed from the server
*/
const onCalendarRemoved = () => {
setUserSettings({
...userSettings,
nylasCalendars: [],
});

setStage(POPUP_STAGES.CONNECT_CALENDAR);
getSettings({ preferredStage: POPUP_STAGES.CONNECT_CALENDAR });
};

/**
Expand Down Expand Up @@ -203,16 +209,15 @@ const InterviewPopup = ({
return (
<Confirm
scheduleDetails={scheduleDetails}
userProfile={v5UserProfile}
onContinue={onChangeStage}
onGoBack={onGoingBack}
onShowingLoader={onShowingLoader}
candidateId={candidate.id}
candidate={candidate}
/>
);
case POPUP_STAGES.SUCCESS:
return (
<Success userProfile={v5UserProfile} onContinue={onChangeStage} />
<Success candidate={candidate} onContinue={onChangeStage} />
);
default:
return null;
Expand Down