| import { useEffect } from "react"; | import { useEffect } from "react"; | ||||
| import { SelectionContext } from "../../context/SelectionContext"; | import { SelectionContext } from "../../context/SelectionContext"; | ||||
| import { setUpdateStatusReq } from "../../store/actions/processes/processAction"; | import { setUpdateStatusReq } from "../../store/actions/processes/processAction"; | ||||
| import { createScreeningTest } from "../../store/actions/screeningTests/screeningTestActions"; | |||||
| const StatusDialog = ({ | const StatusDialog = ({ | ||||
| title, | title, | ||||
| fullWidth, | fullWidth, | ||||
| responsive, | responsive, | ||||
| }) => { | }) => { | ||||
| const [selected, setSelected] = useState(""); | |||||
| const [selected, setSelected] = useState(''); | |||||
| const [value, setValue] = useState(null); | const [value, setValue] = useState(null); | ||||
| const [selectedScreeningTest, setSelectedScreeningTest] = useState(""); | |||||
| const { activeProcess, setActiveProcess } = useContext(SelectionContext) | |||||
| const { activeProcess, setActiveProcess } = useContext(SelectionContext); | |||||
| const theme = useTheme(); | const theme = useTheme(); | ||||
| const fullScreen = useMediaQuery(theme.breakpoints.down("md")); | const fullScreen = useMediaQuery(theme.breakpoints.down("md")); | ||||
| const { users } = useSelector((s) => s.users); | const { users } = useSelector((s) => s.users); | ||||
| const { isSuccess } = useSelector((s) => s.initProcess); | const { isSuccess } = useSelector((s) => s.initProcess); | ||||
| const { screeningTests } = useSelector((s) => s.screeningTests); | |||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| }, [dispatch, isSuccess]); | }, [dispatch, isSuccess]); | ||||
| const handleChange = (newValue) => { | const handleChange = (newValue) => { | ||||
| if (isValid(newValue)) { // throws an error if invalid value is set | |||||
| if (isValid(newValue)) { | |||||
| // throws an error if invalid value is set | |||||
| var date = format(newValue, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"); | var date = format(newValue, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"); | ||||
| setValue(date); | setValue(date); | ||||
| } | } | ||||
| }; | }; | ||||
| useEffect(()=>{ | |||||
| setSelected('') | |||||
| setValue(null) | |||||
| }, [onClose]) | |||||
| useEffect(() => { | |||||
| setSelected(''); | |||||
| setValue(null); | |||||
| setSelectedScreeningTest("") | |||||
| }, [onClose]); | |||||
| const handleClose = () => { | const handleClose = () => { | ||||
| onClose(); | onClose(); | ||||
| }; | }; | ||||
| const submitHandler = () => { | const submitHandler = () => { | ||||
| console.log(selected) | |||||
| if (activeProcess.process.selectionLevelId !== 2) { | |||||
| dispatch( | dispatch( | ||||
| setUpdateStatusReq({ | setUpdateStatusReq({ | ||||
| data: { | data: { | ||||
| newStatus: activeProcess.status, | newStatus: activeProcess.status, | ||||
| processId: activeProcess.process.id, | processId: activeProcess.process.id, | ||||
| }, | }, | ||||
| responseHandler: apiSuccess | |||||
| responseHandler: apiSuccess, | |||||
| }) | }) | ||||
| ); | ); | ||||
| } else { | |||||
| dispatch( | |||||
| setUpdateStatusReq({ | |||||
| data: { | |||||
| schedulerId: selected, | |||||
| appointment: value, | |||||
| newStatus: activeProcess.status, | |||||
| processId: activeProcess.process.id, | |||||
| }, | |||||
| responseHandler: apiSuccessScreeningTests, | |||||
| }) | |||||
| ); | |||||
| } | |||||
| }; | |||||
| const apiSuccessScreeningTests = () => { | |||||
| const user = users.find(k => k.id === selected) | |||||
| dispatch( | |||||
| createScreeningTest({ | |||||
| adminEmail: user.email, | |||||
| email: activeProcess.process.applicant.email, | |||||
| duration: 60, | |||||
| testId: parseInt(selectedScreeningTest), | |||||
| url: "https:dzenis-meris.com", | |||||
| }) | |||||
| ); | |||||
| setActiveProcess(null); | |||||
| }; | }; | ||||
| const apiSuccess = () =>{ | |||||
| setActiveProcess(null) | |||||
| } | |||||
| const apiSuccess = () => { | |||||
| setActiveProcess(null); | |||||
| }; | |||||
| return ( | return ( | ||||
| <Dialog | <Dialog | ||||
| <form className="modal-content interviewDialog"> | <form className="modal-content interviewDialog"> | ||||
| <FormControl fullWidth> | <FormControl fullWidth> | ||||
| <InputLabel id="demo-simple-select-label"> | <InputLabel id="demo-simple-select-label"> | ||||
| Ime intervjuera | |||||
| Ime intervjuera | |||||
| </InputLabel> | </InputLabel> | ||||
| <Select | <Select | ||||
| labelId="demo-simple-select-label" | labelId="demo-simple-select-label" | ||||
| }} | }} | ||||
| > | > | ||||
| {users | {users | ||||
| ? users.map( | |||||
| ({ id, firstName, lastName }, index) => ( | |||||
| <MenuItem | |||||
| key={index} | |||||
| sx={{ textAlign: "left" }} | |||||
| value={id} | |||||
| > | |||||
| {firstName} {lastName} | |||||
| </MenuItem> | |||||
| ) | |||||
| ) | |||||
| ? users.map(({ id, firstName, lastName }, index) => ( | |||||
| <MenuItem | |||||
| key={index} | |||||
| sx={{ textAlign: "left" }} | |||||
| value={id} | |||||
| > | |||||
| {firstName} {lastName} | |||||
| </MenuItem> | |||||
| )) | |||||
| : ""} | : ""} | ||||
| </Select> | </Select> | ||||
| </FormControl> | </FormControl> | ||||
| {activeProcess !== null && | |||||
| activeProcess.process.selectionLevelId === 2 && ( | |||||
| <FormControl fullWidth> | |||||
| <InputLabel id="demo-simple-select-label"> | |||||
| Screening test | |||||
| </InputLabel> | |||||
| <Select | |||||
| labelId="demo-simple-select-label" | |||||
| id="demo-simple-select" | |||||
| value={selectedScreeningTest} | |||||
| label="Screening test" | |||||
| onChange={(e) => { | |||||
| setSelectedScreeningTest(e.target.value); | |||||
| }} | |||||
| > | |||||
| {screeningTests | |||||
| ? screeningTests.map((screeningTest, index) => ( | |||||
| <MenuItem | |||||
| key={index} | |||||
| sx={{ textAlign: "left" }} | |||||
| value={screeningTest.id} | |||||
| > | |||||
| {screeningTest.name} | |||||
| </MenuItem> | |||||
| )) | |||||
| : ""} | |||||
| </Select> | |||||
| </FormControl> | |||||
| )} | |||||
| {/* {activeProcess.process && activeProcess.process.date ? <p>Proces ima zakazan termin</p> : ''} */} | {/* {activeProcess.process && activeProcess.process.date ? <p>Proces ima zakazan termin</p> : ''} */} | ||||
| <DateTimePicker | <DateTimePicker | ||||
| label="Termin" | label="Termin" |
| import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns"; | import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns"; | ||||
| import { LocalizationProvider } from "@mui/x-date-pickers"; | import { LocalizationProvider } from "@mui/x-date-pickers"; | ||||
| import { fetchCandidateOptions } from "../../store/actions/candidates/candidatesActions"; | import { fetchCandidateOptions } from "../../store/actions/candidates/candidatesActions"; | ||||
| import { fetchScreeningTests } from "../../store/actions/screeningTests/screeningTestActions"; | |||||
| import { SelectionContext } from "../../context/SelectionContext"; | import { SelectionContext } from "../../context/SelectionContext"; | ||||
| import { setUsersReq } from "../../store/actions/users/usersActions"; | import { setUsersReq } from "../../store/actions/users/usersActions"; | ||||
| import StatusDialog from "../../components/MUI/StatusDialog"; | import StatusDialog from "../../components/MUI/StatusDialog"; | ||||
| useEffect(() => { | useEffect(() => { | ||||
| dispatch(fetchCandidateOptions()); | dispatch(fetchCandidateOptions()); | ||||
| dispatch(setProcessesReq()); | dispatch(setProcessesReq()); | ||||
| dispatch(fetchScreeningTests()); | |||||
| dispatch(setUsersReq()); | dispatch(setUsersReq()); | ||||
| const s = [ | const s = [ | ||||
| { isChecked: false, name: "Zakazan" }, | { isChecked: false, name: "Zakazan" }, |
| doneProcess: base + "/selectionprocesses", | doneProcess: base + "/selectionprocesses", | ||||
| getApplicantProcesses: base + "/applicants/processes", | getApplicantProcesses: base + "/applicants/processes", | ||||
| changeStatus: base + "/selectionprocesses/status-update", | changeStatus: base + "/selectionprocesses/status-update", | ||||
| changeInterviewer: base + "/selectionprocesses/interviewer-update" | |||||
| changeInterviewer: base + "/selectionprocesses/interviewer-update", | |||||
| // allProcesses: base + "/selectionprocesses", | // allProcesses: base + "/selectionprocesses", | ||||
| }, | }, | ||||
| patterns: { | patterns: { | ||||
| applyForAd: base + "/applicants/apply-for-ad", | applyForAd: base + "/applicants/apply-for-ad", | ||||
| getCV: base + "/applicants/get-CV", | getCV: base + "/applicants/get-CV", | ||||
| }, | }, | ||||
| screeningTest: { | |||||
| allTests: base + "/screeningtest", | |||||
| createTest:base + '/screeningtest' | |||||
| }, | |||||
| }; | }; |
| import { getRequest, postRequest } from "."; | |||||
| import apiEndpoints from "./apiEndpoints"; | |||||
| export const getTests = () => getRequest(apiEndpoints.screeningTest.allTests); | |||||
| export const createTest = (payload) => | |||||
| postRequest(apiEndpoints.screeningTest.createTest,payload); |
| import { | |||||
| SCREENING_TESTS_FETCH, | |||||
| SCREENING_TESTS_ERROR, | |||||
| SCREENING_TESTS_SUCCESS, | |||||
| CREATE_SCREENING_TEST, | |||||
| CREATE_SCREENING_TEST_ERROR, | |||||
| CREATE_SCREENING_TEST_SUCCESS, | |||||
| } from "./screeningTestsActionConstants"; | |||||
| export const fetchScreeningTests = () => ({ | |||||
| type: SCREENING_TESTS_FETCH, | |||||
| }); | |||||
| export const fetchScreeningTestsError = (payload) => ({ | |||||
| type: SCREENING_TESTS_ERROR, | |||||
| payload, | |||||
| }); | |||||
| export const fetchScreeningTestsSuccess = (payload) => ({ | |||||
| type: SCREENING_TESTS_SUCCESS, | |||||
| payload, | |||||
| }); | |||||
| export const createScreeningTest = (payload) => ({ | |||||
| type: CREATE_SCREENING_TEST, | |||||
| payload, | |||||
| }); | |||||
| export const createScreeningTestError = (payload) => ({ | |||||
| type: CREATE_SCREENING_TEST_ERROR, | |||||
| payload, | |||||
| }); | |||||
| export const createScreeningTestSuccess = (payload) => ({ | |||||
| type: CREATE_SCREENING_TEST_SUCCESS, | |||||
| payload, | |||||
| }); |
| import { | |||||
| createErrorType, | |||||
| createFetchType, | |||||
| createLoadingType, | |||||
| createSuccessType, | |||||
| } from "../actionHelpers"; | |||||
| const SCREENING_TESTS_SCOPE = "SCREENING_TESTS"; | |||||
| const CREATE_SCREENING_TEST_SCOPE = "CREATE_SCREENING_TEST"; | |||||
| export const SCREENING_TESTS_FETCH = createFetchType(SCREENING_TESTS_SCOPE); | |||||
| export const SCREENING_TESTS_ERROR = createErrorType(SCREENING_TESTS_SCOPE); | |||||
| export const SCREENING_TESTS_SUCCESS = createSuccessType(SCREENING_TESTS_SCOPE); | |||||
| export const SCREENING_TESTS_LOADING = createLoadingType(SCREENING_TESTS_SCOPE); | |||||
| export const CREATE_SCREENING_TEST = createFetchType(CREATE_SCREENING_TEST_SCOPE); | |||||
| export const CREATE_SCREENING_TEST_ERROR = createErrorType(CREATE_SCREENING_TEST_SCOPE); | |||||
| export const CREATE_SCREENING_TEST_SUCCESS = createSuccessType(CREATE_SCREENING_TEST_SCOPE); | |||||
| export const CREATE_SCREENING_TEST_LOADING = createLoadingType(CREATE_SCREENING_TEST_SCOPE); |
| import applyForAdReducer from "./applicants/applyForAdReducer"; | import applyForAdReducer from "./applicants/applyForAdReducer"; | ||||
| import statusUpdateReducer from "./processes/statusUpdateReducer"; | import statusUpdateReducer from "./processes/statusUpdateReducer"; | ||||
| import interviewerUpdateReducer from "./processes/interviewerUpdateReducer"; | import interviewerUpdateReducer from "./processes/interviewerUpdateReducer"; | ||||
| import screeningTestsReducer from "./screeningTests/screeningTestsReducer"; | |||||
| export default combineReducers({ | export default combineReducers({ | ||||
| login: loginReducer, | login: loginReducer, | ||||
| patternApplicants: patternApplicantsReducer, | patternApplicants: patternApplicantsReducer, | ||||
| applyForAd: applyForAdReducer, | applyForAd: applyForAdReducer, | ||||
| statusUpdate: statusUpdateReducer, | statusUpdate: statusUpdateReducer, | ||||
| interviewerUpdate: interviewerUpdateReducer | |||||
| interviewerUpdate: interviewerUpdateReducer, | |||||
| screeningTests:screeningTestsReducer | |||||
| }); | }); |
| import createReducer from "../../utils/createReducer"; | |||||
| import { | |||||
| SCREENING_TESTS_ERROR, | |||||
| SCREENING_TESTS_SUCCESS, | |||||
| } from "../../actions/screeningTests/screeningTestsActionConstants"; | |||||
| const initialState = { | |||||
| screeningTests: [], | |||||
| errorMessage: "", | |||||
| }; | |||||
| export default createReducer( | |||||
| { | |||||
| [SCREENING_TESTS_SUCCESS]: setScreeningTests, | |||||
| [SCREENING_TESTS_ERROR]: setScreeningTestsError, | |||||
| }, | |||||
| initialState | |||||
| ); | |||||
| function setScreeningTests(state, action) { | |||||
| return { | |||||
| ...state, | |||||
| screeningTests: action.payload, | |||||
| }; | |||||
| } | |||||
| function setScreeningTestsError(state, action) { | |||||
| return { | |||||
| ...state, | |||||
| errorMessage: action.payload, | |||||
| }; | |||||
| } |
| import scheduleSaga from "./scheduleSaga"; | import scheduleSaga from "./scheduleSaga"; | ||||
| import registerSaga from "./registerSaga"; | import registerSaga from "./registerSaga"; | ||||
| import applicantsSaga from "./applicantsSaga"; | import applicantsSaga from "./applicantsSaga"; | ||||
| import screeningTestsSaga from "./screeningTestsSaga"; | |||||
| export default function* rootSaga() { | export default function* rootSaga() { | ||||
| yield all([ | yield all([ | ||||
| scheduleSaga(), | scheduleSaga(), | ||||
| registerSaga(), | registerSaga(), | ||||
| applicantsSaga(), | applicantsSaga(), | ||||
| screeningTestsSaga() | |||||
| ]); | ]); | ||||
| } | } |
| import { all, call, put, takeEvery } from "redux-saga/effects"; | |||||
| import { JWT_TOKEN } from "../../constants/localStorage"; | |||||
| import { addHeaderToken } from "../../request"; | |||||
| import { getTests, createTest } from "../../request/screeningTestRequest"; | |||||
| import { authScopeStringGetHelper } from "../../util/helpers/authScopeHelpers"; | |||||
| import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper"; | |||||
| import { SCREENING_TESTS_FETCH,CREATE_SCREENING_TEST } from "../actions/screeningTests/screeningTestsActionConstants"; | |||||
| import { | |||||
| fetchScreeningTestsError, | |||||
| fetchScreeningTestsSuccess, | |||||
| createScreeningTestSuccess, | |||||
| createScreeningTestError, | |||||
| } from "../actions/screeningTests/screeningTestActions"; | |||||
| export function* getScreeningTests() { | |||||
| try { | |||||
| const JwtToken = yield call(authScopeStringGetHelper, JWT_TOKEN); | |||||
| yield call(addHeaderToken, JwtToken); | |||||
| const result = yield call(getTests); | |||||
| yield put(fetchScreeningTestsSuccess(result.data)); | |||||
| } catch (error) { | |||||
| if (error.response && error.response.data) { | |||||
| const errorMessage = yield call(rejectErrorCodeHelper, error); | |||||
| yield put(fetchScreeningTestsError(errorMessage)); | |||||
| } | |||||
| } | |||||
| } | |||||
| export function* createScreeningTest({ payload }) { | |||||
| try { | |||||
| const JwtToken = yield call(authScopeStringGetHelper, JWT_TOKEN); | |||||
| yield call(addHeaderToken, JwtToken); | |||||
| const result = yield call(createTest, payload); | |||||
| yield put(createScreeningTestSuccess(result.data)); | |||||
| } catch (error) { | |||||
| if (error.response && error.response.data) { | |||||
| const errorMessage = yield call(rejectErrorCodeHelper, error); | |||||
| yield put(createScreeningTestError(errorMessage)); | |||||
| } | |||||
| } | |||||
| } | |||||
| export default function* screeningTestsSaga() { | |||||
| yield all([takeEvery(SCREENING_TESTS_FETCH, getScreeningTests)]); | |||||
| yield all([takeEvery(CREATE_SCREENING_TEST, createScreeningTest)]); | |||||
| } |
| // export const selectAdsCandidates = createSelector( | |||||
| // adsCandidatesSelector, | |||||
| // (state) => state.adsCandidates, | |||||
| // ); | |||||
| import { createSelector } from "@reduxjs/toolkit"; | import { createSelector } from "@reduxjs/toolkit"; | ||||
| export const candidatesSelector = (state) => state.candidates; | export const candidatesSelector = (state) => state.candidates; |
| import { createSelector } from "@reduxjs/toolkit"; | |||||
| export const screeningTestsSelector = (state) => state.screeningTests; | |||||
| export const selectScreeningTests = createSelector( | |||||
| screeningTestsSelector, | |||||
| (state) => state.screeningTests | |||||
| ); | |||||
| export const selectScreeningTestsError = createSelector( | |||||
| screeningTestsSelector, | |||||
| (state) => state.errorMessage | |||||
| ); |