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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import { selectDoneProcessError } from "../../store/selectors/processSelectors";
  4. import { selectAuthUser } from "../../store/selectors/userSelectors"
  5. import { setDoneProcessReq } from "../../store/actions/processes/processAction";
  6. import { useDispatch, useSelector } from "react-redux";
  7. import { formatDateSrb, formatTimeSrb } from "../../util/helpers/dateHelpers";
  8. import { SELECTION_PROCESS_OF_APPLICANT_PAGE } from "../../constants/pages";
  9. const dragStart = (e, applicant) => {
  10. e.dataTransfer.setData("text/plain", JSON.stringify(applicant));
  11. }
  12. const dragOver = (e) => {
  13. e.preventDefault();
  14. }
  15. const Selection = (props) => {
  16. const applicants = props.selection.selectionProcesses;
  17. const errorMessage = useSelector(selectDoneProcessError);
  18. const dispatch = useDispatch();
  19. const user = useSelector(selectAuthUser);
  20. const dropItem = (e, selId) => {
  21. var data = e.dataTransfer.getData("text/plain");
  22. const selectionProcess = JSON.parse(data);
  23. if (selectionProcess.selectionLevelId < selId) {
  24. dispatch(setDoneProcessReq({
  25. id: selectionProcess.id,
  26. name: "radnom name",
  27. applicantId: selectionProcess.applicant.applicantId,
  28. schedulerId: user.id
  29. }));
  30. }
  31. if (errorMessage) {
  32. console.log(errorMessage)
  33. }
  34. }
  35. const handleOpenDetails = (id) => {
  36. props.history.push(SELECTION_PROCESS_OF_APPLICANT_PAGE.replace(":id", id))
  37. }
  38. const renderList = applicants?.map((item, index) => {
  39. return <div draggable key={index} className="sel-item" onDragStart={e => dragStart(e, item)}
  40. onClick={() => handleOpenDetails(item.applicant.applicantId)}>
  41. <div className="status">
  42. <button>{item.status}</button>
  43. </div>
  44. <div className="date-name">
  45. <div className="date">
  46. {item.date !== null && item.date !== "" && <p>{formatDateSrb(item.date)} <span className="grey">|</span> {formatTimeSrb(item.date)}</p>}
  47. </div>
  48. <div className="full-name">
  49. <p>{item.applicant.firstName + " " + item.applicant.lastName}</p>
  50. </div>
  51. </div>
  52. </div>
  53. }
  54. );
  55. return (
  56. <div dropppable="true" id={props.selection.id} className="selection-card"
  57. onDragOver={e => dragOver(e)}
  58. onDrop={e => dropItem(e, props.selection.id)}
  59. >
  60. <div className="selection-card-title">
  61. <h3>{props.selection.name}</h3>
  62. </div>
  63. {applicants.length > 0 && renderList}
  64. {applicants.length === 0 && <div className="sel-item">
  65. <div className="date">
  66. <p>Nema kandidata u selekciji</p>
  67. </div>
  68. </div>}
  69. </div>
  70. );
  71. };
  72. Selection.propTypes = {
  73. history: PropTypes.shape({
  74. replace: PropTypes.func,
  75. push: PropTypes.func,
  76. location: PropTypes.shape({
  77. pathname: PropTypes.string,
  78. }),
  79. }),
  80. selection: PropTypes.shape({
  81. id: PropTypes.number,
  82. name: PropTypes.string,
  83. selectionProcesses: PropTypes.arrayOf(PropTypes.shape({
  84. id: PropTypes.number,
  85. name: PropTypes.string,
  86. date: PropTypes.string,
  87. status: PropTypes.string,
  88. currentSelection: PropTypes.number,
  89. map: PropTypes.func,
  90. applicant: PropTypes.shape({
  91. firstName: PropTypes.string,
  92. lastName: PropTypes.string
  93. })
  94. }))
  95. }),
  96. };
  97. export default Selection;