| @@ -120,7 +120,7 @@ export default { | |||
| invite: "/users/invite", | |||
| getProfile: "users/", | |||
| editProfile: "users", | |||
| getAllProfiles: "users" | |||
| getAllProfiles: "users", | |||
| }, | |||
| applications: { | |||
| application: "/applications/{applicationUid}", | |||
| @@ -164,11 +164,12 @@ export default { | |||
| getOneOffer: "offers", | |||
| getOffers: "offers", | |||
| getFeaturedOffers: "offers/featured", | |||
| addOffer: "offers", | |||
| addOffer: "/users/{userId}/offers", | |||
| editOffer: "/users/{userId}/offers/{offerId}", | |||
| categories: "categories", | |||
| locations: "locations", | |||
| mineOffers: "users", | |||
| removeOffer: "offers", | |||
| removeOffer: "/users/{userId}/offers/{offerId}", | |||
| pinOffer: "offers/{id}/pin", | |||
| }, | |||
| chat: { | |||
| @@ -177,7 +178,7 @@ export default { | |||
| }, | |||
| exchange: { | |||
| getExchange: "exchanges", | |||
| validateExchange: "exchanges" | |||
| validateExchange: "exchanges", | |||
| }, | |||
| reviews: { | |||
| postReview: "reviews", | |||
| @@ -28,17 +28,32 @@ export const attemptFetchMoreOffers = (page, payload) => { | |||
| ); | |||
| return getRequest(apiEndpoints.offers.getOffers + `?size=10&page=${page}`); | |||
| }; | |||
| export const attemptAddOffer = (payload) => { | |||
| return postRequest(apiEndpoints.offers.addOffer, payload); | |||
| export const attemptAddOffer = (payload, data) => { | |||
| // return postRequest(apiEndpoints.offers.addOffer, { userId: payload }); | |||
| return postRequest( | |||
| replaceInUrl(apiEndpoints.offers.addOffer, { userId: payload }), | |||
| data | |||
| ); | |||
| }; | |||
| export const attemptFetchProfileOffers = (payload) => { | |||
| return getRequest(`${apiEndpoints.offers.mineOffers}/${payload}/offers`); | |||
| }; | |||
| export const attemptRemoveOffer = (payload) => { | |||
| return deleteRequest(apiEndpoints.offers.removeOffer + "/" + payload); | |||
| export const attemptRemoveOffer = (payload, offerId) => { | |||
| return deleteRequest( | |||
| replaceInUrl(apiEndpoints.offers.removeOffer, { | |||
| userId: payload, | |||
| offerId: offerId, | |||
| }) | |||
| ); | |||
| }; | |||
| export const attemptEditOffer = (payload, editedData) => { | |||
| return putRequest(apiEndpoints.offers.editOffer + "/" + payload, editedData); | |||
| export const attemptEditOffer = (payload, offerId, editedData) => { | |||
| return putRequest( | |||
| replaceInUrl(apiEndpoints.offers.editOffer, { | |||
| userId: payload, | |||
| offerId: offerId, | |||
| }), | |||
| editedData | |||
| ); | |||
| }; | |||
| export const attemptPinOffer = (payload) => { | |||
| return patchRequest( | |||
| @@ -10,7 +10,7 @@ import { | |||
| function* fetchLocations() { | |||
| try { | |||
| const { data } = yield call(attemptFetchLocations); | |||
| yield put(setLocations(data)); | |||
| yield put(setLocations(data.value)); | |||
| yield put(fetchLocationsSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchLocationsError()); | |||
| @@ -157,6 +157,7 @@ function* fetchMoreOffers(payload) { | |||
| function* createOffer(payload) { | |||
| try { | |||
| console.log(payload); | |||
| const userId = yield select(selectUserId); | |||
| const offerData = payload.payload.offerData; | |||
| const formData = new FormData(); | |||
| formData.append("category[name]", offerData.category.name); | |||
| @@ -169,7 +170,8 @@ function* createOffer(payload) { | |||
| formData.append("location[city]", offerData.location.city); | |||
| formData.append("name", offerData.name); | |||
| formData.append("subcategory", offerData.subcategory); | |||
| yield call(attemptAddOffer, formData); | |||
| console.log(formData); | |||
| yield call(attemptAddOffer, userId, formData); | |||
| yield put(addOfferSuccess()); | |||
| if (payload.payload.handleApiResponseSuccess) { | |||
| yield call(payload.payload.handleApiResponseSuccess); | |||
| @@ -237,8 +239,9 @@ function* fetchProfileOffers(payload) { | |||
| function* removeOffer(payload) { | |||
| try { | |||
| const userId = yield select(selectUserId); | |||
| const offerId = payload.payload.offerId; | |||
| yield call(attemptRemoveOffer, offerId); | |||
| yield call(attemptRemoveOffer, userId, offerId); | |||
| yield put(removeOfferSuccess()); | |||
| if (payload.payload.handleApiResponseSuccess) { | |||
| yield call(payload.payload.handleApiResponseSuccess); | |||
| @@ -264,6 +267,7 @@ function* pinOffer(payload) { | |||
| function* editOffer(payload) { | |||
| try { | |||
| const userId = yield select(selectUserId); | |||
| const offerId = payload.payload.offerId; | |||
| // const editedData = payload.payload.offerData; | |||
| const offerData = payload.payload.offerData; | |||
| @@ -290,7 +294,7 @@ function* editOffer(payload) { | |||
| formData.append("location[city]", offerData.location.city); | |||
| formData.append("name", offerData.name); | |||
| formData.append("subcategory", offerData.subcategory); | |||
| yield call(attemptEditOffer, offerId, formData); | |||
| yield call(attemptEditOffer, userId, offerId, formData); | |||
| yield put(editOfferSuccess()); | |||
| if (payload.payload.handleApiResponseSuccess) { | |||
| yield call(payload.payload.handleApiResponseSuccess); | |||
| @@ -313,7 +317,7 @@ export default function* offersSaga() { | |||
| takeLatest(OFFER_EDIT, editOffer), | |||
| takeLatest(OFFERS_MINE_HEADER_FETCH, fetchMineHeaderOffers), | |||
| takeLatest(OFFERS_FEATURED_FETCH, fetchFeaturedOffers), | |||
| takeLatest(OFFER_PIN, pinOffer) | |||
| takeLatest(OFFER_PIN, pinOffer), | |||
| // takeLatest(OFFERS_ALL_FETCH, fetchAllOffers), | |||
| ]); | |||
| } | |||