| }, | }, | ||||
| }); | }); | ||||
| }; | }; | ||||
| const closePostsPopover = () => { | |||||
| setPostsPopoverOpen(false); | |||||
| setPostsAnchorEl(null); | |||||
| } | |||||
| const closeMsgPopover = () => { | |||||
| setMsgPopoverOpen(false); | |||||
| setMsgAnchorEl(null); | |||||
| } | |||||
| const closeUserPopover = () => { | |||||
| setUserPopoverOpen(false); | |||||
| setUserAnchorEl(null); | |||||
| } | |||||
| return ( | return ( | ||||
| <HeaderContainer style={{ display: shouldShow ? "block" : "none" }}> | <HeaderContainer style={{ display: shouldShow ? "block" : "none" }}> | ||||
| setPostsPopoverOpen(false); | setPostsPopoverOpen(false); | ||||
| setPostsAnchorEl(null); | setPostsAnchorEl(null); | ||||
| }} | }} | ||||
| content={<MyPosts />} | |||||
| content={<MyPosts closePopover={closePostsPopover} />} | |||||
| /> | /> | ||||
| <PopoverComponent | <PopoverComponent | ||||
| anchorEl={msgAnchorEl} | anchorEl={msgAnchorEl} | ||||
| setMsgPopoverOpen(false); | setMsgPopoverOpen(false); | ||||
| setMsgAnchorEl(null); | setMsgAnchorEl(null); | ||||
| }} | }} | ||||
| content={<MyMessages />} | |||||
| content={<MyMessages closePopover={closeMsgPopover}/>} | |||||
| /> | /> | ||||
| <PopoverComponent | <PopoverComponent | ||||
| anchorEl={userAnchorEl} | anchorEl={userAnchorEl} | ||||
| setUserPopoverOpen(false); | setUserPopoverOpen(false); | ||||
| setUserAnchorEl(null); | setUserAnchorEl(null); | ||||
| }} | }} | ||||
| content={<MyProfile />} | |||||
| content={<MyProfile closePopover={closeUserPopover} />} | |||||
| /> | /> | ||||
| </React.Fragment> | </React.Fragment> | ||||
| )} | )} |
| import { selectLatestChats } from "../../../store/selectors/chatSelectors"; | import { selectLatestChats } from "../../../store/selectors/chatSelectors"; | ||||
| import { selectUserId } from "../../../store/selectors/loginSelectors"; | import { selectUserId } from "../../../store/selectors/loginSelectors"; | ||||
| import HeaderPopover from "../HeaderPopover/HeaderPopover"; | import HeaderPopover from "../HeaderPopover/HeaderPopover"; | ||||
| import PropTypes from "prop-types"; | |||||
| export const MyMessages = () => { | |||||
| export const MyMessages = (props) => { | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| const userId = useSelector(selectUserId); | const userId = useSelector(selectUserId); | ||||
| const history = useHistory(); | const history = useHistory(); | ||||
| const [lastChats, setLastChats] = useState([]); | const [lastChats, setLastChats] = useState([]); | ||||
| const goToMessage = (chatId) => { | |||||
| history.push(`/messages/${chatId}`); | |||||
| }; | |||||
| const convertMessages = (messages) => { | const convertMessages = (messages) => { | ||||
| return messages | return messages | ||||
| .map((item) => ({ | .map((item) => ({ | ||||
| }, [chats]); | }, [chats]); | ||||
| const goToMessages = () => { | const goToMessages = () => { | ||||
| history.push(`/messages/${chats[0].chat?._id}`); | history.push(`/messages/${chats[0].chat?._id}`); | ||||
| props.closePopover(); | |||||
| }; | |||||
| const goToMessage = (chatId) => { | |||||
| history.push(`/messages/${chatId}`); | |||||
| props.closePopover(); | |||||
| }; | }; | ||||
| return ( | return ( | ||||
| <HeaderPopover | <HeaderPopover | ||||
| /> | /> | ||||
| ); | ); | ||||
| }; | }; | ||||
| MyMessages.propTypes = { | |||||
| closePopover: PropTypes.func, | |||||
| }; |
| import React, { useEffect, useState } from "react"; | import React, { useEffect, useState } from "react"; | ||||
| import { PostsImgSuit } from "./MyPosts.styled"; | import { PostsImgSuit } from "./MyPosts.styled"; | ||||
| import PropTypes from "prop-types"; | |||||
| // const dummyData2 = [ | // const dummyData2 = [ | ||||
| // { | // { | ||||
| import { useHistory } from "react-router-dom"; | import { useHistory } from "react-router-dom"; | ||||
| import { MY_OFFERS_PAGE } from "../../../constants/pages"; | import { MY_OFFERS_PAGE } from "../../../constants/pages"; | ||||
| export const MyPosts = () => { | |||||
| export const MyPosts = (props) => { | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| const mineOffers = useSelector(selectMineOffers); | const mineOffers = useSelector(selectMineOffers); | ||||
| const goToOffer = (id) => { | const goToOffer = (id) => { | ||||
| history.push(`/proizvodi/${id}`); | history.push(`/proizvodi/${id}`); | ||||
| props.closePopover(); | |||||
| }; | }; | ||||
| const goToMySwaps = () => { | const goToMySwaps = () => { | ||||
| history.push(MY_OFFERS_PAGE); | history.push(MY_OFFERS_PAGE); | ||||
| props.closePopover(); | |||||
| }; | }; | ||||
| return ( | return ( | ||||
| <HeaderPopover | <HeaderPopover | ||||
| /> | /> | ||||
| ); | ); | ||||
| }; | }; | ||||
| MyPosts.propTypes = { | |||||
| closePopover: PropTypes.func, | |||||
| }; |
| import { logoutUser } from "../../../store/actions/login/loginActions"; | import { logoutUser } from "../../../store/actions/login/loginActions"; | ||||
| import { useHistory } from "react-router-dom"; | import { useHistory } from "react-router-dom"; | ||||
| import { LOGIN_PAGE } from "../../../constants/pages"; | import { LOGIN_PAGE } from "../../../constants/pages"; | ||||
| import PropTypes from "prop-types"; | |||||
| export const MyProfile = () => { | |||||
| export const MyProfile = (props) => { | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const profile = useSelector(selectMineProfile); | const profile = useSelector(selectMineProfile); | ||||
| const userId = useSelector(selectUserId); | const userId = useSelector(selectUserId); | ||||
| }; | }; | ||||
| const seeMyProfile = () => { | const seeMyProfile = () => { | ||||
| history.push(`/profile/${userId}`); | history.push(`/profile/${userId}`); | ||||
| } | |||||
| props.closePopover(); | |||||
| }; | |||||
| return ( | return ( | ||||
| <HeaderPopover | <HeaderPopover | ||||
| title={t("header.myProfile")} | title={t("header.myProfile")} | ||||
| /> | /> | ||||
| ); | ); | ||||
| }; | }; | ||||
| MyProfile.propTypes = { | |||||
| closePopover: PropTypes.func, | |||||
| }; |
| IconComponent={DownArrow} | IconComponent={DownArrow} | ||||
| onChange={handleChangeSelect} | onChange={handleChangeSelect} | ||||
| > | > | ||||
| <SelectOption | |||||
| value={sortEnum.INITIAL.value} | |||||
| key={sortEnum.INITIAL.value} | |||||
| style={{ display: "none" }} | |||||
| > | |||||
| {sortEnum.INITIAL.mainText} | |||||
| </SelectOption> | |||||
| {Object.keys(sortEnum).map((property) => { | {Object.keys(sortEnum).map((property) => { | ||||
| if (sortEnum[property].value === sortEnum.INITIAL.value) return; | |||||
| return ( | return ( | ||||
| <SelectOption | <SelectOption | ||||
| value={sortEnum[property].value} | value={sortEnum[property].value} |
| setMailError(mail); | setMailError(mail); | ||||
| if ( | if ( | ||||
| error?.error?.response?.data?.toString() === | error?.error?.response?.data?.toString() === | ||||
| "User with email already exists" | |||||
| "User with email already exists!" | |||||
| ) { | ) { | ||||
| setMailErrorMessage(t("register.emailTaken")); | setMailErrorMessage(t("register.emailTaken")); | ||||
| } else { | } else { |
| console.log(e); | console.log(e); | ||||
| let type = "server"; | let type = "server"; | ||||
| if ( | 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' | e?.response?.data?.toString() === '"email" must be a valid email' | ||||
| ) { | ) { | ||||
| type = "mail"; | type = "mail"; |
| .min(8, i18n.t("login.passwordLength")) | .min(8, i18n.t("login.passwordLength")) | ||||
| .minLowercase(1, i18n.t("password.strongPassword")) | .minLowercase(1, i18n.t("password.strongPassword")) | ||||
| .minUppercase(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")) | |||||
| }); | }); |