From ee9dc30805d844b15ca7885c05ceacc2cd72d49c Mon Sep 17 00:00:00 2001 From: yoution Date: Sat, 23 Oct 2021 19:30:13 +0800 Subject: [PATCH 1/2] fix: issue #523 --- src/constants/index.js | 13 ++++ src/root.component.jsx | 2 + src/routes/SchedulingPage/index.jsx | 73 ++++++++++++++++++++++ src/services/scheduler.js | 96 +++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 src/routes/SchedulingPage/index.jsx create mode 100644 src/services/scheduler.js diff --git a/src/constants/index.js b/src/constants/index.js index ff52aac..072b023 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -48,6 +48,19 @@ export const POSITION_STATUS = { CANCELLED: "cancelled", }; +/** + * Interview related constants + */ +export const INTERVIEW_STATUS = { + SCHEDULING: "Scheduling", + SCHEDULED: "Scheduled", + REQUESTEDFORRESCHEDULE: "Requested for reschedule", + RESCHEDULED: "Rescheduled", + COMPLETED: "Completed", + CANCELLED: "Cancelled", + EXPIRED: "Expired", +}; + /** * Mapping between position status "server value" and human readable value */ diff --git a/src/root.component.jsx b/src/root.component.jsx index 9c89234..159e979 100644 --- a/src/root.component.jsx +++ b/src/root.component.jsx @@ -19,6 +19,7 @@ import InputSkills from "./routes/CreateNewTeam/pages/InputSkills"; import InputJobDescription from "./routes/CreateNewTeam/pages/InputJobDescription"; import SelectRole from "./routes/CreateNewTeam/pages/SelectRole"; import CreateTaasPayment from "./routes/CreateNewTeam/pages/CreateTaasPayment"; +import SchedulingPage from "./routes/SchedulingPage"; import ReduxToastr from "react-redux-toastr"; import store from "./store"; import "./styles/main.vendor.scss"; @@ -50,6 +51,7 @@ export default function Root() { + {/* Global config for Toastr popups */} diff --git a/src/routes/SchedulingPage/index.jsx b/src/routes/SchedulingPage/index.jsx new file mode 100644 index 0000000..36cc412 --- /dev/null +++ b/src/routes/SchedulingPage/index.jsx @@ -0,0 +1,73 @@ +/** + * Scheduling Page + * + * Allows users to set up bookings for an interview in Nylas + */ +import React, { useEffect, useState } from "react"; +import { getAuthUserProfile } from "@topcoder/micro-frontends-navbar-app"; +import _ from "lodash"; +import Page from "components/Page"; +import LoadingIndicator from "components/LoadingIndicator"; +import PageHeader from "components/PageHeader"; +import { getInterview } from "services/scheduler"; +import { INTERVIEW_STATUS } from "constants"; +import withAuthentication from "../../hoc/withAuthentication"; + +const SchedulingPage = ({ interviewId }) => { + const [schedulingPageUrl, setSchedulingPageUrl] = useState(null); + const [errorMessage, setErrorMessage] = useState(null); + + // if there are some candidates to review, then show "To Review" tab by default + useEffect(() => { + getAuthUserProfile() + .then((res) => { + return { + firstName: res.firstName, + lastName: res.lastName, + email: res.email, + }; + }) + .then((profile) => { + getInterview(interviewId) + .then(({ data }) => { + if ( + data.status === INTERVIEW_STATUS.SCHEDULED || + data.status === INTERVIEW_STATUS.RESCHEDULED + ) { + setSchedulingPageUrl( + `https://schedule.nylas.com/${data.nylasPageSlug}?email=${ + profile.email + }&name=${encodeURI( + profile.firstName + " " + profile.lastName + )}&prefilled_readonly=true` + ); + } else { + setErrorMessage("No interviews scheduled"); + } + }) + .catch((err) => { + setErrorMessage(err); + }); + }); + }, [interviewId]); + + return ( + + {!schedulingPageUrl ? ( + + ) : ( + <> + +