Djordje Mitrovic hace 3 años
padre
commit
8d7e14aefc

+ 5
- 4
src/components/Cards/OfferCard/OfferCard.js Ver fichero

@@ -78,7 +78,8 @@ const OfferCard = (props) => {
})
);
};
const routeToItem = (itemId) => {
const routeToItem = (event, itemId) => {
event.stopPropagation();
if (!props.disabledCheckButton) {
if (props.isAdmin) {
history.push(
@@ -151,7 +152,7 @@ const OfferCard = (props) => {
: props?.offer?.pinned?.toString()
}
halfwidth={props.halfwidth ? 1 : 0}
onClick={() => routeToItem(props?.offer?._id)}
onClick={(event) => routeToItem(event, props?.offer?._id)}
>
{/* This only shows on vertical offer card */}
<OfferTitleAboveImage
@@ -167,7 +168,7 @@ const OfferCard = (props) => {
? 2
: 1
}
onClick={() => routeToItem(props?.offer?._id)}
onClick={(event) => routeToItem(event, props?.offer?._id)}
>
{props?.offer?.name}
</OfferTitleAboveImage>
@@ -192,7 +193,7 @@ const OfferCard = (props) => {
<OfferInfo vertical={props.vertical}>
<OfferTitle
vertical={props.vertical}
onClick={() => routeToItem(props?.offer?._id)}
onClick={(event) => routeToItem(event, props?.offer?._id)}
>
{props?.offer?.name}
</OfferTitle>

+ 1
- 0
src/components/ItemDetails/Header/Header.js Ver fichero

@@ -10,6 +10,7 @@ const Header = (props) => {
const { t } = useTranslation();

const handleBackButton = () => {
console.log("clicked")
history.goBack();
};


+ 20
- 13
src/components/Popovers/MyMessages/MyMessages.js Ver fichero

@@ -3,20 +3,27 @@ import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
import { fetchHeaderChats } from "../../../store/actions/chat/chatActions";
import { selectLatestChats } from "../../../store/selectors/chatSelectors";
import {
selectLatestChats,
selectSelectedChat,
} from "../../../store/selectors/chatSelectors";
import { selectUserId } from "../../../store/selectors/loginSelectors";
import HeaderPopover from "../HeaderPopover/HeaderPopover";
import PropTypes from "prop-types";
import { makeErrorToastMessage } from "../../../store/utils/makeToastMessage";
import { EyeIcon } from "./MyMessages.styled";
import { DIRECT_CHAT_PAGE } from "../../../constants/pages";
import { replaceInRoute } from "../../../util/helpers/routeHelpers";
import {
dynamicRouteMatches,
replaceInRoute,
} from "../../../util/helpers/routeHelpers";

export const MyMessages = (props) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const userId = useSelector(selectUserId);
const chats = useSelector(selectLatestChats);
const selectedChat = useSelector(selectSelectedChat);
const history = useHistory();
const [lastChats, setLastChats] = useState([]);

@@ -48,23 +55,23 @@ export const MyMessages = (props) => {
const goToMessages = () => {
if (lastChats.length !== 0) {
console.log(chats);
history.push({
pathname: replaceInRoute(DIRECT_CHAT_PAGE, {
chatId: chats[0]._id,
}),
});
props.closePopover();
goToMessage(chats[0]?._id)
} else {
makeErrorToastMessage(t("messages.noMessagesToast"));
props.closePopover();
}
};
const goToMessage = (chatId) => {
history.push(
replaceInRoute(DIRECT_CHAT_PAGE, {
chatId,
})
);
if (
!dynamicRouteMatches(DIRECT_CHAT_PAGE) ||
selectedChat?._id !== chatId
) {
history.push(
replaceInRoute(DIRECT_CHAT_PAGE, {
chatId,
})
);
}
props.closePopover();
};
return (

+ 13
- 8
src/components/Popovers/MyPosts/MyPosts.js Ver fichero

@@ -4,19 +4,20 @@ import PropTypes from "prop-types";
import HeaderPopover from "../HeaderPopover/HeaderPopover";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { selectMineHeaderOffers } from "../../../store/selectors/offersSelectors";
import { selectMineHeaderOffers, selectOffer } from "../../../store/selectors/offersSelectors";
import { fetchMineHeaderOffers } from "../../../store/actions/offers/offersActions";
import { selectProfileName } from "../../../store/selectors/profileSelectors";
import { useHistory } from "react-router-dom";
import { ITEM_DETAILS_PAGE, MY_OFFERS_PAGE } from "../../../constants/pages";
import { useMemo } from "react";
import { replaceInRoute } from "../../../util/helpers/routeHelpers";
import { dynamicRouteMatches, replaceInRoute, routeMatches } from "../../../util/helpers/routeHelpers";

export const MyPosts = (props) => {
const { t } = useTranslation();
const dispatch = useDispatch();
const mineOffers = useSelector(selectMineHeaderOffers);
const name = useSelector(selectProfileName);
const offer = useSelector(selectOffer);
const history = useHistory();
const [arrayOfMineOffers, setArrayOfMineOffers] = useState([]);
useEffect(() => {
@@ -60,15 +61,19 @@ export const MyPosts = (props) => {
}, [arrayOfMineOffers, mineOffers]);

const goToOffer = (id) => {
history.push(
replaceInRoute(ITEM_DETAILS_PAGE, {
offerId: id,
})
);
if (!dynamicRouteMatches(ITEM_DETAILS_PAGE) || offer?._id !== id) {
history.push(
replaceInRoute(ITEM_DETAILS_PAGE, {
offerId: id,
})
);
}
props.closePopover();
};
const goToMySwaps = () => {
history.push(MY_OFFERS_PAGE);
if (!routeMatches(MY_OFFERS_PAGE)) {
history.push(MY_OFFERS_PAGE);
}
props.closePopover();
};
return (

+ 17
- 7
src/components/Popovers/MyProfile/AboutButton/AboutButton.js Ver fichero

@@ -7,18 +7,28 @@ import { PopoverButton } from "../../HeaderPopover/HeaderPopover.styled";
import { InfoIcon } from "./AboutButton.styled";
import { useHistory } from "react-router-dom";
import scrollConstants from "../../../../constants/scrollConstants";
import { routeMatches } from "../../../../util/helpers/routeHelpers";

const AboutButton = (props) => {
const { t } = useTranslation();
const history = useHistory();
const seeAbout = () => {
history.push({
pathname: ABOUT_PAGE,
state: {
navigation: scrollConstants.about.aboutPage,
clicked: true,
}
});
if (!routeMatches(ABOUT_PAGE)) {
history.push({
pathname: ABOUT_PAGE,
state: {
navigation: scrollConstants.about.aboutPage,
clicked: true,
},
});
} else {
history.replace({
state: {
clicked: true,
navigation: scrollConstants.about.aboutPage,
},
});
}
props.closePopover();
};
return (

+ 16
- 5
src/components/Popovers/MyProfile/MyProfile.js Ver fichero

@@ -7,7 +7,10 @@ import {
import HeaderPopover from "../HeaderPopover/HeaderPopover";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { selectMineProfile } from "../../../store/selectors/profileSelectors";
import {
selectMineProfile,
selectProfile,
} from "../../../store/selectors/profileSelectors";
import {
selectRoles,
selectUserId,
@@ -22,11 +25,15 @@ import AboutButton from "./AboutButton/AboutButton";
import PrivacyPolicyButton from "./PrivacyPolicyButton/PrivacyPolicyButton";
import PricesButton from "./PricesButton/PricesButton";
import { ADMIN_HOME_PAGE, PROFILE_PAGE } from "../../../constants/pages";
import { replaceInRoute } from "../../../util/helpers/routeHelpers";
import {
dynamicRouteMatches,
replaceInRoute,
} from "../../../util/helpers/routeHelpers";

export const MyProfile = (props) => {
const { t } = useTranslation();
const profile = useSelector(selectMineProfile);
const selectedProfile = useSelector(selectProfile);
const userId = useSelector(selectUserId);
const dispatch = useDispatch();
const history = useHistory();
@@ -63,9 +70,13 @@ export const MyProfile = (props) => {
}
}, [profile]);
const seeMyProfile = () => {
history.push(replaceInRoute(PROFILE_PAGE, {
profileId: userId
}));
if (!dynamicRouteMatches(PROFILE_PAGE) || selectedProfile?._id !== userId)
history.push(
replaceInRoute(PROFILE_PAGE, {
profileId: userId,
})
);

props.closePopover();
};
const goToAdminHome = () => {

+ 17
- 7
src/components/Popovers/MyProfile/PricesButton/PricesButton.js Ver fichero

@@ -6,18 +6,28 @@ import { DollarIcon, GrayButton } from "../MyProfile.styled";
import { PopoverButton } from "../../HeaderPopover/HeaderPopover.styled";
import { useHistory } from "react-router-dom";
import scrollConstants from "../../../../constants/scrollConstants";
import { routeMatches } from "../../../../util/helpers/routeHelpers";

const PricesButton = (props) => {
const { t } = useTranslation();
const history = useHistory();
const seePrices = () => {
history.push({
pathname: ABOUT_PAGE,
state: {
navigation: scrollConstants.about.pricesPage,
clicked: true,
},
});
if (!routeMatches(ABOUT_PAGE)) {
history.push({
pathname: ABOUT_PAGE,
state: {
navigation: scrollConstants.about.pricesPage,
clicked: true,
},
});
} else {
history.replace({
state: {
clicked: true,
navigation: scrollConstants.about.pricesPage,
},
});
}
props.closePopover();
};
return (

+ 17
- 7
src/components/Popovers/MyProfile/PrivacyPolicyButton/PrivacyPolicyButton.js Ver fichero

@@ -7,18 +7,28 @@ import { ABOUT_PAGE } from "../../../../constants/pages";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import scrollConstants from "../../../../constants/scrollConstants";
import { routeMatches } from "../../../../util/helpers/routeHelpers";

const PrivacyPolicyButton = (props) => {
const { t } = useTranslation();
const history = useHistory();
const seePrivacy = () => {
history.push({
pathname: ABOUT_PAGE,
state: {
clicked: true,
navigation: scrollConstants.about.privacyPolicyPage,
},
});
if (!routeMatches(ABOUT_PAGE)) {
history.push({
pathname: ABOUT_PAGE,
state: {
clicked: true,
navigation: scrollConstants.about.privacyPolicyPage,
},
});
} else {
history.replace({
state: {
clicked: true,
navigation: scrollConstants.about.privacyPolicyPage,
}
})
}
props.closePopover();
};
return (

Cargando…
Cancelar
Guardar