| @@ -35,7 +35,10 @@ import { | |||
| ITEM_DETAILS_PAGE, | |||
| PROFILE_PAGE, | |||
| } from "../../../constants/pages"; | |||
| import { dynamicRouteMatches, replaceInRoute } from "../../../util/helpers/routeHelpers"; | |||
| import { | |||
| dynamicRouteMatches, | |||
| replaceInRoute, | |||
| } from "../../../util/helpers/routeHelpers"; | |||
| import { selectIsLoadingByActionType } from "../../../store/selectors/loadingSelectors"; | |||
| import { | |||
| OFFER_ADD_SCOPE, | |||
| @@ -54,6 +57,7 @@ const CreateOffer = ({ editOffer, offer, isAdmin, customUserId }) => { | |||
| const [currentStep, setCurrentStep] = useState(1); | |||
| const { t } = useTranslation(); | |||
| const userId = useSelector(selectUserId); | |||
| console.log(offer); | |||
| const isLoading = useSelector( | |||
| selectIsLoadingByActionType(editOffer ? OFFER_EDIT_SCOPE : OFFER_ADD_SCOPE) | |||
| ); | |||
| @@ -64,7 +68,10 @@ const CreateOffer = ({ editOffer, offer, isAdmin, customUserId }) => { | |||
| if (editOffer) { | |||
| if (routeMatches(BASE_PAGE) || routeMatches(HOME_PAGE)) | |||
| dispatch(fetchOffers({ queryString })); | |||
| if (dynamicRouteMatches(PROFILE_PAGE) || dynamicRouteMatches(ADMIN_SINGLE_USER_PAGE)) | |||
| if ( | |||
| dynamicRouteMatches(PROFILE_PAGE) || | |||
| dynamicRouteMatches(ADMIN_SINGLE_USER_PAGE) | |||
| ) | |||
| if (isAdmin) dispatch(fetchProfileOffers(customUserId)); | |||
| else dispatch(fetchProfileOffers(userId)); | |||
| @@ -92,7 +92,7 @@ const ItemDetailsCard = (props) => { | |||
| editOffer: true, | |||
| offer: offer?.offer, | |||
| isAdmin: props.isAdmin, | |||
| customUserId: offer?.offer?.userId | |||
| customUserId: offer?.offer?.userId, | |||
| }) | |||
| ); | |||
| }; | |||
| @@ -107,7 +107,7 @@ const ItemDetailsCard = (props) => { | |||
| }) | |||
| ); | |||
| }; | |||
| console.log(offer); | |||
| return ( | |||
| <> | |||
| <ItemDetailsCardContainer | |||
| @@ -48,7 +48,7 @@ const DeleteOffer = (props) => { | |||
| const { t } = useTranslation(); | |||
| const queryString = useSelector(selectQueryString); | |||
| const history = useHistory(); | |||
| const userId = props.offer.userId; | |||
| const userId = props.offer.user._id; | |||
| const { isMobile } = useIsMobile(); | |||
| const offerId = props.offer._id; | |||
| const closeDeleteModalHandler = () => { | |||
| @@ -139,8 +139,6 @@ const OfferCard = (props) => { | |||
| return true; | |||
| }, [userId, props.offer]); | |||
| console.log("props", props); | |||
| return ( | |||
| <React.Fragment> | |||
| <OfferCardContainer | |||
| @@ -85,7 +85,7 @@ const ProfileCard = (props) => { | |||
| 100 | |||
| ); | |||
| } | |||
| console.log(profileFromRedux); | |||
| return ( | |||
| <> | |||
| {isLoading ? ( | |||
| @@ -41,9 +41,10 @@ const ItemDetailsHeaderCard = (props) => { | |||
| }, [props.offer]); | |||
| const userId = useSelector(selectUserId); | |||
| const { isMobile } = useIsMobile(); | |||
| console.log(props); | |||
| const handleGoProfile = () => { | |||
| history.push(`/profile/${offer?.offer?.userId}`); | |||
| history.push(`/profile/${offer?.offer?.user?._id}`); | |||
| }; | |||
| const messageUser = (offer) => { | |||
| const chatItem = chats.find( | |||
| @@ -29,7 +29,6 @@ const Offers = (props) => { | |||
| const toggleFilters = () => { | |||
| props?.toggleFilters(); | |||
| }; | |||
| return ( | |||
| <> | |||
| {!props?.skeleton ? ( | |||
| @@ -22,6 +22,7 @@ const Profile = (props) => { | |||
| const isMyProfile = useMemo(() => { | |||
| return userId === routeMatch.params.idProfile; | |||
| }, [userId, routeMatch]); | |||
| console.log(userId); | |||
| return ( | |||
| <ProfileContainer className={props.className}> | |||
| <Header isAdmin={props.isAdmin} /> | |||
| @@ -53,6 +53,8 @@ const ProfileOffers = (props) => { | |||
| const total = useSelector(selectTotalOffers); | |||
| const dispatch = useDispatch(); | |||
| const searchRef = useRef(null); | |||
| console.log(props); | |||
| console.log(profileOffers); | |||
| useEffect(() => { | |||
| dispatch( | |||
| @@ -26,6 +26,7 @@ const ProfileMini = () => { | |||
| if (offer?.offer?.userId?.toString() === userId?.toString()) return true; | |||
| return false; | |||
| }, [offer, userId]); | |||
| console.log(offer); | |||
| return ( | |||
| <> | |||
| {isLoadingOfferContent || isLoadingOfferContent === undefined ? ( | |||
| @@ -17,6 +17,7 @@ const ItemDetailsPage = (props) => { | |||
| const selectedOffer = useSelector(selectOffer); | |||
| const [isInitiallyLoaded, setIsInitiallyLoaded] = useState(false); | |||
| const offerId = props.match.params.idProizvod; | |||
| console.log(selectedOffer); | |||
| useEffect(() => { | |||
| dispatch(fetchOneOffer(offerId)); | |||
| @@ -6,7 +6,8 @@ const request = axios.create({ | |||
| // baseURL: "http://192.168.88.175:3005/", | |||
| // baseURL: "http://192.168.88.143:3001/", // DULE | |||
| // baseURL: "https://trampa-api.dilig.net/", | |||
| baseURL: "https://trampa-api-test.dilig.net/", | |||
| // baseURL: "https://trampa-api-test.dilig.net/", | |||
| baseURL: "https://trampa-qa-api.dilig.net/", | |||
| // baseURL: "http://localhost:3001/", | |||
| // baseURL: process.env.REACT_APP_BASE_API_URL, | |||
| headers: { | |||
| @@ -16,7 +16,8 @@ import { logoutUser, refreshUserToken } from "../actions/login/loginActions"; | |||
| // const baseURL = "http://192.168.88.143:3001/"; // DULE | |||
| // const baseURL = "http://192.168.88.175:3005/"; | |||
| // const baseURL = "https://trampa-api.dilig.net/"; | |||
| const baseURL = "https://trampa-api-test.dilig.net/"; | |||
| // const baseURL = "https://trampa-api-test.dilig.net/"; | |||
| const baseURL = "https://trampa-qa-api.dilig.net/"; | |||
| // const baseURL = "http://192.168.88.150:3001/"; // DJOLE | |||
| // const baseURL = "http://localhost:3001/"; | |||
| // const baseURL = process.env.REACT_APP_BASE_API_URL | |||
| @@ -11,7 +11,7 @@ function* fetchLocations() { | |||
| try { | |||
| const data = yield call(attemptFetchLocations); | |||
| if (!data?.data) throw new Error(); | |||
| yield put(setLocations(data.data.value)); | |||
| yield put(setLocations(data.data)); | |||
| yield put(fetchLocationsSuccess()); | |||
| } catch (e) { | |||
| yield put(fetchLocationsError()); | |||
| @@ -213,6 +213,7 @@ function* fetchMineOffers() { | |||
| try { | |||
| const userId = yield select(selectUserId); | |||
| const data = yield call(attemptFetchProfileOffers, userId); | |||
| console.log(userId, data); | |||
| yield put(setMineOffers(data.data.offers)); | |||
| yield put(fetchMineOffersSuccess()); | |||
| } catch (e) { | |||
| @@ -234,7 +235,7 @@ function* fetchMineHeaderOffers() { | |||
| function* fetchProfileOffers(payload) { | |||
| try { | |||
| console.log(payload.payload); | |||
| console.log(payload); | |||
| let userId; | |||
| if (typeof payload.payload === "object") { | |||
| userId = payload.payload.idProfile; | |||
| @@ -253,11 +254,13 @@ function* fetchProfileOffers(payload) { | |||
| queryString = yield select(selectQueryString); | |||
| } | |||
| console.log(queryString.toString()); | |||
| console.log(userId); | |||
| const data = yield call( | |||
| attemptFetchProfileOffers, | |||
| userId, | |||
| convertQueryStringForBackend(queryString) | |||
| ); | |||
| console.log(data); | |||
| if (payload.payload.append) { | |||
| yield put(addProfileOffers(data.data.offers)); | |||
| } else { | |||
| @@ -277,6 +280,7 @@ function* fetchProfileOffers(payload) { | |||
| function* removeOffer(payload) { | |||
| try { | |||
| const userId = yield select(selectUserId); | |||
| console.log(userId); | |||
| const offerId = payload.payload.offerId; | |||
| if (payload.payload.isAdmin) yield call(attemptRemoveOfferAsAdmin, offerId); | |||
| else yield call(attemptRemoveOffer, userId, offerId); | |||
| @@ -309,6 +313,7 @@ function* editOffer(payload) { | |||
| const offerId = payload.payload.offerId; | |||
| // const editedData = payload.payload.offerData; | |||
| const offerData = payload.payload.offerData; | |||
| console.log(userId, offerId, payload); | |||
| const formData = new FormData(); | |||
| formData.append("category[name]", offerData.category.name); | |||
| formData.append("condition", offerData.condition); | |||
| @@ -45,6 +45,7 @@ import { selectQueryString } from "../selectors/queryStringSelectors"; | |||
| function* fetchProfile(payload) { | |||
| try { | |||
| console.log("JOHAN", payload); | |||
| const data = yield call(attemptFetchProfile, payload.payload); | |||
| if (data) yield put(setProfile(data.data)); | |||
| yield put(fetchProfileSuccess()); | |||
| @@ -26,7 +26,7 @@ import { selectUserId } from "../selectors/loginSelectors"; | |||
| function* fetchReviews(payload) { | |||
| try { | |||
| console.log(payload); | |||
| console.log("JOHAN", payload); | |||
| const data = yield call(attemptFetchReview, payload.payload); | |||
| yield put(setReviews([...data.data].reverse())); | |||
| yield put(fetchReviewsSuccess()); | |||
| @@ -24,9 +24,9 @@ export const selectAllProfiles = createSelector( | |||
| ); | |||
| export const selectTotalProfiles = createSelector( | |||
| profileSelector, | |||
| state => state.allProfiles?.total | |||
| ) | |||
| (state) => state.allProfiles?.total | |||
| ); | |||
| export const selectAmIBlocked = createSelector( | |||
| profileSelector, | |||
| state => state?.mineProfile?._blocked | |||
| ) | |||
| (state) => state?.mineProfile?._blocked | |||
| ); | |||