close job

parent 83390d6c
...@@ -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 });
} }
import { Configuration, OpenAIApi } from "openai"; import { Configuration, OpenAIApi } from "openai";
import { OPEN_API_KEY } from "../config"; import { OPEN_API_KEY } from "../config";
const configuration = new Configuration({ const configuration = new Configuration({
organization: "org-AoUQNrvNFgE7OsNnQWErMvxy", organization: "org-AoUQNrvNFgE7OsNnQWErMvxy",
apiKey: OPEN_API_KEY, apiKey: OPEN_API_KEY,
}); });
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,
} });
\ No newline at end of file }
...@@ -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,17 +269,28 @@ const CreateUpdateJob = ({ ...@@ -265,17 +269,28 @@ const CreateUpdateJob = ({
/> />
</div> </div>
</div> </div>
<div className="d-md-block" style={{ float: "right" }}> <div className="d-md-block">
<button {mode !== "create" && (
className="btn btn-primary m-2" <button
onClick={onSubmit} className="btn btn-secondary m-2"
disabled={isLoading} onClick={onCloseJob}
> disabled={isLoading}
{btnText} >
</button> Close Job
<button className="btn btn-danger" onClick={toggleModal}> </button>
Cancel )}
</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> </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