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.

SelectionProcessOfApplicantPage.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import React, { useEffect, useRef } from "react";
  2. import arrow_left from "../../assets/images/arrow_left.png";
  3. import arrow_right from "../../assets/images/arrow_right.png";
  4. import { useParams } from "react-router-dom";
  5. import { useTranslation } from "react-i18next";
  6. import { Link } from "react-router-dom";
  7. import { useDispatch } from "react-redux";
  8. import { useSelector } from "react-redux";
  9. import Slider from "react-slick";
  10. import "slick-carousel/slick/slick.css";
  11. import "slick-carousel/slick/slick-theme.css";
  12. import { useTheme } from "@emotion/react";
  13. import { useMediaQuery } from "@mui/material";
  14. import ApplicantSelection from "../../components/Selection/ApplicantSelection";
  15. import { setProcessesReq } from "../../store/actions/processes/processesAction";
  16. import { selectProcesses } from "../../store/selectors/processesSelectors";
  17. import { selectApplicant } from "../../store/selectors/applicantWithProcessSelector";
  18. import { setApplicantReq } from "../../store/actions/processes/applicantAction";
  19. import parse from "html-react-parser";
  20. const SelectionProcessOfApplicantPage = () => {
  21. const theme = useTheme();
  22. const matches = useMediaQuery(theme.breakpoints.down("sm"));
  23. const applicant = useSelector(selectApplicant);
  24. const processes = applicant?.selectionProcesses;
  25. const levels = useSelector(selectProcesses);
  26. const { id } = useParams();
  27. const activeAdsSliderRef = useRef();
  28. const { t } = useTranslation();
  29. const dispatch = useDispatch();
  30. useEffect(() => {
  31. dispatch(setApplicantReq(id));
  32. dispatch(setProcessesReq());
  33. }, []);
  34. var settings = {
  35. dots: false,
  36. infinite: false,
  37. speed: 500,
  38. initialSlide: 0,
  39. responsive: [
  40. {
  41. breakpoint: 1024,
  42. settings: {
  43. slidesToShow: 4,
  44. slidesToScroll: 4,
  45. infinite: true,
  46. dots: false,
  47. },
  48. },
  49. {
  50. breakpoint: 900,
  51. settings: {
  52. slidesToShow: 3,
  53. slidesToScroll: 3,
  54. initialSlide: 0,
  55. },
  56. },
  57. {
  58. breakpoint: 480,
  59. settings: {
  60. slidesToShow: 1,
  61. slidesToScroll: 1,
  62. },
  63. },
  64. ],
  65. };
  66. const activeAdsArrowLeftHandler = () => {
  67. activeAdsSliderRef.current.slickPrev();
  68. };
  69. const activeAdsArrowRightHandler = () => {
  70. activeAdsSliderRef.current.slickNext();
  71. };
  72. const concatLevels = () => {
  73. const applicantSelections = [];
  74. for (var i = processes.length; i < levels.length; i++) {
  75. applicantSelections.push(
  76. <ApplicantSelection
  77. levelNumber={levels[i].id}
  78. levelName={levels[i].name}
  79. schedguler={""}
  80. date={""}
  81. status={"Čeka na zakazivanje"}
  82. id={id}
  83. key={i}
  84. />
  85. );
  86. }
  87. applicantSelections.push(
  88. <ApplicantSelection key={i} className="hiddenAd" date={""} />
  89. );
  90. return applicantSelections;
  91. };
  92. console.log(processes);
  93. console.log(applicant?.selectionProcesses);
  94. return (
  95. <>
  96. <div className="l-t-rectangle"></div>
  97. <div className="r-b-rectangle"></div>
  98. {/* <AdFilters /> */}
  99. <div className="ads">
  100. {processes && processes.length > 0 && (
  101. <div className="active-ads">
  102. <div className="active-ads-header">
  103. <h1>
  104. {t("selection.title")}
  105. <span className="level-header-spliter">|</span>
  106. <span className="level-header-subheader">
  107. {applicant.firstName + " " + applicant.lastName}
  108. </span>
  109. </h1>
  110. </div>
  111. <div className="active-ads-ads">
  112. <div className="active-ads-ads-a">
  113. {!matches && (
  114. <div className="active-ads-ads-arrows">
  115. <button onClick={activeAdsArrowLeftHandler}>
  116. <img src={arrow_left} alt="arrow-left" />
  117. </button>
  118. <button onClick={activeAdsArrowRightHandler}>
  119. <img src={arrow_right} alt="arrow-right" />
  120. </button>
  121. </div>
  122. )}
  123. </div>
  124. <div className="active-ads-ads-ad">
  125. <Slider
  126. {...settings}
  127. slidesToShow={4}
  128. slidesToScroll={4}
  129. style={{ width: "100%" }}
  130. ref={activeAdsSliderRef}
  131. >
  132. {processes.map((process, index) => {
  133. return (
  134. <ApplicantSelection
  135. levelNumber={index + 1}
  136. levelName={process.selectionLevel.name}
  137. schedguler={
  138. process?.scheduler
  139. ? `${process?.scheduler?.firstName} ${process?.scheduler?.lastName}`
  140. : "Proces nema intervjuera."
  141. }
  142. link={process.link}
  143. date={new Date(process.date)}
  144. status={process.status}
  145. id={id}
  146. key={index}
  147. className={
  148. index === processes.length - 1 ? "active-process" : ""
  149. }
  150. />
  151. );
  152. })}
  153. {processes.length <= levels.length && concatLevels()}
  154. </Slider>
  155. </div>
  156. </div>
  157. </div>
  158. )}
  159. {matches && (
  160. <div className="active-ads-ads-arrows">
  161. <button onClick={activeAdsArrowLeftHandler}>
  162. <img src={arrow_left} alt="arrow-left" />
  163. </button>
  164. <button onClick={activeAdsArrowRightHandler}>
  165. <img src={arrow_right} alt="arrow-right" />
  166. </button>
  167. </div>
  168. )}
  169. <div className="active-process-tip">
  170. <h3>
  171. {applicant?.selectionProcesses?.some(
  172. (n) => n.status === "Neuspešno"
  173. )
  174. ? "Komentar:"
  175. : t("selection.tipHeader")}
  176. </h3>
  177. <p>
  178. {/* {processes?.some(n => n.status === "Neuspešno") && parse(processes?.comment)} */}
  179. {applicant?.selectionProcesses?.some(
  180. (n) => n.status === "Neuspešno"
  181. )
  182. ? parse(
  183. applicant?.selectionProcesses.find(
  184. (n) => n.status === "Neuspešno"
  185. ).comment
  186. )
  187. : t("selection.tipBody")}
  188. {/* {t("selection.tipBody")} */}
  189. </p>
  190. </div>
  191. </div>
  192. <div className="add-ad">
  193. <Link className="ad-details-buttons-link" to="/selectionFlow">
  194. Nazad na sve kandidate
  195. </Link>
  196. </div>
  197. </>
  198. );
  199. };
  200. export default SelectionProcessOfApplicantPage;