| @@ -202,6 +202,18 @@ const Header = () => { | |||
| }, | |||
| }); | |||
| }; | |||
| const closePostsPopover = () => { | |||
| setPostsPopoverOpen(false); | |||
| setPostsAnchorEl(null); | |||
| } | |||
| const closeMsgPopover = () => { | |||
| setMsgPopoverOpen(false); | |||
| setMsgAnchorEl(null); | |||
| } | |||
| const closeUserPopover = () => { | |||
| setUserPopoverOpen(false); | |||
| setUserAnchorEl(null); | |||
| } | |||
| return ( | |||
| <HeaderContainer style={{ display: shouldShow ? "block" : "none" }}> | |||
| @@ -357,7 +369,7 @@ const Header = () => { | |||
| setPostsPopoverOpen(false); | |||
| setPostsAnchorEl(null); | |||
| }} | |||
| content={<MyPosts />} | |||
| content={<MyPosts closePopover={closePostsPopover} />} | |||
| /> | |||
| <PopoverComponent | |||
| anchorEl={msgAnchorEl} | |||
| @@ -366,7 +378,7 @@ const Header = () => { | |||
| setMsgPopoverOpen(false); | |||
| setMsgAnchorEl(null); | |||
| }} | |||
| content={<MyMessages />} | |||
| content={<MyMessages closePopover={closeMsgPopover}/>} | |||
| /> | |||
| <PopoverComponent | |||
| anchorEl={userAnchorEl} | |||
| @@ -375,7 +387,7 @@ const Header = () => { | |||
| setUserPopoverOpen(false); | |||
| setUserAnchorEl(null); | |||
| }} | |||
| content={<MyProfile />} | |||
| content={<MyProfile closePopover={closeUserPopover} />} | |||
| /> | |||
| </React.Fragment> | |||
| )} | |||
| @@ -6,8 +6,9 @@ import { fetchHeaderChats } from "../../../store/actions/chat/chatActions"; | |||
| import { selectLatestChats } from "../../../store/selectors/chatSelectors"; | |||
| import { selectUserId } from "../../../store/selectors/loginSelectors"; | |||
| import HeaderPopover from "../HeaderPopover/HeaderPopover"; | |||
| import PropTypes from "prop-types"; | |||
| export const MyMessages = () => { | |||
| export const MyMessages = (props) => { | |||
| const { t } = useTranslation(); | |||
| const dispatch = useDispatch(); | |||
| const userId = useSelector(selectUserId); | |||
| @@ -15,10 +16,6 @@ export const MyMessages = () => { | |||
| const history = useHistory(); | |||
| const [lastChats, setLastChats] = useState([]); | |||
| const goToMessage = (chatId) => { | |||
| history.push(`/messages/${chatId}`); | |||
| }; | |||
| const convertMessages = (messages) => { | |||
| return messages | |||
| .map((item) => ({ | |||
| @@ -42,6 +39,11 @@ export const MyMessages = () => { | |||
| }, [chats]); | |||
| const goToMessages = () => { | |||
| history.push(`/messages/${chats[0].chat?._id}`); | |||
| props.closePopover(); | |||
| }; | |||
| const goToMessage = (chatId) => { | |||
| history.push(`/messages/${chatId}`); | |||
| props.closePopover(); | |||
| }; | |||
| return ( | |||
| <HeaderPopover | |||
| @@ -52,3 +54,7 @@ export const MyMessages = () => { | |||
| /> | |||
| ); | |||
| }; | |||
| MyMessages.propTypes = { | |||
| closePopover: PropTypes.func, | |||
| }; | |||
| @@ -1,5 +1,6 @@ | |||
| import React, { useEffect, useState } from "react"; | |||
| import { PostsImgSuit } from "./MyPosts.styled"; | |||
| import PropTypes from "prop-types"; | |||
| // const dummyData2 = [ | |||
| // { | |||
| @@ -24,7 +25,7 @@ import { selectProfileName } from "../../../store/selectors/profileSelectors"; | |||
| import { useHistory } from "react-router-dom"; | |||
| import { MY_OFFERS_PAGE } from "../../../constants/pages"; | |||
| export const MyPosts = () => { | |||
| export const MyPosts = (props) => { | |||
| const { t } = useTranslation(); | |||
| const dispatch = useDispatch(); | |||
| const mineOffers = useSelector(selectMineOffers); | |||
| @@ -71,9 +72,11 @@ export const MyPosts = () => { | |||
| const goToOffer = (id) => { | |||
| history.push(`/proizvodi/${id}`); | |||
| props.closePopover(); | |||
| }; | |||
| const goToMySwaps = () => { | |||
| history.push(MY_OFFERS_PAGE); | |||
| props.closePopover(); | |||
| }; | |||
| return ( | |||
| <HeaderPopover | |||
| @@ -84,3 +87,7 @@ export const MyPosts = () => { | |||
| /> | |||
| ); | |||
| }; | |||
| MyPosts.propTypes = { | |||
| closePopover: PropTypes.func, | |||
| }; | |||
| @@ -11,8 +11,9 @@ import { EyeIcon } from "../HeaderPopover/HeaderPopover.styled"; | |||
| import { logoutUser } from "../../../store/actions/login/loginActions"; | |||
| import { useHistory } from "react-router-dom"; | |||
| import { LOGIN_PAGE } from "../../../constants/pages"; | |||
| import PropTypes from "prop-types"; | |||
| export const MyProfile = () => { | |||
| export const MyProfile = (props) => { | |||
| const { t } = useTranslation(); | |||
| const profile = useSelector(selectMineProfile); | |||
| const userId = useSelector(selectUserId); | |||
| @@ -49,7 +50,8 @@ export const MyProfile = () => { | |||
| }; | |||
| const seeMyProfile = () => { | |||
| history.push(`/profile/${userId}`); | |||
| } | |||
| props.closePopover(); | |||
| }; | |||
| return ( | |||
| <HeaderPopover | |||
| title={t("header.myProfile")} | |||
| @@ -64,3 +66,7 @@ export const MyProfile = () => { | |||
| /> | |||
| ); | |||
| }; | |||
| MyProfile.propTypes = { | |||
| closePopover: PropTypes.func, | |||
| }; | |||
| @@ -127,7 +127,15 @@ const ProfileOffers = (props) => { | |||
| IconComponent={DownArrow} | |||
| onChange={handleChangeSelect} | |||
| > | |||
| <SelectOption | |||
| value={sortEnum.INITIAL.value} | |||
| key={sortEnum.INITIAL.value} | |||
| style={{ display: "none" }} | |||
| > | |||
| {sortEnum.INITIAL.mainText} | |||
| </SelectOption> | |||
| {Object.keys(sortEnum).map((property) => { | |||
| if (sortEnum[property].value === sortEnum.INITIAL.value) return; | |||
| return ( | |||
| <SelectOption | |||
| value={sortEnum[property].value} | |||
| @@ -52,7 +52,7 @@ const Register = () => { | |||
| setMailError(mail); | |||
| if ( | |||
| error?.error?.response?.data?.toString() === | |||
| "User with email already exists" | |||
| "User with email already exists!" | |||
| ) { | |||
| setMailErrorMessage(t("register.emailTaken")); | |||
| } else { | |||
| @@ -40,7 +40,7 @@ function* fetchRegisterUser({ payload }) { | |||
| console.log(e); | |||
| let type = "server"; | |||
| if ( | |||
| e?.response?.data?.toString() === "User with email already exists" || | |||
| e?.response?.data?.toString() === "User with email already exists!" || | |||
| e?.response?.data?.toString() === '"email" must be a valid email' | |||
| ) { | |||
| type = "mail"; | |||
| @@ -11,5 +11,6 @@ export default Yup.object().shape({ | |||
| .min(8, i18n.t("login.passwordLength")) | |||
| .minLowercase(1, i18n.t("password.strongPassword")) | |||
| .minUppercase(1, i18n.t("password.strongPassword")) | |||
| .minSymbols(1, i18n.t("password.strongPassword")), | |||
| .minSymbols(1, i18n.t("password.strongPassword")) | |||
| .minNumbers(1, i18n.t("password.strongPassword")) | |||
| }); | |||