| let mockDispatch; | let mockDispatch; | ||||
| beforeEach(() => { | beforeEach(() => { | ||||
| // Mock useSelector hook | |||||
| spyOnUseSelector = jest.spyOn(redux, "useSelector"); | spyOnUseSelector = jest.spyOn(redux, "useSelector"); | ||||
| spyOnUseSelector | spyOnUseSelector | ||||
| .mockReturnValueOnce(mockState.candidates.adsCandidates) | .mockReturnValueOnce(mockState.candidates.adsCandidates) | ||||
| .mockReturnValueOnce(mockState.candidates.adsCandidates); | .mockReturnValueOnce(mockState.candidates.adsCandidates); | ||||
| // Mock useDispatch hook | |||||
| spyOnUseDispatch = jest.spyOn(redux, "useDispatch"); | spyOnUseDispatch = jest.spyOn(redux, "useDispatch"); | ||||
| // Mock dispatch function returned from useDispatch | |||||
| mockDispatch = jest.fn(); | mockDispatch = jest.fn(); | ||||
| spyOnUseDispatch.mockReturnValue(mockDispatch); | spyOnUseDispatch.mockReturnValue(mockDispatch); | ||||
| }); | }); | ||||
| it("should load and handle adsCandidates in case of success", async () => { | it("should load and handle adsCandidates in case of success", async () => { | ||||
| const dispatchedActions = []; | const dispatchedActions = []; | ||||
| const mockedCall = { data: mockState.technologies.technologies }; | |||||
| const mockedCall = { data: mockState.candidates.adsCandidates }; | |||||
| api.getFilteredAdsCandidates = jest.fn(() => Promise.resolve(mockedCall)); | api.getFilteredAdsCandidates = jest.fn(() => Promise.resolve(mockedCall)); | ||||
| const fakeStore = { | const fakeStore = { |
| import { mockState } from "../../mockState"; | import { mockState } from "../../mockState"; | ||||
| import { render } from "@testing-library/react"; | import { render } from "@testing-library/react"; | ||||
| import * as api from "../../request/candidatesRequest"; | import * as api from "../../request/candidatesRequest"; | ||||
| import * as api2 from '../../request/usersRequest'; | |||||
| import { runSaga } from "redux-saga"; | import { runSaga } from "redux-saga"; | ||||
| import { CANDIDATE_FETCH } from "../../store/actions/candidate/candidateActionConstants"; | import { CANDIDATE_FETCH } from "../../store/actions/candidate/candidateActionConstants"; | ||||
| import { FETCH_USERS_REQ } from "../../store/actions/users/usersActionConstants"; | import { FETCH_USERS_REQ } from "../../store/actions/users/usersActionConstants"; | ||||
| import { getSingleCandidate } from "../../store/saga/candidatesSaga"; | import { getSingleCandidate } from "../../store/saga/candidatesSaga"; | ||||
| import {getUsers} from '../../store/saga/usersSaga' | |||||
| import { | import { | ||||
| fetchCandidateSuccess, | fetchCandidateSuccess, | ||||
| fetchCandidateError, | fetchCandidateError, | ||||
| } from "../../store/actions/candidate/candidateActions"; | } from "../../store/actions/candidate/candidateActions"; | ||||
| import { | |||||
| setUsers, | |||||
| setUsersError | |||||
| } from "../../store/actions/users/usersActions"; | |||||
| import * as helper from "../../util/helpers/rejectErrorCodeHelper"; | import * as helper from "../../util/helpers/rejectErrorCodeHelper"; | ||||
| import CandidateDetailsPage from "../../pages/CandidatesPage/CandidateDetailsPage"; | import CandidateDetailsPage from "../../pages/CandidatesPage/CandidateDetailsPage"; | ||||
| it("should load and handle candidate in case of success", async () => { | it("should load and handle candidate in case of success", async () => { | ||||
| const dispatchedActions = []; | const dispatchedActions = []; | ||||
| helper.rejectErrorCodeHelper = jest.fn(() => "Server error"); | |||||
| const mockedCall = { data: mockState.candidate.candidate }; | const mockedCall = { data: mockState.candidate.candidate }; | ||||
| api.getCandidate = jest.fn(() => Promise.resolve(mockedCall)); | api.getCandidate = jest.fn(() => Promise.resolve(mockedCall)); | ||||
| ); | ); | ||||
| }); | }); | ||||
| it("should load and handle users in case of success", async () => { | |||||
| const dispatchedActions = []; | |||||
| const mockedCall = { data: mockState.users.users }; | |||||
| api2.getAllUsers = jest.fn(() => Promise.resolve(mockedCall)); | |||||
| const fakeStore = { | |||||
| getState: () => mockState.users.users, | |||||
| dispatch: (action) => dispatchedActions.push(action), | |||||
| }; | |||||
| await runSaga(fakeStore, getUsers).done; | |||||
| expect(api2.getAllUsers.mock.calls.length).toBe(1); | |||||
| expect(dispatchedActions).toContainEqual( | |||||
| setUsers(mockedCall.data) | |||||
| ); | |||||
| }); | |||||
| it("should handle candidate load errors in case of failure", async () => { | it("should handle candidate load errors in case of failure", async () => { | ||||
| const dispatchedActions = []; | const dispatchedActions = []; | ||||
| fetchCandidateError(error.response.data.message) | fetchCandidateError(error.response.data.message) | ||||
| ); | ); | ||||
| }); | }); | ||||
| it("should handle users load errors in case of failure", async () => { | |||||
| const dispatchedActions = []; | |||||
| helper.rejectErrorCodeHelper = jest.fn( | |||||
| () => mockState.users.fetchUsersErrorMessage | |||||
| ); | |||||
| const error = { | |||||
| response: { | |||||
| data: { message: mockState.users.fetchUsersErrorMessage }, | |||||
| }, | |||||
| }; | |||||
| api2.getAllUsers = jest.fn(() => Promise.reject(error)); | |||||
| const fakeStore = { | |||||
| getState: () => mockState.users.users, | |||||
| dispatch: (action) => dispatchedActions.push(action), | |||||
| }; | |||||
| await runSaga(fakeStore, getUsers).done; | |||||
| expect(api2.getAllUsers.mock.calls.length).toBe(1); | |||||
| expect(dispatchedActions).toContainEqual( | |||||
| setUsersError(error.response.data.message) | |||||
| ); | |||||
| }); | |||||
| }); | }); |
| it("should load and handle techonologies in case of success", async () => { | it("should load and handle techonologies in case of success", async () => { | ||||
| const dispatchedActions = []; | const dispatchedActions = []; | ||||
| helper.rejectErrorCodeHelper = jest.fn(()=> 'Server error') | |||||
| const mockedCall = { data: mockState.technologies.technologies }; | const mockedCall = { data: mockState.technologies.technologies }; | ||||
| api.getAllTechnologies = jest.fn(() => Promise.resolve(mockedCall)); | api.getAllTechnologies = jest.fn(() => Promise.resolve(mockedCall)); | ||||
| it("Should dispatch get schedule request when rendered", () => { | it("Should dispatch get schedule request when rendered", () => { | ||||
| render(cont); | render(cont); | ||||
| const date = new Date() | |||||
| expect(mockDispatch).toHaveBeenCalledWith({ | expect(mockDispatch).toHaveBeenCalledWith({ | ||||
| type: SCHEDULE_FETCH, | type: SCHEDULE_FETCH, | ||||
| payload: { | payload: { | ||||
| month: 12, | |||||
| year: 2022, | |||||
| month: date.getMonth() + 1, | |||||
| year: date.getFullYear(), | |||||
| }, | }, | ||||
| }); | }); | ||||
| }); | }); |
| import * as fc from "../../store/saga/candidatesSaga"; | import * as fc from "../../store/saga/candidatesSaga"; | ||||
| import { | import { | ||||
| filterCandidates, | |||||
| filterCandidatesSuccess, | |||||
| filterCandidatesError, | filterCandidatesError, | ||||
| } from "../../store/actions/candidates/candidatesActions"; | } from "../../store/actions/candidates/candidatesActions"; | ||||
| import { PAGE_SIZE_CANDIDATES } from "../../constants/keyCodeConstants"; | import { PAGE_SIZE_CANDIDATES } from "../../constants/keyCodeConstants"; | ||||
| await runSaga(fakeStore, fc.filterCandidates, {}).done; | await runSaga(fakeStore, fc.filterCandidates, {}).done; | ||||
| expect(api.getFilteredCandidates.mock.calls.length).toBe(1); | expect(api.getFilteredCandidates.mock.calls.length).toBe(1); | ||||
| expect(dispatchedActions[0].payload).toEqual( | |||||
| filterCandidates(mockedCall.data).payload | |||||
| expect(dispatchedActions).toContainEqual( | |||||
| filterCandidatesSuccess(mockedCall.data) | |||||
| ); | ); | ||||
| }); | }); | ||||
| import { render, fireEvent } from "@testing-library/react"; | |||||
| import { render, fireEvent, waitFor } from "@testing-library/react"; | |||||
| import * as redux from "react-redux"; | import * as redux from "react-redux"; | ||||
| import store from "../../store"; | import store from "../../store"; | ||||
| import { mockState } from "../../mockState"; | import { mockState } from "../../mockState"; | ||||
| ); | ); | ||||
| }); | }); | ||||
| it("Number of arrows (left and right) should be 0 because there is no more than 4 candidates in any of ads", () => { | |||||
| it("Number of candidates in slider (vissible and hidden) should be equal to the number of candidates which applied for ad", () => { | |||||
| const { container } = render(cont); | |||||
| expect( | |||||
| container | |||||
| .getElementsByClassName("ads-candidates")[0] | |||||
| .getElementsByClassName("slick-slide").length | |||||
| ).toBe(mockState.candidates.adsCandidates[0].applicants.length); | |||||
| }); | |||||
| it("Number of arrows (left and right) should be 1 because there is more than 4 candidates which applied for ad", () => { | |||||
| const { container } = render(cont); | const { container } = render(cont); | ||||
| expect( | expect( | ||||
| container.getElementsByClassName("active-ads-ads-arrows").length | container.getElementsByClassName("active-ads-ads-arrows").length | ||||
| ).toBe(0); | |||||
| ).toBe(1); | |||||
| }); | |||||
| it("After clicking on right arrow of first slider, first slider should show fifth candidate as forth card of slider", async () => { | |||||
| const { container } = render(cont); | |||||
| fireEvent.click( | |||||
| container | |||||
| .getElementsByClassName("active-ads-ads-arrows")[0] | |||||
| .getElementsByTagName("button")[1] | |||||
| ); | |||||
| await waitFor(() => | |||||
| expect( | |||||
| container | |||||
| .getElementsByClassName("ads-candidates")[0] | |||||
| .getElementsByClassName("slick-active")[3] | |||||
| .getElementsByClassName("candidate-card-container")[0] | |||||
| .getElementsByClassName("candidate-card-applicant-name")[0] | |||||
| .textContent | |||||
| ).toBe( | |||||
| mockState.candidates.adsCandidates[0].applicants[4].firstName + | |||||
| " " + | |||||
| mockState.candidates.adsCandidates[0].applicants[4].lastName | |||||
| ) | |||||
| ); | |||||
| }); | }); | ||||
| it("Should render candidate details page", () => { | |||||
| it("Should render candidate details page after clicking on candidate card", () => { | |||||
| const { container } = render(cont); | const { container } = render(cont); | ||||
| fireEvent.click( | fireEvent.click( | ||||
| container.getElementsByClassName("candidate-card-container")[0] | container.getElementsByClassName("candidate-card-container")[0] |
| import { render, screen, fireEvent } from "@testing-library/react"; | |||||
| import { render, screen, fireEvent, waitFor } from "@testing-library/react"; | |||||
| import * as redux from "react-redux"; | import * as redux from "react-redux"; | ||||
| import CandidatesPage from "../../pages/CandidatesPage/CandidatesPage"; | import CandidatesPage from "../../pages/CandidatesPage/CandidatesPage"; | ||||
| import store from "../../store"; | import store from "../../store"; | ||||
| beforeEach(() => { | beforeEach(() => { | ||||
| spyOnUseSelector = jest.spyOn(redux, "useSelector"); | spyOnUseSelector = jest.spyOn(redux, "useSelector"); | ||||
| spyOnUseSelector.mockReturnValueOnce(mockState.technologies.technologies) | |||||
| spyOnUseSelector.mockReturnValueOnce(mockState.technologies.technologies); | |||||
| }); | }); | ||||
| afterEach(() => { | afterEach(() => { | ||||
| ); | ); | ||||
| }); | }); | ||||
| // it("input for searching by name should be shown after clicking button for first time", () => { | |||||
| // it("input for searching by name should be shown after clicking button for first time", async () => { | |||||
| // const { container } = render(cont); | // const { container } = render(cont); | ||||
| // fireEvent.click(container.getElementsByClassName("candidate-btn")[1]); | // fireEvent.click(container.getElementsByClassName("candidate-btn")[1]); | ||||
| // expect(container.getElementsByClassName("proba")[0].style.visibility).toBe( | |||||
| // "vissible" | |||||
| // await waitFor(() => | |||||
| // expect( | |||||
| // container.getElementsByClassName("proba")[0].style.visibility | |||||
| // ).toBe("vissible") | |||||
| // ); | // ); | ||||
| // }); | // }); | ||||
| ).toBeDefined(); | ).toBeDefined(); | ||||
| }); | }); | ||||
| // it("should render AdsCandidatesPage component when button for switching to another view is clicked for the first time", () => { | |||||
| // it("should render AdsCandidatesPage component when button for switching to another view is clicked for the first time", async () => { | |||||
| // const { container } = render(cont); | // const { container } = render(cont); | ||||
| // fireEvent.click(container.getElementsByClassName("candidate-btn")[0]); | // fireEvent.click(container.getElementsByClassName("candidate-btn")[0]); | ||||
| // expect( | |||||
| // container.getElementsByClassName("ads-candidates-container")[0] | |||||
| // ).toBeDefined(); | |||||
| // await waitFor(() => | |||||
| // expect( | |||||
| // container.getElementsByClassName("ads-candidates-container")[0] | |||||
| // ).toBeDefined() | |||||
| // ); | |||||
| // }); | // }); | ||||
| }); | }); |
| expect(screen.getByTestId("day-component-dialog")).toBeDefined(); | expect(screen.getByTestId("day-component-dialog")).toBeDefined(); | ||||
| }); | }); | ||||
| it("Should render left arrow as disabled because we set that currenlty selected day is first day of month", () => { | |||||
| render(cont); | |||||
| expect( | |||||
| screen.getAllByTestId("day-datails-left-arrow")[0] | |||||
| ).toBeDefined(); | |||||
| }); | |||||
| it("Should render right arrow as enabled because we set that currenlty selected day is first day of month", () => { | |||||
| render(cont); | |||||
| expect( | |||||
| screen.getAllByTestId("day-datails-right-arrow")[0] | |||||
| ).toBeDefined(); | |||||
| }); | |||||
| it("Should show all interviews which we pass to component", () => { | it("Should show all interviews which we pass to component", () => { | ||||
| render(cont); | render(cont); | ||||
| expect(screen.getAllByTestId("day-details-component-process").length).toBe( | expect(screen.getAllByTestId("day-details-component-process").length).toBe( |
| import { render, screen, fireEvent } from "@testing-library/react"; | |||||
| import { render, screen, fireEvent,waitFor } from "@testing-library/react"; | |||||
| import * as redux from "react-redux"; | import * as redux from "react-redux"; | ||||
| import store from "../../store"; | import store from "../../store"; | ||||
| import { mockState } from "../../mockState"; | import { mockState } from "../../mockState"; | ||||
| import history from "../../store/utils/history"; | import history from "../../store/utils/history"; | ||||
| import TableViewPage from "../../pages/CandidatesPage/TableViewPage"; | import TableViewPage from "../../pages/CandidatesPage/TableViewPage"; | ||||
| import { PAGE_SIZE_CANDIDATES } from "../../constants/keyCodeConstants"; | import { PAGE_SIZE_CANDIDATES } from "../../constants/keyCodeConstants"; | ||||
| import * as requests from '../../request/candidatesRequest' | |||||
| describe("TableViewPage render tests", () => { | describe("TableViewPage render tests", () => { | ||||
| var props = { | |||||
| history: { | |||||
| replace: jest.fn(), | |||||
| push: jest.fn(), | |||||
| location: { | |||||
| pathname: "/candidates", | |||||
| }, | |||||
| }, | |||||
| }; | |||||
| const cont = ( | const cont = ( | ||||
| <redux.Provider store={store}> | <redux.Provider store={store}> | ||||
| <Router history={history}> | <Router history={history}> | ||||
| <TableViewPage search="" /> | |||||
| <TableViewPage search="" {...props} /> | |||||
| </Router> | </Router> | ||||
| </redux.Provider> | </redux.Provider> | ||||
| ); | ); | ||||
| ).toBeDefined(); | ).toBeDefined(); | ||||
| }); | }); | ||||
| it("Pagination component should show 1 page because number of elements of our candidates arrat is 2 and the size of page is 2)", () => { | |||||
| it("Here we check if our component is displaying as many pages as it should display", () => { | |||||
| const { container } = render(cont); | const { container } = render(cont); | ||||
| expect( | expect( | ||||
| container | container | ||||
| ); | ); | ||||
| }); | }); | ||||
| it("Table should initialy contain 2 rows", () => { | |||||
| it("The number of table rows should be equal to the number of candidates", () => { | |||||
| const { container } = render(cont); | const { container } = render(cont); | ||||
| expect(container.getElementsByClassName("cadidate-row").length).toBe( | expect(container.getElementsByClassName("cadidate-row").length).toBe( | ||||
| mockState.candidates.candidates.length | mockState.candidates.candidates.length | ||||
| ); | ); | ||||
| }); | }); | ||||
| it("Should render candidate details page after clicking on table row", () => { | |||||
| const { container } = render(cont); | |||||
| fireEvent.click(container.getElementsByClassName("cadidate-row")[0]); | |||||
| const arg = { pathname: "/candidates/1" }; | |||||
| expect(props.history.push).toHaveBeenCalledWith(arg); | |||||
| }); | |||||
| it("Initially CV of candidate isn't displayed", () => { | |||||
| const { container } = render(cont); | |||||
| expect(container.getElementsByClassName('candidates-cv')[0].style.opacity).toBe("0") | |||||
| }); | |||||
| // How to mock getCV() function ? | |||||
| // it("Should render CV of candidate after clicking on CV name", async () => { | |||||
| // const mockedCall = { data: mockState.candidates.adsCandidates }; | |||||
| // requests.getCV = {} | |||||
| // const { container } = render(cont); | |||||
| // fireEvent.click( | |||||
| // container | |||||
| // .getElementsByClassName("cadidate-row")[0] | |||||
| // .getElementsByTagName("td")[4] | |||||
| // .getElementsByTagName("span")[0] | |||||
| // ); | |||||
| // await waitFor(() => expect(container.getElementsByClassName('candidates-cv')[0].style.opacity).toBe("1")); | |||||
| // }); | |||||
| }); | }); |
| } | } | ||||
| .cls1 .slick-track { | .cls1 .slick-track { | ||||
| margin-left: 30px !important; | |||||
| margin-left: 35px !important; | |||||
| } | } | ||||
| .cls2 .slick-track { | .cls2 .slick-track { | ||||
| margin-left: 20 !important; | |||||
| margin-left: 20px !important; | |||||
| } | } | ||||
| .cls3 .slick-track { | .cls3 .slick-track { | ||||
| margin-left: 20 !important; | |||||
| margin-left: 0px !important; | |||||
| } | } | ||||
| .cls4 .slick-track { | .cls4 .slick-track { | ||||
| } | } | ||||
| .candidates-cv { | .candidates-cv { | ||||
| width: 695px; | |||||
| height: 595px; | |||||
| width: 500px; | |||||
| height: 610px; | |||||
| margin-right: 72px; | margin-right: 72px; | ||||
| margin-top: 37px; | |||||
| } | } | ||||
| @media only screen and (max-width: 600px) { | @media only screen and (max-width: 600px) { |
| }} | }} | ||||
| > | > | ||||
| {isLeftArrowDisabled === true ? ( | {isLeftArrowDisabled === true ? ( | ||||
| <div className="day-datails-arrow-container"> | |||||
| <div className="day-datails-arrow-container" data-testid="day-datails-left-arrow"> | |||||
| <img src={arrowLeftDisabled} /> | <img src={arrowLeftDisabled} /> | ||||
| </div> | </div> | ||||
| ) : ( | ) : ( | ||||
| <div | <div | ||||
| className="day-datails-arrow-container" | className="day-datails-arrow-container" | ||||
| onClick={goForwardOneDay} | onClick={goForwardOneDay} | ||||
| data-testid="day-datails-right-arrow" | |||||
| > | > | ||||
| <img src={arrowRight} /> | <img src={arrowRight} /> | ||||
| </div> | </div> |
| export const mockState = { | export const mockState = { | ||||
| user: { | user: { | ||||
| user: { | user: { | ||||
| id: 1, | id: 1, | ||||
| name: "HR intervju", | name: "HR intervju", | ||||
| }, | }, | ||||
| applicant: { | applicant: { | ||||
| applicantId: 1, | |||||
| applicantId: 11, | |||||
| firstName: "Dzenis", | firstName: "Dzenis", | ||||
| lastName: "Hadzifejzovic", | lastName: "Hadzifejzovic", | ||||
| }, | }, | ||||
| name: "HR intervju", | name: "HR intervju", | ||||
| }, | }, | ||||
| applicant: { | applicant: { | ||||
| applicantId: 25, | |||||
| applicantId: 22, | |||||
| firstName: "Meris", | firstName: "Meris", | ||||
| lastName: "Ahmatovic", | lastName: "Ahmatovic", | ||||
| }, | }, | ||||
| }, | }, | ||||
| ], | ], | ||||
| }, | }, | ||||
| { | |||||
| applicantId: 42, | |||||
| firstName: "Safet", | |||||
| lastName: "Purkovic", | |||||
| dateOfApplication: "2022-12-14T11:30:36.3658961", | |||||
| cv: "PDF", | |||||
| experience: 3, | |||||
| technologyApplicants: [ | |||||
| { | |||||
| technology: { | |||||
| technologyId: 1, | |||||
| technologyType: "Backend", | |||||
| name: ".NET", | |||||
| }, | |||||
| }, | |||||
| ], | |||||
| }, | |||||
| ], | ], | ||||
| nubmerOfApplicants: 4, | |||||
| nubmerOfApplicants: 5, | |||||
| }, | }, | ||||
| { | { | ||||
| id: 2, | id: 2, |
| dots: false, | dots: false, | ||||
| infinite: false, | infinite: false, | ||||
| speed: 400, | speed: 400, | ||||
| slidesToShow: 3, | |||||
| slidesToScroll: 3, | |||||
| slidesToShow: 4, | |||||
| slidesToScroll: 4, | |||||
| initialSlide: 0, | initialSlide: 0, | ||||
| arrows: true, | arrows: true, | ||||
| variableWidth: true, | variableWidth: true, | ||||
| { | { | ||||
| breakpoint: 1024, | breakpoint: 1024, | ||||
| settings: { | settings: { | ||||
| slidesToShow: 2, | |||||
| slidesToScroll: 2, | |||||
| slidesToShow: 3, | |||||
| slidesToScroll: 3, | |||||
| infinite: true, | infinite: true, | ||||
| dots: false, | dots: false, | ||||
| }, | }, | ||||
| { | { | ||||
| breakpoint: 900, | breakpoint: 900, | ||||
| settings: { | settings: { | ||||
| slidesToShow: 1, | |||||
| slidesToScroll: 1, | |||||
| slidesToShow: 2, | |||||
| slidesToScroll: 2, | |||||
| initialSlide: 0, | initialSlide: 0, | ||||
| }, | }, | ||||
| }, | }, | ||||
| <button onClick={() => activeAdsArrowLeftHandler(index)}> | <button onClick={() => activeAdsArrowLeftHandler(index)}> | ||||
| <img src={arrow_left} alt="arrow-left" /> | <img src={arrow_left} alt="arrow-left" /> | ||||
| </button> | </button> | ||||
| <button onClick={() => activeAdsArrowRightHandler(index)}> | |||||
| <button onClick={() => activeAdsArrowRightHandler(index)} className="kp"> | |||||
| <img src={arrow_right} alt="arrow-right" /> | <img src={arrow_right} alt="arrow-right" /> | ||||
| </button> | </button> | ||||
| </div> | </div> |
| const technologies = useSelector(selectTechnologies); | const technologies = useSelector(selectTechnologies); | ||||
| const [search, setSearch] = useState(""); | const [search, setSearch] = useState(""); | ||||
| const [isSearchFieldVisible, setIsSearchFieldVisible] = useState(false); | const [isSearchFieldVisible, setIsSearchFieldVisible] = useState(false); | ||||
| const [isCVDisplayed, setIsCVDisplayed] = useState(false); | |||||
| const [linkToCV, setLinkToCV] = useState(""); | |||||
| // const [isCVDisplayed, setIsCVDisplayed] = useState(false); | |||||
| // const [linkToCV, setLinkToCV] = useState(""); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| dispatch(setTechnologiesReq()); | dispatch(setTechnologiesReq()); | ||||
| page={page} | page={page} | ||||
| setPage={setPage} | setPage={setPage} | ||||
| search={search} | search={search} | ||||
| setIsCVDisplayed={setIsCVDisplayed} | |||||
| isCVDisplayed={isCVDisplayed} | |||||
| setLinkToCV={setLinkToCV} | |||||
| // setIsCVDisplayed={setIsCVDisplayed} | |||||
| // isCVDisplayed={isCVDisplayed} | |||||
| // setLinkToCV={setLinkToCV} | |||||
| /> | /> | ||||
| ) : ( | ) : ( | ||||
| <AdsCandidatesPage history={history} search={search} /> | <AdsCandidatesPage history={history} search={search} /> | ||||
| )} | )} | ||||
| {isTableView ? ( | |||||
| {/* {isTableView ? ( | |||||
| <Fade in={isCVDisplayed} timeout={400} className="candidates-cv"> | <Fade in={isCVDisplayed} timeout={400} className="candidates-cv"> | ||||
| <embed src={`data:application/pdf;base64,${linkToCV}`} /> | <embed src={`data:application/pdf;base64,${linkToCV}`} /> | ||||
| </Fade> | </Fade> | ||||
| ) : ( | ) : ( | ||||
| "" | "" | ||||
| )} | |||||
| )} */} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| ); | ); |
| import React, { useEffect } from "react"; | |||||
| import React, { useEffect, useState } from "react"; | |||||
| import Pagination from "@mui/material/Pagination"; | import Pagination from "@mui/material/Pagination"; | ||||
| import { formatDate } from "../../util/helpers/dateHelpers"; | import { formatDate } from "../../util/helpers/dateHelpers"; | ||||
| import { useDispatch, useSelector } from "react-redux"; | import { useDispatch, useSelector } from "react-redux"; | ||||
| selectPagination, | selectPagination, | ||||
| } from "../../store/selectors/candidatesSelectors"; | } from "../../store/selectors/candidatesSelectors"; | ||||
| import { getCV } from "../../request/candidatesRequest"; | import { getCV } from "../../request/candidatesRequest"; | ||||
| import Fade from "@mui/material/Fade"; | |||||
| const TableViewPage = ({ | const TableViewPage = ({ | ||||
| history, | history, | ||||
| setPage, | setPage, | ||||
| page, | page, | ||||
| search, | search, | ||||
| setIsCVDisplayed, | |||||
| isCVDisplayed, | |||||
| setLinkToCV, | |||||
| // setIsCVDisplayed, | |||||
| // isCVDisplayed, | |||||
| // setLinkToCV, | |||||
| }) => { | }) => { | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| const candidates = useSelector(selectCandidates); | const candidates = useSelector(selectCandidates); | ||||
| const pagination = useSelector(selectPagination); | const pagination = useSelector(selectPagination); | ||||
| const theme = useTheme(); | const theme = useTheme(); | ||||
| const matches = useMediaQuery(theme.breakpoints.down("361")); | const matches = useMediaQuery(theme.breakpoints.down("361")); | ||||
| const navigate = (applicantId) => { | |||||
| history.push({ | |||||
| pathname: CANDIDATES_PAGE + "/" + applicantId, | |||||
| state: { | |||||
| from: history.location.pathname, | |||||
| }, | |||||
| }); | |||||
| }; | |||||
| const [linkToCV, setLinkToCV] = useState(""); | |||||
| const [isCVDisplayed, setIsCVDisplayed] = useState(false); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| dispatch( | dispatch( | ||||
| .catch((e) => console.log(e)); | .catch((e) => console.log(e)); | ||||
| }; | }; | ||||
| const navigateToCandidateDetailsPage = (applicantId) => { | |||||
| history.push({ | |||||
| pathname: CANDIDATES_PAGE + "/" + applicantId, | |||||
| }); | |||||
| }; | |||||
| return ( | return ( | ||||
| <div className="candidates-table"> | <div className="candidates-table"> | ||||
| <div style={{ overflowX: "auto", marginLeft: matches ? 36 : 72 }}> | |||||
| <div | |||||
| style={{ | |||||
| overflowX: "auto", | |||||
| marginLeft: matches ? 36 : 72, | |||||
| display: "flex", | |||||
| justifyContent:'space-between' | |||||
| }} | |||||
| > | |||||
| <table | <table | ||||
| className="usersTable" | className="usersTable" | ||||
| style={{ width: isCVDisplayed ? "784px" : "914px" }} | style={{ width: isCVDisplayed ? "784px" : "914px" }} | ||||
| style={{ | style={{ | ||||
| cursor: "pointer", | cursor: "pointer", | ||||
| }} | }} | ||||
| onClick={() => navigate(candidate.applicantId)} | |||||
| onClick={() => | |||||
| navigateToCandidateDetailsPage(candidate.applicantId) | |||||
| } | |||||
| > | > | ||||
| <td> | <td> | ||||
| {( | {( | ||||
| ))} | ))} | ||||
| </tbody> | </tbody> | ||||
| </table> | </table> | ||||
| <Fade in={isCVDisplayed} timeout={400}> | |||||
| <embed src={`data:application/pdf;base64,${linkToCV}`} className="candidates-cv"/> | |||||
| </Fade> | |||||
| </div> | </div> | ||||
| <Pagination | <Pagination | ||||
| size={matches ? "small" : "medium"} | size={matches ? "small" : "medium"} | ||||
| setPage: PropTypes.func, | setPage: PropTypes.func, | ||||
| page: PropTypes.number, | page: PropTypes.number, | ||||
| search: PropTypes.string, | search: PropTypes.string, | ||||
| setIsCVDisplayed: PropTypes.func, | |||||
| isCVDisplayed: PropTypes.bool, | |||||
| setLinkToCV: PropTypes.func, | |||||
| // setIsCVDisplayed: PropTypes.func, | |||||
| // isCVDisplayed: PropTypes.bool, | |||||
| // setLinkToCV: PropTypes.func, | |||||
| }; | }; | ||||
| export default TableViewPage; | export default TableViewPage; |
| import { deleteRequest, getRequest, postRequest,downloadPdf } from "."; | |||||
| import { deleteRequest, getRequest, postRequest, downloadPdf } from "."; | |||||
| import apiEndpoints from "./apiEndpoints"; | import apiEndpoints from "./apiEndpoints"; | ||||
| export const getFilteredCandidates = (payload) => { | export const getFilteredCandidates = (payload) => { | ||||
| export const initializeProcessRequest = (payload) => | export const initializeProcessRequest = (payload) => | ||||
| postRequest(apiEndpoints.candidates.initProcess, payload); | postRequest(apiEndpoints.candidates.initProcess, payload); | ||||
| export const getCV = (fileName) => downloadPdf(apiEndpoints.applicant.getCV + "?fileName=" + fileName); | |||||
| export const getCV = (fileName) => | |||||
| downloadPdf(apiEndpoints.applicant.getCV + "?fileName=" + fileName); |