Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

InterviewDialog.js 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import React, { 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. const InterviewDialog = ({
  25. title,
  26. subtitle,
  27. imgSrc,
  28. onClose,
  29. open,
  30. maxWidth,
  31. fullWidth,
  32. responsive,
  33. }) => {
  34. const [selected, setSelected] = useState("");
  35. const [selectedInterviewer, setSelectedInterviewer] = useState("");
  36. const [value, setValue] = useState(null);
  37. const theme = useTheme();
  38. const fullScreen = useMediaQuery(theme.breakpoints.down("md"));
  39. const { options } = useSelector((n) => n.options);
  40. const { users } = useSelector((n) => n.users);
  41. // const { user } = useSelector((s) => s.user);
  42. const { isSuccess } = useSelector((s) => s.initProcess);
  43. const dispatch = useDispatch();
  44. useEffect(() => {
  45. handleClose();
  46. }, [dispatch, isSuccess]);
  47. const handleChange = (newValue) => {
  48. if (isValid(newValue)) {
  49. // throws an error if invalid value is set
  50. var date = format(newValue, "yyyy-MM-dd'T'HH:mm:ss.SSSxxx");
  51. setValue(date);
  52. }
  53. };
  54. useEffect(() => {
  55. setSelected("");
  56. setSelectedInterviewer("");
  57. setValue(null);
  58. }, [onClose]);
  59. const handleClose = () => {
  60. onClose();
  61. };
  62. console.log(selectedInterviewer)
  63. const submitHandler = () => {
  64. dispatch(
  65. fetchInitProcess({
  66. model: {
  67. schedulerId: selectedInterviewer,
  68. appointment: value,
  69. applicantId: selected,
  70. },
  71. })
  72. );
  73. };
  74. return (
  75. <Dialog
  76. maxWidth={maxWidth}
  77. keepMounted={false}
  78. fullWidth={fullWidth}
  79. fullScreen={responsive && fullScreen}
  80. onClose={handleClose}
  81. open={open}
  82. style={{
  83. padding: "36px",
  84. }}
  85. >
  86. <div style={{ padding: "36px" }}>
  87. <DialogTitle style={{ padding: 0 }}>
  88. {fullScreen ? (
  89. <>
  90. <div className="flex-center" style={{ justifyContent: "start" }}>
  91. <img
  92. style={{
  93. position: "relative",
  94. top: -0.25,
  95. paddingRight: "10px",
  96. }}
  97. src={imgSrc}
  98. />
  99. <h5 style={{ textAlign: "start" }}>{title}</h5>
  100. <div style={{ justifySelf: "stretch", flex: "1" }}></div>
  101. <IconButton onClick={onClose}>
  102. <img
  103. style={{
  104. position: "relative",
  105. top: -0.25,
  106. }}
  107. src={x}
  108. />
  109. </IconButton>
  110. </div>
  111. <p
  112. className="dialog-subtitle"
  113. style={{ paddingLeft: "23px", marginTop: "-10px" }}
  114. >
  115. | {subtitle}
  116. </p>
  117. </>
  118. ) : (
  119. <div
  120. className="flex-center"
  121. style={{ justifyContent: "space-between" }}
  122. >
  123. <div className="flex-center" style={{ justifyContent: "start" }}>
  124. <img
  125. style={{
  126. position: "relative",
  127. top: -0.25,
  128. paddingRight: "10px",
  129. }}
  130. src={imgSrc}
  131. />
  132. <h5>{title}</h5>
  133. <div className="vr"></div>
  134. <p className="dialog-subtitle">{subtitle}</p>
  135. </div>
  136. </div>
  137. )}
  138. </DialogTitle>
  139. <DialogContent>
  140. <form className="modal-content interviewDialog">
  141. <FormControl fullWidth>
  142. <InputLabel id="demo-simple-select-label">
  143. Ime kandidata
  144. </InputLabel>
  145. <Select
  146. labelId="demo-simple-select-label"
  147. id="demo-simple-select"
  148. value={selected}
  149. label="Ime kandidata"
  150. onChange={(e) => {
  151. setSelected(e.target.value);
  152. }}
  153. >
  154. {options
  155. ? options.map(
  156. ({ applicantId, firstName, lastName }, index) => (
  157. <MenuItem
  158. key={index}
  159. sx={{ textAlign: "left" }}
  160. value={applicantId}
  161. >
  162. {firstName} {lastName}
  163. </MenuItem>
  164. )
  165. )
  166. : ""}
  167. </Select>
  168. </FormControl>
  169. <FormControl fullWidth>
  170. <InputLabel id="demo-simple-select-label">
  171. Ime intervjuera (opciono)
  172. </InputLabel>
  173. <Select
  174. labelId="demo-simple-select-label"
  175. id="demo-simple-select"
  176. value={selectedInterviewer}
  177. label="Ime intervjuera (opciono)"
  178. onChange={(e) => {
  179. setSelectedInterviewer(e.target.value);
  180. }}
  181. >
  182. {users
  183. ? users.map(({ id, firstName, lastName }, index) => (
  184. <MenuItem
  185. key={index}
  186. sx={{ textAlign: "left" }}
  187. value={id}
  188. >
  189. {firstName} {lastName}
  190. </MenuItem>
  191. ))
  192. : ""}
  193. </Select>
  194. </FormControl>
  195. <DateTimePicker
  196. label="Termin (opciono)"
  197. value={value}
  198. onChange={handleChange}
  199. renderInput={(params) => <TextField {...params} />}
  200. />
  201. </form>
  202. </DialogContent>
  203. <DialogActions style={{ padding: 0, justifyContent: "space-between" }}>
  204. {!fullScreen ? (
  205. <IconButton
  206. data-testid="editbtn"
  207. className={`c-btn--primary-outlined interview-btn c-btn dialog-btn`}
  208. onClick={onClose}
  209. >
  210. Cancel
  211. </IconButton>
  212. ) : (
  213. ""
  214. )}
  215. <IconButton
  216. data-testid="editbtn"
  217. className={`c-btn--primary-outlined sm-full interview-btn c-btn dialog-btn`}
  218. onClick={submitHandler}
  219. >
  220. Confirm
  221. </IconButton>
  222. </DialogActions>
  223. </div>
  224. </Dialog>
  225. );
  226. };
  227. InterviewDialog.propTypes = {
  228. title: PropTypes.any,
  229. subtitle: PropTypes.any,
  230. imgSrc: PropTypes.any,
  231. open: PropTypes.bool.isRequired,
  232. onClose: PropTypes.func.isRequired,
  233. maxWidth: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"]),
  234. fullWidth: PropTypes.bool,
  235. responsive: PropTypes.bool,
  236. };
  237. export default InterviewDialog;