| @@ -64,6 +64,8 @@ h3 { | |||
| cursor: pointer; | |||
| } | |||
| .active-ads-ads-no-ads { | |||
| position: relative; | |||
| width: 100% !important; | |||
| height: 75vh; | |||
| display: flex; | |||
| flex-direction: column; | |||
| @@ -85,6 +87,12 @@ h3 { | |||
| margin-bottom: 36px !important; | |||
| } | |||
| .active-ads-ads-no-ads-filters { | |||
| position: absolute; | |||
| right: 72px; | |||
| top: 0; | |||
| } | |||
| .active-ads-ads-ad { | |||
| padding-left: 81px; | |||
| display: flex; | |||
| @@ -15,6 +15,9 @@ import arrow_left from "../../assets/images/arrow_left.png"; | |||
| import arrow_right from "../../assets/images/arrow_right.png"; | |||
| import AdDetailsCandidateCard from "../../components/Ads/AdDetailsCandidateCard"; | |||
| import { selectLogo } from "../../util/helpers/technologiesLogos"; | |||
| import { archiveActiveAdReq } from "../../store/actions/archiveActiveAd/archiveActiveAdActions"; | |||
| import { ADS_PAGE } from "../../constants/pages"; | |||
| import { useHistory } from "react-router-dom"; | |||
| const AdDetailsPage = () => { | |||
| const theme = useTheme(); | |||
| @@ -24,6 +27,7 @@ const AdDetailsPage = () => { | |||
| const dispatch = useDispatch(); | |||
| const { t } = useTranslation(); | |||
| const archiveAdsSliderRef = useRef(); | |||
| const history = useHistory(); | |||
| useEffect(() => { | |||
| dispatch(setAdReq({ id })); | |||
| @@ -62,6 +66,14 @@ const AdDetailsPage = () => { | |||
| ], | |||
| }; | |||
| const navigateToAds = () => { | |||
| history.push(ADS_PAGE); | |||
| }; | |||
| const archiveAdHandler = () => { | |||
| dispatch(archiveActiveAdReq({ id, navigateToAds })); | |||
| }; | |||
| const archiveAdsArrowLeftHandler = () => { | |||
| archiveAdsSliderRef.current.slickPrev(); | |||
| }; | |||
| @@ -215,9 +227,19 @@ const AdDetailsPage = () => { | |||
| <Link className="ad-details-buttons-link" to="/ads"> | |||
| Nazad na sve oglase | |||
| </Link> | |||
| <IconButton className="c-btn c-btn--primary add-ad-btn"> | |||
| PRIJAVI SE | |||
| </IconButton> | |||
| {!(new Date(ad.expiredAt) < new Date()) && ( | |||
| <IconButton | |||
| className="c-btn c-btn--primary add-ad-btn" | |||
| onClick={archiveAdHandler} | |||
| > | |||
| ARCHIVE AD | |||
| </IconButton> | |||
| )} | |||
| {!(new Date(ad.expiredAt) < new Date()) && ( | |||
| <IconButton className="c-btn c-btn--primary add-ad-btn"> | |||
| PRIJAVI SE | |||
| </IconButton> | |||
| )} | |||
| </div> | |||
| </div> | |||
| )} | |||
| @@ -135,10 +135,10 @@ const AdsPage = ({ history }) => { | |||
| archiveAdsSliderRef.current.slickNext(); | |||
| }; | |||
| const deleteFiltersHandler = () => { | |||
| history.push("/ads"); | |||
| dispatch(setAdsReq()); | |||
| }; | |||
| // const deleteFiltersHandler = () => { | |||
| // history.push("/ads"); | |||
| // dispatch(setAdsReq()); | |||
| // }; | |||
| const getDummyAds = (len) => { | |||
| const ads = []; | |||
| @@ -233,6 +233,9 @@ const AdsPage = ({ history }) => { | |||
| )} | |||
| {(!ads || ads.length === 0) && ( | |||
| <div className="active-ads-ads-no-ads"> | |||
| <div className="active-ads-ads-no-ads-filters"> | |||
| <FilterButton onShowFilters={handleToggleFiltersDrawer} /> | |||
| </div> | |||
| <img src={noActiveAds} alt="noActiveAds" /> | |||
| <h1>Nažalost, trenutno nema aktivnih oglasa</h1> | |||
| <p>Uvek možete dodati novi u samo par jednostavnih koraka</p> | |||
| @@ -244,16 +247,6 @@ const AdsPage = ({ history }) => { | |||
| Dodaj Oglas | |||
| </IconButton> | |||
| </div> | |||
| {search && ( | |||
| <div> | |||
| <IconButton | |||
| className="c-btn c-btn--primary delete-filters-btn" | |||
| onClick={deleteFiltersHandler} | |||
| > | |||
| Obrisite filtere | |||
| </IconButton> | |||
| </div> | |||
| )} | |||
| </div> | |||
| )} | |||
| {archiveAds && archiveAds.length > 0 && ( | |||
| @@ -1,4 +1,4 @@ | |||
| import { getRequest, postRequest } from "."; | |||
| import { getRequest, postRequest, putRequest } from "."; | |||
| import apiEndpoints from "./apiEndpoints"; | |||
| export const getAllAds = () => getRequest(apiEndpoints.ads.allAds); | |||
| @@ -17,3 +17,8 @@ export const getAllArchiveAds = () => | |||
| export const getAdDetailsById = (id) => | |||
| getRequest(`${apiEndpoints.ads.adDetails}/${id}`); | |||
| export const createNewAd = (ad) => postRequest(apiEndpoints.ads.createAd, ad); | |||
| export const archiveActiveAdRequest = (payload) => | |||
| putRequest( | |||
| apiEndpoints.ads.archiveActiveAd.replace(":id", payload.id), | |||
| payload | |||
| ); | |||
| @@ -9,15 +9,15 @@ export default { | |||
| forgetPassword: base + "/authentications/ForgotPassword", | |||
| resetPassword: base + "/authentications/RessetPassword", | |||
| }, | |||
| users:{ | |||
| allUsers: base + '/users', | |||
| user: base + '/users/{id}', | |||
| toggleEnabled: base + '/users/toggleEnable/{id}', | |||
| invite: base + '/users/invite', | |||
| users: { | |||
| allUsers: base + "/users", | |||
| user: base + "/users/{id}", | |||
| toggleEnabled: base + "/users/toggleEnable/{id}", | |||
| invite: base + "/users/invite", | |||
| }, | |||
| candidates: { | |||
| filteredCandidates:base + "/applicants", | |||
| allFilteredAdsCandidates: base + "/applicants/adsApplicants" | |||
| filteredCandidates: base + "/applicants", | |||
| allFilteredAdsCandidates: base + "/applicants/adsApplicants", | |||
| }, | |||
| ads: { | |||
| allAds: base + "/ads", | |||
| @@ -25,6 +25,7 @@ export default { | |||
| allFilteredAds: base + "/ads/filtered", | |||
| allArchiveAds: base + "/ads/archive", | |||
| adDetails: base + "/ads/details", | |||
| archiveActiveAd: base + "/ads/archive-active-ad/:id", | |||
| }, | |||
| technologies: { | |||
| allTechnologies: base + "/technologies", | |||
| @@ -46,10 +47,10 @@ export default { | |||
| createPattern: base + "/patterns", | |||
| updatePattern: base + "/patterns/:id", | |||
| }, | |||
| stats:{ | |||
| stats: base + "/stats" | |||
| stats: { | |||
| stats: base + "/stats", | |||
| }, | |||
| schedule: { | |||
| specificSchedule: base + "/schedule", | |||
| }, | |||
| schedule:{ | |||
| specificSchedule:base + "/schedule" | |||
| } | |||
| }; | |||
| @@ -0,0 +1,13 @@ | |||
| import { | |||
| createFetchType, | |||
| createSuccessType, | |||
| createErrorType, | |||
| } from "../actionHelpers"; | |||
| const ARCHIVE_ACTIVE_AD_SCOPE = "ARCHIVE_ACTIVE_AD"; | |||
| export const ARCHIVE_ACTIVE_AD_REQ = createFetchType(ARCHIVE_ACTIVE_AD_SCOPE); | |||
| export const ARCHIVE_ACTIVE_AD_ERR = createErrorType(ARCHIVE_ACTIVE_AD_SCOPE); | |||
| export const ARCHIVE_ACTIVE_AD_SUCCESS = createSuccessType( | |||
| ARCHIVE_ACTIVE_AD_SCOPE | |||
| ); | |||
| @@ -0,0 +1,20 @@ | |||
| import { | |||
| ARCHIVE_ACTIVE_AD_REQ, | |||
| ARCHIVE_ACTIVE_AD_ERR, | |||
| ARCHIVE_ACTIVE_AD_SUCCESS, | |||
| } from "./archiveActiveAdActionConstants"; | |||
| export const archiveActiveAdReq = (payload) => ({ | |||
| type: ARCHIVE_ACTIVE_AD_REQ, | |||
| payload, | |||
| }); | |||
| export const archiveActiveAdError = (payload) => ({ | |||
| type: ARCHIVE_ACTIVE_AD_ERR, | |||
| payload, | |||
| }); | |||
| export const archiveActiveAd = (payload) => ({ | |||
| type: ARCHIVE_ACTIVE_AD_SUCCESS, | |||
| payload, | |||
| }); | |||
| @@ -0,0 +1,30 @@ | |||
| import { | |||
| ARCHIVE_ACTIVE_AD_SUCCESS, | |||
| ARCHIVE_ACTIVE_AD_ERR, | |||
| } from "../../actions/archiveActiveAd/archiveActiveAdActionConstants"; | |||
| import createReducer from "../../utils/createReducer"; | |||
| const initialState = { | |||
| errorMessage: "", | |||
| }; | |||
| export default createReducer( | |||
| { | |||
| [ARCHIVE_ACTIVE_AD_SUCCESS]: setArchiveActiveAd, | |||
| [ARCHIVE_ACTIVE_AD_ERR]: setArchiveActiveAdErrorMessage, | |||
| }, | |||
| initialState | |||
| ); | |||
| function setArchiveActiveAd(state) { | |||
| return { | |||
| ...state, | |||
| }; | |||
| } | |||
| function setArchiveActiveAdErrorMessage(state, action) { | |||
| return { | |||
| ...state, | |||
| errorMessage: action.payload, | |||
| }; | |||
| } | |||
| @@ -24,6 +24,7 @@ import createPatternReducer from "./pattern/createPatternReducer"; | |||
| import updatePatternReducer from "./pattern/updatePatternReducer"; | |||
| import statsReducer from "./stats/statsReducer"; | |||
| import scheduleReducer from "./schedule/scheduleReducer"; | |||
| import archiveActiveAdReducer from "./ad/archiveActiveAdReducer"; | |||
| export default combineReducers({ | |||
| login: loginReducer, | |||
| @@ -38,6 +39,7 @@ export default combineReducers({ | |||
| technologies: technologiesReducer, | |||
| addAdTechnologies: addAddTechnologiesReducer, | |||
| createAd: createAdReducer, | |||
| archiveActiveAd: archiveActiveAdReducer, | |||
| candidates: candidatesReducer, | |||
| processes: processesReducer, | |||
| process: processReducer, | |||
| @@ -5,6 +5,7 @@ import { | |||
| getAllArchiveAds, | |||
| getAllFilteredAds, | |||
| createNewAd, | |||
| archiveActiveAdRequest, | |||
| } from "../../request/adsRequest"; | |||
| import { | |||
| setAds, | |||
| @@ -22,10 +23,16 @@ import { FETCH_FILTERED_ADS_REQ } from "../actions/ads/adsActionConstants"; | |||
| import { FETCH_AD_REQ } from "../actions/ad/adActionConstants"; | |||
| import { FETCH_ARCHIVE_ADS_REQ } from "../actions/archiveAds/archiveAdsActionConstants"; | |||
| import { CREATE_AD_REQ } from "../actions/createAd/createAdActionConstants"; | |||
| import { ARCHIVE_ACTIVE_AD_REQ } from "../actions/archiveActiveAd/archiveActiveAdActionConstants"; | |||
| import { | |||
| setCreateAd, | |||
| setCreateAdError, | |||
| } from "../actions/createAd/createAdActions"; | |||
| import { authScopeStringGetHelper } from "../../util/helpers/authScopeHelpers"; | |||
| import { JWT_TOKEN } from "../../constants/localStorage"; | |||
| import { addHeaderToken } from "../../request"; | |||
| import { rejectErrorCodeHelper } from "../../util/helpers/rejectErrorCodeHelper"; | |||
| import { archiveActiveAd, archiveActiveAdError } from "../actions/archiveActiveAd/archiveActiveAdActions"; | |||
| export function* getAds() { | |||
| try { | |||
| @@ -77,6 +84,25 @@ export function* createAd({ payload }) { | |||
| } | |||
| } | |||
| export function* archiveActiveAdSaga({ payload }) { | |||
| try { | |||
| const JwtToken = yield call(authScopeStringGetHelper, JWT_TOKEN); | |||
| yield call(addHeaderToken, JwtToken); | |||
| const { data } = yield call(archiveActiveAdRequest, payload); | |||
| yield put(archiveActiveAd(data)); | |||
| const resultAds = yield call(getAllAds); | |||
| yield put(setAds(resultAds.data)); | |||
| const resultArchiveAds = yield call(getAllArchiveAds); | |||
| yield put(setArchiveAds(resultArchiveAds.data)); | |||
| if(payload.navigateToAds){ | |||
| yield call(payload.navigateToAds) | |||
| } | |||
| } catch (error) { | |||
| const errorMessage = yield call(rejectErrorCodeHelper, error); | |||
| yield put(archiveActiveAdError(errorMessage)); | |||
| } | |||
| } | |||
| export default function* adsSaga() { | |||
| yield all([ | |||
| takeLatest(FETCH_ADS_REQ, getAds), | |||
| @@ -84,5 +110,6 @@ export default function* adsSaga() { | |||
| takeLatest(FETCH_AD_REQ, getAd), | |||
| takeLatest(FETCH_ARCHIVE_ADS_REQ, getArchiveAds), | |||
| takeLatest(CREATE_AD_REQ, createAd), | |||
| takeLatest(ARCHIVE_ACTIVE_AD_REQ, archiveActiveAdSaga), | |||
| ]); | |||
| } | |||