| right: 134px; | right: 134px; | ||||
| top: 18px; | top: 18px; | ||||
| @media (max-width: 600px) { | @media (max-width: 600px) { | ||||
| ${props => props.vertical && ` | |||||
| ${(props) => | |||||
| props.vertical && | |||||
| ` | |||||
| display: block; | display: block; | ||||
| top: initial; | top: initial; | ||||
| right: initial; | right: initial; | ||||
| @media (max-width: 600px) { | @media (max-width: 600px) { | ||||
| top: 20px; | top: 20px; | ||||
| right: 55px; | right: 55px; | ||||
| ${props => props.vertical && ` | |||||
| ${(props) => | |||||
| props.vertical && | |||||
| ` | |||||
| top: initial; | top: initial; | ||||
| bottom: 18px; | bottom: 18px; | ||||
| right: 18px; | right: 18px; | ||||
| `} | `} | ||||
| } | } | ||||
| `; | `; | ||||
| export const CategoryIcon = styled(Category)` | export const CategoryIcon = styled(Category)` | ||||
| width: 14px; | width: 14px; |
| error={props.formik.touched.firmPIB && props.formik.errors.firmPIB} | error={props.formik.touched.firmPIB && props.formik.errors.firmPIB} | ||||
| margin="normal" | margin="normal" | ||||
| fullWidth | fullWidth | ||||
| disabled | |||||
| // disabled | |||||
| /> | /> | ||||
| </> | </> | ||||
| ); | ); |
| const ProfileMainInfo = (props) => { | const ProfileMainInfo = (props) => { | ||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const { isMobile } = useIsMobile(); | const { isMobile } = useIsMobile(); | ||||
| console.log(props.profile); | |||||
| const goToUser = () => { | const goToUser = () => { | ||||
| if (isAdminRoute()) { | if (isAdminRoute()) { | ||||
| history.push( | history.push( |
| ) | ) | ||||
| isGoodCommunication = reviewEnum.NO.mainText.toUpperCase(); | isGoodCommunication = reviewEnum.NO.mainText.toUpperCase(); | ||||
| return { | return { | ||||
| _id: props.review._id, | |||||
| name: props.review.userWhoGaveReview.name, | name: props.review.userWhoGaveReview.name, | ||||
| image: props.review.userWhoGaveReview.image, | image: props.review.userWhoGaveReview.image, | ||||
| userId: props.review.userId, | userId: props.review.userId, | ||||
| offerImage: props.review.offer.image, | offerImage: props.review.offer.image, | ||||
| }; | }; | ||||
| }, [props.review]); | }, [props.review]); | ||||
| console.log(review); | |||||
| return ( | return ( | ||||
| <> | <> |
| import UserReviewsSingleCard from "../../Cards/UserReviewsCard/UserReviewsSingleCard/UserReviewsSingleCard"; | import UserReviewsSingleCard from "../../Cards/UserReviewsCard/UserReviewsSingleCard/UserReviewsSingleCard"; | ||||
| import { useTranslation } from "react-i18next"; | import { useTranslation } from "react-i18next"; | ||||
| import DeleteButton from "./DeleteButton/DeleteButton"; | import DeleteButton from "./DeleteButton/DeleteButton"; | ||||
| import { useDispatch } from "react-redux"; | |||||
| import { removeReview } from "../../../store/actions/review/reviewActions"; | |||||
| const DeleteReview = (props) => { | const DeleteReview = (props) => { | ||||
| const dispatch = useDispatch(); | |||||
| const reviewId = props.review._id; | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const handleApiResponseSuccess = () => { | |||||
| console.log("Succes"); | |||||
| }; | |||||
| const deleteReviewHandler = () => { | |||||
| dispatch(removeReview({ reviewId, handleApiResponseSuccess })); | |||||
| props.setOpenedDeleteModal(false); | |||||
| }; | |||||
| return ( | return ( | ||||
| <> | <> | ||||
| <BackdropComponent | <BackdropComponent | ||||
| review={props.review} | review={props.review} | ||||
| /> | /> | ||||
| <XIcon onClick={() => props.setOpenedDeleteModal(false)} /> | <XIcon onClick={() => props.setOpenedDeleteModal(false)} /> | ||||
| <DeleteButton /> | |||||
| <DeleteButton onClick={deleteReviewHandler} /> | |||||
| </DeleteReviewContainer> | </DeleteReviewContainer> | ||||
| </> | </> | ||||
| ); | ); |
| updateUserRegistration: "/users/{userUid}", | updateUserRegistration: "/users/{userUid}", | ||||
| invite: "/users/invite", | invite: "/users/invite", | ||||
| getProfile: "users/", | getProfile: "users/", | ||||
| editProfile: "users", | |||||
| getAllProfiles: "users", | |||||
| editProfile: "users/{userId}", | |||||
| getAllProfiles: "users/companies", | |||||
| }, | }, | ||||
| applications: { | applications: { | ||||
| application: "/applications/{applicationUid}", | application: "/applications/{applicationUid}", | ||||
| validateExchange: "exchanges", | validateExchange: "exchanges", | ||||
| }, | }, | ||||
| reviews: { | reviews: { | ||||
| postReview: "reviews", | |||||
| getUserReviews: "/users/{userId}/reviews", | |||||
| postReview: "/users/{userId}/reviews", | |||||
| removeReview: "/admin/reviews/{id}", | |||||
| }, | }, | ||||
| }; | }; |
| // baseURL: "http://192.168.88.150:3001/", // DJOLE | // baseURL: "http://192.168.88.150:3001/", // DJOLE | ||||
| // baseURL: "http://192.168.88.175:3005/", | // baseURL: "http://192.168.88.175:3005/", | ||||
| // baseURL: "http://192.168.88.143:3001/", // DULE | // 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, | // baseURL: process.env.REACT_APP_BASE_API_URL, | ||||
| headers: { | headers: { | ||||
| "Content-Type": "application/json", | "Content-Type": "application/json", |
| import { getRequest, putRequest } from "."; | |||||
| import { getRequest, putRequest, replaceInUrl } from "."; | |||||
| import apiEndpoints from "./apiEndpoints"; | import apiEndpoints from "./apiEndpoints"; | ||||
| export const attemptFetchProfile = (payload) => | export const attemptFetchProfile = (payload) => | ||||
| export const attemptFetchAllProfiles = () => | export const attemptFetchAllProfiles = () => | ||||
| getRequest(apiEndpoints.users.getAllProfiles); | 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 | |||||
| ); | |||||
| }; |
| 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) => { | 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 }) | |||||
| ); | |||||
| }; |
| export const REVIEW_GET_SUCCESS = createSuccessType(REVIEW_GET_SCOPE); | export const REVIEW_GET_SUCCESS = createSuccessType(REVIEW_GET_SCOPE); | ||||
| export const REVIEW_GET_ERROR = createErrorType(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"); | export const REVIEW_SET = createSetType("REVIEW_SET"); |
| 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) => ({ | export const fetchReviews = (payload) => ({ | ||||
| type: REVIEW_GET, | |||||
| payload, | |||||
| }) | |||||
| type: REVIEW_GET, | |||||
| payload, | |||||
| }); | |||||
| export const fetchReviewsSuccess = () => ({ | export const fetchReviewsSuccess = () => ({ | ||||
| type: REVIEW_GET_SUCCESS | |||||
| }) | |||||
| type: REVIEW_GET_SUCCESS, | |||||
| }); | |||||
| export const fetchReviewsError = () => ({ | export const fetchReviewsError = () => ({ | ||||
| type: REVIEW_GET_ERROR | |||||
| }) | |||||
| type: REVIEW_GET_ERROR, | |||||
| }); | |||||
| export const giveReview = (payload) => ({ | export const giveReview = (payload) => ({ | ||||
| type: REVIEW_GIVE, | |||||
| payload, | |||||
| }) | |||||
| type: REVIEW_GIVE, | |||||
| payload, | |||||
| }); | |||||
| export const giveReviewSuccess = () => ({ | export const giveReviewSuccess = () => ({ | ||||
| type: REVIEW_GIVE_SUCCESS | |||||
| }) | |||||
| type: REVIEW_GIVE_SUCCESS, | |||||
| }); | |||||
| export const giveReviewError = () => ({ | 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) => ({ | export const setReviews = (payload) => ({ | ||||
| type: REVIEW_SET, | |||||
| payload, | |||||
| }) | |||||
| type: REVIEW_SET, | |||||
| payload, | |||||
| }); |
| if (typeof payload.payload.firmLogo !== "string") | if (typeof payload.payload.firmLogo !== "string") | ||||
| requestBody.append("file", payload.payload.firmLogo); | requestBody.append("file", payload.payload.firmLogo); | ||||
| requestBody.append("company[name]", payload.payload.firmName); | 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) | if (payload.payload.firmPhone.toString().length !== 0) | ||||
| requestBody.append( | requestBody.append( | ||||
| "company[contacts][telephone]", | "company[contacts][telephone]", |
| import { all, takeLatest, call, put } from "@redux-saga/core/effects"; | |||||
| import { all, takeLatest, call, put, select } from "@redux-saga/core/effects"; | |||||
| import { | import { | ||||
| attemptFetchReview, | attemptFetchReview, | ||||
| attemptGiveReview, | attemptGiveReview, | ||||
| attemptRemoveReview, | |||||
| } from "../../request/reviewRequest"; | } from "../../request/reviewRequest"; | ||||
| import { | import { | ||||
| REVIEW_GET, | REVIEW_GET, | ||||
| REVIEW_GIVE, | REVIEW_GIVE, | ||||
| REVIEW_REMOVE, | |||||
| } from "../actions/review/reviewActionConstants"; | } from "../actions/review/reviewActionConstants"; | ||||
| import { | import { | ||||
| fetchReviewsError, | fetchReviewsError, | ||||
| fetchReviewsSuccess, | fetchReviewsSuccess, | ||||
| giveReviewError, | giveReviewError, | ||||
| giveReviewSuccess, | giveReviewSuccess, | ||||
| removeReviewError, | |||||
| removeReviewSuccess, | |||||
| setReviews, | setReviews, | ||||
| } from "../actions/review/reviewActions"; | } from "../actions/review/reviewActions"; | ||||
| import { selectUserId } from "../selectors/loginSelectors"; | |||||
| function* fetchReviews(payload) { | function* fetchReviews(payload) { | ||||
| try { | try { | ||||
| console.log(payload); | |||||
| const data = yield call(attemptFetchReview, payload.payload); | const data = yield call(attemptFetchReview, payload.payload); | ||||
| yield put(setReviews([...data.data].reverse())); | yield put(setReviews([...data.data].reverse())); | ||||
| yield put(fetchReviewsSuccess()); | yield put(fetchReviewsSuccess()); | ||||
| function* giveReview(payload) { | function* giveReview(payload) { | ||||
| try { | try { | ||||
| yield call(attemptGiveReview, payload.payload.review); | |||||
| const userId = yield select(selectUserId); | |||||
| yield call(attemptGiveReview, userId, payload.payload.review); | |||||
| if (payload.payload.handleApiResponseSuccess) { | if (payload.payload.handleApiResponseSuccess) { | ||||
| yield call(payload.payload.handleApiResponseSuccess); | yield call(payload.payload.handleApiResponseSuccess); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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() { | export default function* reviewSaga() { | ||||
| yield all([ | yield all([ | ||||
| takeLatest(REVIEW_GET, fetchReviews), | takeLatest(REVIEW_GET, fetchReviews), | ||||
| takeLatest(REVIEW_GIVE, giveReview), | takeLatest(REVIEW_GIVE, giveReview), | ||||
| takeLatest(REVIEW_REMOVE, removeReview), | |||||
| ]); | ]); | ||||
| } | } |
| Yup.object().shape({ | Yup.object().shape({ | ||||
| firmName: Yup.string().required(i18n.t("editProfile.labelNameRequired")), | firmName: Yup.string().required(i18n.t("editProfile.labelNameRequired")), | ||||
| firmPIB: Yup.string() | firmPIB: Yup.string() | ||||
| .required(i18n.t("editProfile.labelPIBRequired")) | |||||
| // .required(i18n.t("editProfile.labelPIBRequired")) | |||||
| .min(9, i18n.t("register.PIBnoOfCharacters")) | .min(9, i18n.t("register.PIBnoOfCharacters")) | ||||
| .max(9, i18n.t("register.PIBnoOfCharacters")), | .max(9, i18n.t("register.PIBnoOfCharacters")), | ||||
| firmLocation: Yup.string().oneOf( | firmLocation: Yup.string().oneOf( |