| @@ -367,7 +367,9 @@ export const PinIconContainer = styled(MessageIcon)` | |||
| right: 134px; | |||
| top: 18px; | |||
| @media (max-width: 600px) { | |||
| ${props => props.vertical && ` | |||
| ${(props) => | |||
| props.vertical && | |||
| ` | |||
| display: block; | |||
| top: initial; | |||
| right: initial; | |||
| @@ -416,13 +418,14 @@ export const PinIcon = styled(Pin)` | |||
| @media (max-width: 600px) { | |||
| top: 20px; | |||
| right: 55px; | |||
| ${props => props.vertical && ` | |||
| ${(props) => | |||
| props.vertical && | |||
| ` | |||
| top: initial; | |||
| bottom: 18px; | |||
| right: 18px; | |||
| `} | |||
| } | |||
| `; | |||
| export const CategoryIcon = styled(Category)` | |||
| width: 14px; | |||
| @@ -16,7 +16,7 @@ const PIBField = (props) => { | |||
| error={props.formik.touched.firmPIB && props.formik.errors.firmPIB} | |||
| margin="normal" | |||
| fullWidth | |||
| disabled | |||
| // disabled | |||
| /> | |||
| </> | |||
| ); | |||
| @@ -23,6 +23,7 @@ import { ADMIN_SINGLE_USER_PAGE } from "../../../../constants/pages"; | |||
| const ProfileMainInfo = (props) => { | |||
| const { t } = useTranslation(); | |||
| const { isMobile } = useIsMobile(); | |||
| console.log(props.profile); | |||
| const goToUser = () => { | |||
| if (isAdminRoute()) { | |||
| history.push( | |||
| @@ -33,6 +33,7 @@ const UserReviewsCard = (props) => { | |||
| ) | |||
| isGoodCommunication = reviewEnum.NO.mainText.toUpperCase(); | |||
| return { | |||
| _id: props.review._id, | |||
| name: props.review.userWhoGaveReview.name, | |||
| image: props.review.userWhoGaveReview.image, | |||
| userId: props.review.userId, | |||
| @@ -43,7 +44,6 @@ const UserReviewsCard = (props) => { | |||
| offerImage: props.review.offer.image, | |||
| }; | |||
| }, [props.review]); | |||
| console.log(review); | |||
| return ( | |||
| <> | |||
| @@ -9,9 +9,22 @@ import BackdropComponent from "../../MUI/BackdropComponent"; | |||
| import UserReviewsSingleCard from "../../Cards/UserReviewsCard/UserReviewsSingleCard/UserReviewsSingleCard"; | |||
| import { useTranslation } from "react-i18next"; | |||
| import DeleteButton from "./DeleteButton/DeleteButton"; | |||
| import { useDispatch } from "react-redux"; | |||
| import { removeReview } from "../../../store/actions/review/reviewActions"; | |||
| const DeleteReview = (props) => { | |||
| const dispatch = useDispatch(); | |||
| const reviewId = props.review._id; | |||
| const { t } = useTranslation(); | |||
| const handleApiResponseSuccess = () => { | |||
| console.log("Succes"); | |||
| }; | |||
| const deleteReviewHandler = () => { | |||
| dispatch(removeReview({ reviewId, handleApiResponseSuccess })); | |||
| props.setOpenedDeleteModal(false); | |||
| }; | |||
| return ( | |||
| <> | |||
| <BackdropComponent | |||
| @@ -27,7 +40,7 @@ const DeleteReview = (props) => { | |||
| review={props.review} | |||
| /> | |||
| <XIcon onClick={() => props.setOpenedDeleteModal(false)} /> | |||
| <DeleteButton /> | |||
| <DeleteButton onClick={deleteReviewHandler} /> | |||
| </DeleteReviewContainer> | |||
| </> | |||
| ); | |||
| @@ -119,8 +119,8 @@ export default { | |||
| updateUserRegistration: "/users/{userUid}", | |||
| invite: "/users/invite", | |||
| getProfile: "users/", | |||
| editProfile: "users", | |||
| getAllProfiles: "users", | |||
| editProfile: "users/{userId}", | |||
| getAllProfiles: "users/companies", | |||
| }, | |||
| applications: { | |||
| application: "/applications/{applicationUid}", | |||
| @@ -184,6 +184,8 @@ export default { | |||
| validateExchange: "exchanges", | |||
| }, | |||
| reviews: { | |||
| postReview: "reviews", | |||
| getUserReviews: "/users/{userId}/reviews", | |||
| postReview: "/users/{userId}/reviews", | |||
| removeReview: "/admin/reviews/{id}", | |||
| }, | |||
| }; | |||
| @@ -5,8 +5,8 @@ const request = axios.create({ | |||
| // baseURL: "http://192.168.88.150:3001/", // DJOLE | |||
| // baseURL: "http://192.168.88.175:3005/", | |||
| // baseURL: "http://192.168.88.143:3001/", // DULE | |||
| // baseURL: "https://trampa-api-test.dilig.net/", | |||
| baseURL: "http://localhost:3001/", | |||
| baseURL: "https://trampa-api-test.dilig.net/", | |||
| // baseURL: "http://localhost:3001/", | |||
| // baseURL: process.env.REACT_APP_BASE_API_URL, | |||
| headers: { | |||
| "Content-Type": "application/json", | |||
| @@ -1,4 +1,4 @@ | |||
| import { getRequest, putRequest } from "."; | |||
| import { getRequest, putRequest, replaceInUrl } from "."; | |||
| import apiEndpoints from "./apiEndpoints"; | |||
| export const attemptFetchProfile = (payload) => | |||
| @@ -7,5 +7,10 @@ export const attemptFetchProfile = (payload) => | |||
| export const attemptFetchAllProfiles = () => | |||
| getRequest(apiEndpoints.users.getAllProfiles); | |||
| export const attemptEditProfile = (payload, requestData) => | |||
| putRequest(apiEndpoints.users.editProfile + "/" + payload, requestData); | |||
| export const attemptEditProfile = (payload, requestData) => { | |||
| // putRequest(apiEndpoints.users.editProfile + "/" + payload, requestData); | |||
| return putRequest( | |||
| replaceInUrl(apiEndpoints.users.editProfile, { userId: payload }), | |||
| requestData | |||
| ); | |||
| }; | |||
| @@ -1,9 +1,19 @@ | |||
| import { getRequest, postRequest } from "." | |||
| import apiEndpoints from "./apiEndpoints" | |||
| import { deleteRequest, getRequest, postRequest, replaceInUrl } from "."; | |||
| import apiEndpoints from "./apiEndpoints"; | |||
| export const attemptGiveReview = (payload) => { | |||
| return postRequest(apiEndpoints.reviews.postReview, payload); | |||
| } | |||
| export const attemptGiveReview = (userId, payload) => { | |||
| return postRequest( | |||
| replaceInUrl(apiEndpoints.reviews.postReview, { userId: userId }), | |||
| payload | |||
| ); | |||
| }; | |||
| export const attemptFetchReview = (payload) => { | |||
| return getRequest(`users/${payload}/reviews`) | |||
| } | |||
| return getRequest( | |||
| replaceInUrl(apiEndpoints.reviews.getUserReviews, { userId: payload }) | |||
| ); | |||
| }; | |||
| export const attemptRemoveReview = (payload) => { | |||
| return deleteRequest( | |||
| replaceInUrl(apiEndpoints.reviews.removeReview, { id: payload }) | |||
| ); | |||
| }; | |||
| @@ -15,4 +15,9 @@ export const REVIEW_GET = createFetchType(REVIEW_GET_SCOPE); | |||
| export const REVIEW_GET_SUCCESS = createSuccessType(REVIEW_GET_SCOPE); | |||
| export const REVIEW_GET_ERROR = createErrorType(REVIEW_GET_SCOPE); | |||
| export const REVIEW_REMOVE_SCOPE = "REVIEW_REMOVE_SCOPE"; | |||
| export const REVIEW_REMOVE = createFetchType(REVIEW_REMOVE_SCOPE); | |||
| export const REVIEW_REMOVE_SUCCESS = createSuccessType(REVIEW_REMOVE_SCOPE); | |||
| export const REVIEW_REMOVE_ERROR = createErrorType(REVIEW_REMOVE_SCOPE); | |||
| export const REVIEW_SET = createSetType("REVIEW_SET"); | |||
| @@ -1,26 +1,47 @@ | |||
| import { REVIEW_GET, REVIEW_GET_ERROR, REVIEW_GET_SUCCESS, REVIEW_GIVE, REVIEW_GIVE_ERROR, REVIEW_GIVE_SUCCESS, REVIEW_SET } from "./reviewActionConstants"; | |||
| import { | |||
| REVIEW_GET, | |||
| REVIEW_GET_ERROR, | |||
| REVIEW_GET_SUCCESS, | |||
| REVIEW_GIVE, | |||
| REVIEW_GIVE_ERROR, | |||
| REVIEW_GIVE_SUCCESS, | |||
| REVIEW_REMOVE, | |||
| REVIEW_REMOVE_ERROR, | |||
| REVIEW_REMOVE_SUCCESS, | |||
| REVIEW_SET, | |||
| } from "./reviewActionConstants"; | |||
| export const fetchReviews = (payload) => ({ | |||
| type: REVIEW_GET, | |||
| payload, | |||
| }) | |||
| type: REVIEW_GET, | |||
| payload, | |||
| }); | |||
| export const fetchReviewsSuccess = () => ({ | |||
| type: REVIEW_GET_SUCCESS | |||
| }) | |||
| type: REVIEW_GET_SUCCESS, | |||
| }); | |||
| export const fetchReviewsError = () => ({ | |||
| type: REVIEW_GET_ERROR | |||
| }) | |||
| type: REVIEW_GET_ERROR, | |||
| }); | |||
| export const giveReview = (payload) => ({ | |||
| type: REVIEW_GIVE, | |||
| payload, | |||
| }) | |||
| type: REVIEW_GIVE, | |||
| payload, | |||
| }); | |||
| export const giveReviewSuccess = () => ({ | |||
| type: REVIEW_GIVE_SUCCESS | |||
| }) | |||
| type: REVIEW_GIVE_SUCCESS, | |||
| }); | |||
| export const giveReviewError = () => ({ | |||
| type: REVIEW_GIVE_ERROR | |||
| }) | |||
| type: REVIEW_GIVE_ERROR, | |||
| }); | |||
| export const removeReview = (payload) => ({ | |||
| type: REVIEW_REMOVE, | |||
| payload, | |||
| }); | |||
| export const removeReviewSuccess = () => ({ | |||
| type: REVIEW_REMOVE_SUCCESS, | |||
| }); | |||
| export const removeReviewError = () => ({ | |||
| type: REVIEW_REMOVE_ERROR, | |||
| }); | |||
| export const setReviews = (payload) => ({ | |||
| type: REVIEW_SET, | |||
| payload, | |||
| }) | |||
| type: REVIEW_SET, | |||
| payload, | |||
| }); | |||
| @@ -94,7 +94,7 @@ function* changeMineProfile(payload) { | |||
| if (typeof payload.payload.firmLogo !== "string") | |||
| requestBody.append("file", payload.payload.firmLogo); | |||
| requestBody.append("company[name]", payload.payload.firmName); | |||
| requestBody.append("company[PIB]", payload.payload.firmPIB); | |||
| // requestBody.append("company[PIB]", payload.payload.firmPIB); | |||
| if (payload.payload.firmPhone.toString().length !== 0) | |||
| requestBody.append( | |||
| "company[contacts][telephone]", | |||
| @@ -1,22 +1,28 @@ | |||
| import { all, takeLatest, call, put } from "@redux-saga/core/effects"; | |||
| import { all, takeLatest, call, put, select } from "@redux-saga/core/effects"; | |||
| import { | |||
| attemptFetchReview, | |||
| attemptGiveReview, | |||
| attemptRemoveReview, | |||
| } from "../../request/reviewRequest"; | |||
| import { | |||
| REVIEW_GET, | |||
| REVIEW_GIVE, | |||
| REVIEW_REMOVE, | |||
| } from "../actions/review/reviewActionConstants"; | |||
| import { | |||
| fetchReviewsError, | |||
| fetchReviewsSuccess, | |||
| giveReviewError, | |||
| giveReviewSuccess, | |||
| removeReviewError, | |||
| removeReviewSuccess, | |||
| setReviews, | |||
| } from "../actions/review/reviewActions"; | |||
| import { selectUserId } from "../selectors/loginSelectors"; | |||
| function* fetchReviews(payload) { | |||
| try { | |||
| console.log(payload); | |||
| const data = yield call(attemptFetchReview, payload.payload); | |||
| yield put(setReviews([...data.data].reverse())); | |||
| yield put(fetchReviewsSuccess()); | |||
| @@ -28,7 +34,8 @@ function* fetchReviews(payload) { | |||
| function* giveReview(payload) { | |||
| try { | |||
| yield call(attemptGiveReview, payload.payload.review); | |||
| const userId = yield select(selectUserId); | |||
| yield call(attemptGiveReview, userId, payload.payload.review); | |||
| if (payload.payload.handleApiResponseSuccess) { | |||
| yield call(payload.payload.handleApiResponseSuccess); | |||
| } | |||
| @@ -39,9 +46,24 @@ function* giveReview(payload) { | |||
| } | |||
| } | |||
| function* removeReview(payload) { | |||
| try { | |||
| console.log(payload); | |||
| yield call(attemptRemoveReview, payload.payload.reviewId); | |||
| if (payload.payload.handleApiResponseSuccess) { | |||
| yield call(payload.payload.handleApiResponseSuccess); | |||
| } | |||
| yield put(removeReviewSuccess()); | |||
| } catch (e) { | |||
| yield put(removeReviewError()); | |||
| console.dir(e); | |||
| } | |||
| } | |||
| export default function* reviewSaga() { | |||
| yield all([ | |||
| takeLatest(REVIEW_GET, fetchReviews), | |||
| takeLatest(REVIEW_GIVE, giveReview), | |||
| takeLatest(REVIEW_REMOVE, removeReview), | |||
| ]); | |||
| } | |||
| @@ -4,7 +4,7 @@ export default (locations) => | |||
| Yup.object().shape({ | |||
| firmName: Yup.string().required(i18n.t("editProfile.labelNameRequired")), | |||
| firmPIB: Yup.string() | |||
| .required(i18n.t("editProfile.labelPIBRequired")) | |||
| // .required(i18n.t("editProfile.labelPIBRequired")) | |||
| .min(9, i18n.t("register.PIBnoOfCharacters")) | |||
| .max(9, i18n.t("register.PIBnoOfCharacters")), | |||
| firmLocation: Yup.string().oneOf( | |||