選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

InterviewDialog.js 6.0KB

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