You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InterviewerDialog.js 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import React, { useContext, useState } from "react";
  2. import PropTypes from "prop-types";
  3. import x from "../../assets/images/x.png";
  4. import {
  5. Dialog,
  6. DialogTitle,
  7. DialogActions,
  8. useMediaQuery,
  9. useTheme,
  10. DialogContent,
  11. FormControl,
  12. InputLabel,
  13. Select,
  14. MenuItem,
  15. // TextField,
  16. // TextField,
  17. } from "@mui/material";
  18. import IconButton from "../IconButton/IconButton";
  19. // import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
  20. import { useDispatch, useSelector } from "react-redux";
  21. // import { format, isValid } from "date-fns";
  22. // import { fetchInitProcess } from "../../store/actions/candidates/candidatesActions";
  23. import { useEffect } from "react";
  24. import { SelectionContext } from "../../context/SelectionContext";
  25. import { setUpdateInterviewerReq } from "../../store/actions/processes/processAction";
  26. import { useTranslation } from "react-i18next";
  27. // import { setUpdateStatusReq } from "../../store/actions/processes/processAction";
  28. const InterviewerDialog = ({
  29. title,
  30. subtitle,
  31. imgSrc,
  32. onClose,
  33. open,
  34. maxWidth,
  35. fullWidth,
  36. responsive,
  37. }) => {
  38. const { activeInterview, setActiveInterview } = useContext(SelectionContext);
  39. const [selected, setSelected] = useState("");
  40. const {t} = useTranslation()
  41. const theme = useTheme();
  42. const fullScreen = useMediaQuery(theme.breakpoints.down("md"));
  43. const { users } = useSelector((s) => s.users);
  44. const { isSuccess } = useSelector((s) => s.interviewerUpdate);
  45. const dispatch = useDispatch();
  46. useEffect(() => {
  47. handleClose();
  48. }, [dispatch, isSuccess]);
  49. useEffect(() => {
  50. setSelected("");
  51. }, [onClose]);
  52. const handleClose = () => {
  53. onClose();
  54. };
  55. const submitHandler = () => {
  56. dispatch(
  57. setUpdateInterviewerReq({
  58. data: {
  59. schedulerId: selected,
  60. processId: activeInterview.id,
  61. },
  62. responseHandler: apiSuccess,
  63. })
  64. );
  65. };
  66. const apiSuccess = () => {
  67. setActiveInterview(null);
  68. // console.log("ok");
  69. };
  70. return (
  71. <Dialog
  72. maxWidth={maxWidth}
  73. keepMounted={false}
  74. fullWidth={fullWidth}
  75. fullScreen={responsive && fullScreen}
  76. onClose={handleClose}
  77. open={open}
  78. style={{
  79. padding: "36px",
  80. }}
  81. >
  82. {/* {activeInterview?.id} */}
  83. <div style={{ padding: "36px" }}>
  84. <DialogTitle style={{ padding: 0 }}>
  85. {fullScreen ? (
  86. <>
  87. <div className="flex-center" style={{ justifyContent: "start" }}>
  88. <img
  89. style={{
  90. position: "relative",
  91. top: -0.25,
  92. paddingRight: "10px",
  93. }}
  94. src={imgSrc}
  95. />
  96. <h5 style={{ textAlign: "start" }}>{title}</h5>
  97. <div style={{ justifySelf: "stretch", flex: "1" }}></div>
  98. <IconButton onClick={onClose}>
  99. <img
  100. style={{
  101. position: "relative",
  102. top: -0.25,
  103. }}
  104. src={x}
  105. />
  106. </IconButton>
  107. </div>
  108. <p
  109. className="dialog-subtitle"
  110. style={{ paddingLeft: "23px", marginTop: "-10px" }}
  111. >
  112. | {subtitle}
  113. </p>
  114. </>
  115. ) : (
  116. <div
  117. className="flex-center"
  118. style={{ justifyContent: "space-between" }}
  119. >
  120. <div className="flex-center" style={{ justifyContent: "start" }}>
  121. <img
  122. style={{
  123. position: "relative",
  124. top: -0.25,
  125. paddingRight: "10px",
  126. }}
  127. src={imgSrc}
  128. />
  129. <h5>{title}</h5>
  130. <div className="vr"></div>
  131. <p className="dialog-subtitle">{subtitle}</p>
  132. </div>
  133. </div>
  134. )}
  135. </DialogTitle>
  136. <DialogContent>
  137. <form className="modal-content interviewDialog">
  138. <FormControl fullWidth>
  139. <InputLabel id="demo-simple-select-label">
  140. {t("dialogs.interviewerName2")}
  141. </InputLabel>
  142. <Select
  143. labelId="demo-simple-select-label"
  144. id="demo-simple-select"
  145. value={
  146. selected
  147. ? selected
  148. : activeInterview
  149. ? activeInterview.scheduler.id
  150. : ""
  151. }
  152. label="Ime intervjuera"
  153. onChange={(e) => {
  154. setSelected(e.target.value);
  155. }}
  156. >
  157. {users
  158. ? users.map(({ id, firstName, lastName }, index) => (
  159. <MenuItem
  160. key={index}
  161. sx={{ textAlign: "left" }}
  162. value={id}
  163. >
  164. {firstName} {lastName}
  165. </MenuItem>
  166. ))
  167. : ""}
  168. </Select>
  169. </FormControl>
  170. {/* {activeProcess.process && activeProcess.process.date ? <p>Proces ima zakazan termin</p> : ''} */}
  171. </form>
  172. </DialogContent>
  173. <DialogActions style={{ padding: 0, justifyContent: "space-between" }}>
  174. {!fullScreen ? (
  175. <IconButton
  176. data-testid="editbtn"
  177. className={`c-btn--primary-outlined interview-btn c-btn dialog-btn`}
  178. onClick={onClose}
  179. >
  180. {t("common.cancel")}
  181. </IconButton>
  182. ) : (
  183. ""
  184. )}
  185. <IconButton
  186. data-testid="editbtn"
  187. className={`c-btn--primary-outlined sm-full interview-btn c-btn dialog-btn`}
  188. onClick={submitHandler}
  189. >
  190. {t("common.confirm")}
  191. </IconButton>
  192. </DialogActions>
  193. </div>
  194. </Dialog>
  195. );
  196. };
  197. InterviewerDialog.propTypes = {
  198. title: PropTypes.any,
  199. subtitle: PropTypes.any,
  200. imgSrc: PropTypes.any,
  201. open: PropTypes.bool.isRequired,
  202. onClose: PropTypes.func.isRequired,
  203. maxWidth: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"]),
  204. fullWidth: PropTypes.bool,
  205. responsive: PropTypes.bool,
  206. };
  207. export default InterviewerDialog;