| Select, | Select, | ||||
| MenuItem, | MenuItem, | ||||
| TextField, | TextField, | ||||
| // TextField, | |||||
| } from "@mui/material"; | } from "@mui/material"; | ||||
| import IconButton from "../IconButton/IconButton"; | import IconButton from "../IconButton/IconButton"; | ||||
| import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker"; | import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker"; | ||||
| 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, fetchScreeningTests } from "../../store/actions/screeningTests/screeningTestActions"; | |||||
| import { | |||||
| createScreeningTest, | |||||
| fetchScreeningTests, | |||||
| } 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 [selectedScreeningTest, setSelectedScreeningTest] = useState(""); | ||||
| const [duration, setDuration] = useState(0); | |||||
| const { activeProcess, setActiveProcess } = useContext(SelectionContext); | const { activeProcess, setActiveProcess } = useContext(SelectionContext); | ||||
| } | } | ||||
| }; | }; | ||||
| useEffect(() => { | |||||
| setSelected(''); | |||||
| useEffect(() => { | |||||
| setSelected(""); | |||||
| setValue(null); | setValue(null); | ||||
| setSelectedScreeningTest("") | |||||
| setSelectedScreeningTest(""); | |||||
| setDuration(0); | |||||
| }, [onClose]); | }, [onClose]); | ||||
| useEffect(()=>{ | |||||
| if(activeProcess?.process.selectionLevelId === 2){ | |||||
| useEffect(() => { | |||||
| if (activeProcess?.process.selectionLevelId === 2) { | |||||
| dispatch(fetchScreeningTests()); | dispatch(fetchScreeningTests()); | ||||
| } | } | ||||
| },[activeProcess]) | |||||
| }, [activeProcess]); | |||||
| const handleClose = () => { | const handleClose = () => { | ||||
| onClose(); | onClose(); | ||||
| }; | }; | ||||
| const submitHandler = () => { | const submitHandler = () => { | ||||
| console.log(selected) | |||||
| console.log(selected); | |||||
| if (activeProcess.process.selectionLevelId !== 2) { | if (activeProcess.process.selectionLevelId !== 2) { | ||||
| dispatch( | dispatch( | ||||
| setUpdateStatusReq({ | setUpdateStatusReq({ | ||||
| }) | }) | ||||
| ); | ); | ||||
| } | } | ||||
| }; | }; | ||||
| const apiSuccessScreeningTests = () => { | const apiSuccessScreeningTests = () => { | ||||
| const user = users.find(k => k.id === selected) | |||||
| const user = users.find((k) => k.id === selected); | |||||
| dispatch( | dispatch( | ||||
| createScreeningTest({ | createScreeningTest({ | ||||
| adminEmail: user.email, | adminEmail: user.email, | ||||
| email: activeProcess.process.applicant.email, | email: activeProcess.process.applicant.email, | ||||
| duration: 60, | |||||
| duration: Number.parseInt(duration), | |||||
| testId: parseInt(selectedScreeningTest), | testId: parseInt(selectedScreeningTest), | ||||
| url: "https:dzenis-meris.com", | url: "https:dzenis-meris.com", | ||||
| }) | }) | ||||
| </FormControl> | </FormControl> | ||||
| )} | )} | ||||
| {activeProcess !== null && | |||||
| activeProcess.process.selectionLevelId === 2 && ( | |||||
| <TextField | |||||
| name="duration" | |||||
| label={"Duration"} | |||||
| value={duration} | |||||
| onChange={(e) => setDuration(e.target.value)} | |||||
| fullWidth | |||||
| /> | |||||
| )} | |||||
| {/* {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" |