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) => ({ ...@@ -22,3 +22,8 @@ export const setDialogBox = (payload: string | null) => ({
type: ACTIONS.SET_DIALOG, type: ACTIONS.SET_DIALOG,
payload, payload,
}); });
export const closeJob = (payload: string) => ({
type: ACTIONS.CLOSE_JOB,
payload,
});
...@@ -17,6 +17,7 @@ export enum ACTIONS { ...@@ -17,6 +17,7 @@ export enum ACTIONS {
GET_JOBS = "GET_JOBS", GET_JOBS = "GET_JOBS",
CREATE_JOB = "CREATE_JOB", CREATE_JOB = "CREATE_JOB",
UPDATE_JOB = "UPDATE_JOB", UPDATE_JOB = "UPDATE_JOB",
CLOSE_JOB = "CLOSE_JOB",
UPDATE_APPLICATION = "UPDATE_APPLICATION", UPDATE_APPLICATION = "UPDATE_APPLICATION",
UPDATE_APPLICATION_ACTION = "UPDATE_APPLICATION_ACTION", UPDATE_APPLICATION_ACTION = "UPDATE_APPLICATION_ACTION",
SET_DIALOG = "SET_DIALOG", SET_DIALOG = "SET_DIALOG",
......
...@@ -34,4 +34,7 @@ export default class CommonAPI { ...@@ -34,4 +34,7 @@ export default class CommonAPI {
static searchJobs = (key: string) => static searchJobs = (key: string) =>
request("<BASE_URL>/jobs/search", "GET", { key }); request("<BASE_URL>/jobs/search", "GET", { key });
static closeJob = (jobId: string) =>
request("<BASE_URL>/jobs/close", "DELETE", { jobId });
} }
...@@ -7,13 +7,14 @@ const configuration = new Configuration({ ...@@ -7,13 +7,14 @@ const configuration = new Configuration({
const openai = new OpenAIApi(configuration); const openai = new OpenAIApi(configuration);
export default class OpenAPI { export default class OpenAPI {
static getInterViewQuestions =(subject:string, level:string) => openai.createCompletion({ static getInterViewQuestions = (subject: string, level: string) =>
model:'text-davinci-003', openai.createCompletion({
prompt:`Create a list of ${level} questions with answers for my interview regarding ${subject}`, model: "text-davinci-003",
temperature:0.5, prompt: `Create a list of ${level} 10 questions with answers for my interview regarding ${subject}`,
max_tokens:150, temperature: 0.5,
top_p:1.0, max_tokens: 250,
frequency_penalty:0.0, top_p: 1.0,
presence_penalty:0.0 frequency_penalty: 0.0,
}) presence_penalty: 0.0,
});
} }
...@@ -103,8 +103,36 @@ function* updateJob({ ...@@ -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() { export default function* authSaga() {
yield takeLeading(ACTIONS.GET_JOBS, getJobs); yield takeLeading(ACTIONS.GET_JOBS, getJobs);
yield takeLeading(ACTIONS.CREATE_JOB, createJob); yield takeLeading(ACTIONS.CREATE_JOB, createJob);
yield takeLeading(ACTIONS.UPDATE_JOB, updateJob); yield takeLeading(ACTIONS.UPDATE_JOB, updateJob);
yield takeLeading(ACTIONS.CLOSE_JOB, closeJob);
} }
...@@ -64,7 +64,7 @@ const Analyse = ({ ...@@ -64,7 +64,7 @@ const Analyse = ({
}, [dispatch]); }, [dispatch]);
const getRecording = () => { const getRecording = () => {
if (application.interview?.link) { if (!application.interview?.videoRef && application.interview?.link) {
MeetingsAPI.getRecordings(application.interview.link).then((res: any) => { MeetingsAPI.getRecordings(application.interview.link).then((res: any) => {
if (res.data?.[0]?.file?.fileUrl) { if (res.data?.[0]?.file?.fileUrl) {
updateUserApplication(res.data?.[0]?.file?.fileUrl); updateUserApplication(res.data?.[0]?.file?.fileUrl);
......
import React, { useState, ChangeEvent } from "react"; import React, { useState, ChangeEvent } from "react";
import { useDispatch, useSelector } from "react-redux"; 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 { getUserId } from "../../common/lib/util";
import { JobType } from "../../common/types"; import { JobType } from "../../common/types";
import CustomModal from "./Modal"; import CustomModal from "./Modal";
...@@ -148,6 +148,10 @@ const CreateUpdateJob = ({ ...@@ -148,6 +148,10 @@ const CreateUpdateJob = ({
toggleModal(); toggleModal();
}; };
const onCloseJob = () => {
dispatch(closeJob(defaultJob?._id || ""));
};
const btnText = mode === "create" ? "Create job" : "Update job"; const btnText = mode === "create" ? "Create job" : "Update job";
return ( return (
...@@ -265,7 +269,17 @@ const CreateUpdateJob = ({ ...@@ -265,7 +269,17 @@ const CreateUpdateJob = ({
/> />
</div> </div>
</div> </div>
<div className="d-md-block" style={{ float: "right" }}> <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 <button
className="btn btn-primary m-2" className="btn btn-primary m-2"
onClick={onSubmit} onClick={onSubmit}
...@@ -277,6 +291,7 @@ const CreateUpdateJob = ({ ...@@ -277,6 +291,7 @@ const CreateUpdateJob = ({
Cancel Cancel
</button> </button>
</div> </div>
</div>
</CustomModal> </CustomModal>
</div> </div>
); );
......
...@@ -233,6 +233,8 @@ const Home = () => { ...@@ -233,6 +233,8 @@ const Home = () => {
CommonAPI.searchJobs(_searchKey.current).then(({ data }: any) => { CommonAPI.searchJobs(_searchKey.current).then(({ data }: any) => {
setSelectedJobs(data); 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