Commit a3912188 authored by H.M.C. Nadunithara Wijerathne's avatar H.M.C. Nadunithara Wijerathne

Merge branch 'it19243122' into 'master'

Close job

See merge request !9
parents 149b8b1e a1aebd7b
......@@ -22,3 +22,8 @@ export const setDialogBox = (payload: string | null) => ({
type: ACTIONS.SET_DIALOG,
payload,
});
export const closeJob = (payload: string) => ({
type: ACTIONS.CLOSE_JOB,
payload,
});
......@@ -17,6 +17,7 @@ export enum ACTIONS {
GET_JOBS = "GET_JOBS",
CREATE_JOB = "CREATE_JOB",
UPDATE_JOB = "UPDATE_JOB",
CLOSE_JOB = "CLOSE_JOB",
UPDATE_APPLICATION = "UPDATE_APPLICATION",
UPDATE_APPLICATION_ACTION = "UPDATE_APPLICATION_ACTION",
SET_DIALOG = "SET_DIALOG",
......
......@@ -34,4 +34,7 @@ export default class CommonAPI {
static searchJobs = (key: string) =>
request("<BASE_URL>/jobs/search", "GET", { key });
static closeJob = (jobId: string) =>
request("<BASE_URL>/jobs/close", "DELETE", { jobId });
}
import { Configuration, OpenAIApi } from "openai";
import { OPEN_API_KEY } from "../config";
const configuration = new Configuration({
organization: "org-AoUQNrvNFgE7OsNnQWErMvxy",
apiKey: OPEN_API_KEY,
organization: "org-AoUQNrvNFgE7OsNnQWErMvxy",
apiKey: OPEN_API_KEY,
});
const openai = new OpenAIApi(configuration);
const openai = new OpenAIApi(configuration);
export default class OpenAPI {
static getInterViewQuestions =(subject:string, level:string) => openai.createCompletion({
model:'text-davinci-003',
prompt:`Create a list of ${level} questions with answers for my interview regarding ${subject}`,
temperature:0.5,
max_tokens:150,
top_p:1.0,
frequency_penalty:0.0,
presence_penalty:0.0
})
}
\ No newline at end of file
static getInterViewQuestions = (subject: string, level: string) =>
openai.createCompletion({
model: "text-davinci-003",
prompt: `Create a list of ${level} 10 questions with answers for my interview regarding ${subject}`,
temperature: 0.5,
max_tokens: 250,
top_p: 1.0,
frequency_penalty: 0.0,
presence_penalty: 0.0,
});
}
......@@ -103,8 +103,36 @@ function* updateJob({
}
}
function* closeJob({
payload,
}: {
type: typeof ACTIONS.CLOSE_JOB;
payload: string;
}) {
try {
yield put({
type: ACTIONS.SET_APP_STATE,
payload: { state: APP_STATE.LOADING },
});
yield call(CommonAPI.closeJob, payload);
yield call(getJobs, { type: ACTIONS.GET_JOBS });
yield put({
type: ACTIONS.SET_APP_STATE,
payload: { state: APP_STATE.SUCCESS },
});
} catch (error) {
yield put({
type: ACTIONS.SET_APP_STATE,
payload: { state: APP_STATE.FAILED },
});
}
}
export default function* authSaga() {
yield takeLeading(ACTIONS.GET_JOBS, getJobs);
yield takeLeading(ACTIONS.CREATE_JOB, createJob);
yield takeLeading(ACTIONS.UPDATE_JOB, updateJob);
yield takeLeading(ACTIONS.CLOSE_JOB, closeJob);
}
......@@ -64,7 +64,7 @@ const Analyse = ({
}, [dispatch]);
const getRecording = () => {
if (application.interview?.link) {
if (!application.interview?.videoRef && application.interview?.link) {
MeetingsAPI.getRecordings(application.interview.link).then((res: any) => {
if (res.data?.[0]?.file?.fileUrl) {
updateUserApplication(res.data?.[0]?.file?.fileUrl);
......
import React, { useState, ChangeEvent } from "react";
import { useDispatch, useSelector } from "react-redux";
import { createJob, updateJob } from "../../common/actions/common";
import { closeJob, createJob, updateJob } from "../../common/actions/common";
import { getUserId } from "../../common/lib/util";
import { JobType } from "../../common/types";
import CustomModal from "./Modal";
......@@ -148,6 +148,10 @@ const CreateUpdateJob = ({
toggleModal();
};
const onCloseJob = () => {
dispatch(closeJob(defaultJob?._id || ""));
};
const btnText = mode === "create" ? "Create job" : "Update job";
return (
......@@ -265,17 +269,28 @@ const CreateUpdateJob = ({
/>
</div>
</div>
<div className="d-md-block" style={{ float: "right" }}>
<button
className="btn btn-primary m-2"
onClick={onSubmit}
disabled={isLoading}
>
{btnText}
</button>
<button className="btn btn-danger" onClick={toggleModal}>
Cancel
</button>
<div className="d-md-block">
{mode !== "create" && (
<button
className="btn btn-secondary m-2"
onClick={onCloseJob}
disabled={isLoading}
>
Close Job
</button>
)}
<div style={{ float: "right" }}>
<button
className="btn btn-primary m-2"
onClick={onSubmit}
disabled={isLoading}
>
{btnText}
</button>
<button className="btn btn-danger" onClick={toggleModal}>
Cancel
</button>
</div>
</div>
</CustomModal>
</div>
......
......@@ -233,6 +233,8 @@ const Home = () => {
CommonAPI.searchJobs(_searchKey.current).then(({ data }: any) => {
setSelectedJobs(data);
});
} else {
setSelectedJobs(jobs);
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment