Ver código fonte

Partly finished feature 649

feature/649
Djordje Mitrovic 3 anos atrás
pai
commit
806c36fd64

+ 8
- 2
src/AppRoutes.js Ver arquivo

MY_OFFERS_PAGE, MY_OFFERS_PAGE,
// PRICES_PAGE, // PRICES_PAGE,
ABOUT_PAGE, ABOUT_PAGE,
ADMIN_HOME_PAGE,
ADMIN_HOME_PAGE,
ADMIN_USERS_PAGE,
// POLICY_PRIVACY_PAGE, // POLICY_PRIVACY_PAGE,
} from "./constants/pages"; } from "./constants/pages";
import LoginPage from "./pages/LoginPage/LoginPage"; import LoginPage from "./pages/LoginPage/LoginPage";
import AboutPage from "./pages/About/AboutPage"; import AboutPage from "./pages/About/AboutPage";
import AuthRoute from "./components/Router/AuthRoute"; import AuthRoute from "./components/Router/AuthRoute";
import AdminHomePage from "./pages/AdminHomePage/AdminHomePage"; import AdminHomePage from "./pages/AdminHomePage/AdminHomePage";
import AdminUsersPage from "./pages/AdminUsersPage/AdminUsersPage";
// import PrivacyPolicyPage from "./pages/PrivacyPolicy/PrivacyPolicyPage"; // import PrivacyPolicyPage from "./pages/PrivacyPolicy/PrivacyPolicyPage";


const AppRoutes = () => { const AppRoutes = () => {
<AuthRoute exact path={LOGIN_PAGE} component={LoginPage} /> <AuthRoute exact path={LOGIN_PAGE} component={LoginPage} />
<AuthRoute exact path={ADMIN_LOGIN_PAGE} component={AdminLoginPage} /> <AuthRoute exact path={ADMIN_LOGIN_PAGE} component={AdminLoginPage} />
<Route path={ADMIN_HOME_PAGE} component={AdminHomePage} /> <Route path={ADMIN_HOME_PAGE} component={AdminHomePage} />
<Route path={ADMIN_USERS_PAGE} component={AdminUsersPage} />
<Route path={NOT_FOUND_PAGE} component={NotFoundPage} /> <Route path={NOT_FOUND_PAGE} component={NotFoundPage} />
<Route path={ERROR_PAGE} component={ErrorPage} /> <Route path={ERROR_PAGE} component={ErrorPage} />
<AuthRoute path={REGISTER_SUCCESSFUL_PAGE} component={RegisterSuccessful} />
<AuthRoute
path={REGISTER_SUCCESSFUL_PAGE}
component={RegisterSuccessful}
/>
<AuthRoute path={REGISTER_PAGE} component={Register} /> <AuthRoute path={REGISTER_PAGE} component={Register} />
<AuthRoute path={FORGOT_PASSWORD_MAIL_SENT} component={MailSent} /> <AuthRoute path={FORGOT_PASSWORD_MAIL_SENT} component={MailSent} />
<AuthRoute path={FORGOT_PASSWORD_PAGE} component={ForgotPasswordPage} /> <AuthRoute path={FORGOT_PASSWORD_PAGE} component={ForgotPasswordPage} />

+ 10
- 0
src/assets/images/svg/pin-outlined.svg Ver arquivo

<svg width="22" height="23" viewBox="0 0 22 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1833_10358)">
<path d="M17.5239 6.36219L16.7758 5.93024L16.4025 6.70932L14.1445 11.4218L13.9563 11.8146L14.1841 12.1859C14.8482 13.2683 15.1028 14.5843 14.8378 15.889L14.8162 15.9944C14.8162 15.9945 14.8161 15.9947 14.8161 15.9949C14.8045 16.0494 14.745 16.1479 14.6047 16.2108L14.5786 16.2225L14.5533 16.2361C14.5179 16.2551 14.4348 16.27 14.3339 16.2118L4.59109 10.5868C4.49874 10.5334 4.44062 10.442 4.4307 10.3405L4.43071 10.3405L4.43022 10.3357C4.41975 10.2349 4.46016 10.1311 4.53653 10.0637L4.53726 10.063L4.6205 9.9893L4.62095 9.9889C5.6152 9.10697 6.88296 8.67 8.15351 8.70427L8.58904 8.71602L8.83518 8.35652L11.7873 4.04478L12.2754 3.33195L11.5272 2.9L10.6279 2.38074C10.4725 2.29105 10.4192 2.09214 10.5089 1.93679C10.5986 1.78144 10.7975 1.72814 10.9529 1.81783L18.7471 6.31783C18.9029 6.4078 18.956 6.60601 18.8661 6.76179C18.7761 6.91756 18.5779 6.97072 18.4221 6.88074L17.5239 6.36219ZM8.38144 15.9217L7.09394 18.1517C7.00372 18.3079 6.80624 18.3609 6.64998 18.2706C6.49372 18.1804 6.4408 17.9829 6.53102 17.8267L7.81852 15.5967L8.38144 15.9217Z" stroke="#5A3984" stroke-width="1.6"/>
</g>
<defs>
<clipPath id="clip0_1833_10358">
<rect width="13.5" height="18" fill="white" transform="translate(9.4043) rotate(30)"/>
</clipPath>
</defs>
</svg>

+ 11
- 0
src/components/Cards/OfferCard/OfferCard.js Ver arquivo

LikeIcon, LikeIcon,
LikeIconContainer, LikeIconContainer,
CategoryIcon, CategoryIcon,
PinIconContainer,
PinOutlinedIcon,
} from "./OfferCard.styled"; } from "./OfferCard.styled";
import DeleteOffer from "./DeleteOffer/DeleteOffer"; import DeleteOffer from "./DeleteOffer/DeleteOffer";
import { ReactComponent as Message } from "../../../assets/images/svg/mail.svg"; import { ReactComponent as Message } from "../../../assets/images/svg/mail.svg";
const userId = useSelector(selectUserId); const userId = useSelector(selectUserId);
const { isMobile } = useIsMobile(); const { isMobile } = useIsMobile();


const pinOffer = (event) => {
event.stopPropagation();
};
const routeToItem = (itemId) => { const routeToItem = (itemId) => {
if (!props.disabledCheckButton) { if (!props.disabledCheckButton) {
history.push(`/proizvodi/${itemId}`); history.push(`/proizvodi/${itemId}`);
<Message /> <Message />
</MessageIcon> </MessageIcon>
)} )}
{props.isAdmin && !props.pinned && (
<PinIconContainer showMessageIcon onClick={pinOffer}>
<PinOutlinedIcon />
</PinIconContainer>
)}
{props?.offer?.pinned && <PinIcon isMyOffer={props.isMyOffer} />} {props?.offer?.pinned && <PinIcon isMyOffer={props.isMyOffer} />}
</OfferFlexContainer> </OfferFlexContainer>
</OfferCardContainer> </OfferCardContainer>
dontShowViews: PropTypes.bool, dontShowViews: PropTypes.bool,
skeleton: PropTypes.bool, skeleton: PropTypes.bool,
disabledCheckButton: PropTypes.bool, disabledCheckButton: PropTypes.bool,
isAdmin: PropTypes.bool,
}; };
OfferCard.defaultProps = { OfferCard.defaultProps = {
halfwidth: false, halfwidth: false,

+ 18
- 6
src/components/Cards/OfferCard/OfferCard.styled.js Ver arquivo

import { ReactComponent as Edit } from "../../../assets/images/svg/edit.svg"; import { ReactComponent as Edit } from "../../../assets/images/svg/edit.svg";
import { ReactComponent as Like } from "../../../assets/images/svg/like.svg"; import { ReactComponent as Like } from "../../../assets/images/svg/like.svg";
import { ReactComponent as Pin } from "../../../assets/images/svg/pin.svg"; import { ReactComponent as Pin } from "../../../assets/images/svg/pin.svg";
import { ReactComponent as PinOutlined } from "../../../assets/images/svg/pin-outlined.svg";
import { ReactComponent as Category } from "../../../assets/images/svg/category.svg"; import { ReactComponent as Category } from "../../../assets/images/svg/category.svg";


export const OfferCardContainer = styled(Container)` export const OfferCardContainer = styled(Container)`


@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
display: block; display: block;
position: ${props => props.vertical && "absolute"};
top: ${props => props.vertical && "325px"};
left: ${props => props.vertical && "59px"};
position: ${(props) => props.vertical && "absolute"};
top: ${(props) => props.vertical && "325px"};
left: ${(props) => props.vertical && "59px"};
} }
`; `;
export const RemoveIcon = styled(Remove)``; export const RemoveIcon = styled(Remove)``;
@media screen and (max-width: 600px) { @media screen and (max-width: 600px) {
position: absolute; position: absolute;
display: block; display: block;
right: ${props => !props.vertical && "64px"};
top: ${props => props.vertical && "325px"};
left: ${props => props.vertical && "18px"};
right: ${(props) => !props.vertical && "64px"};
top: ${(props) => props.vertical && "325px"};
left: ${(props) => props.vertical && "18px"};
} }
`; `;
export const EditIcon = styled(Edit)``; export const EditIcon = styled(Edit)``;
} }
`} `}
`; `;
export const PinIconContainer = styled(MessageIcon)`
right: 134px;
top: 18px;
`;
export const LikeIcon = styled(Like)` export const LikeIcon = styled(Like)`
& path { & path {
stroke: ${(props) => stroke: ${(props) =>
top: -1px; top: -1px;
} }
`; `;
export const PinOutlinedIcon = styled(PinOutlined)`
& g path {
/* fill: transparent !important; */
/* stroke-width: 2; */
/* stroke: ${selectedTheme.colors.primaryPurple} !important; */
}
`;
export const PinIcon = styled(Pin)` export const PinIcon = styled(Pin)`
position: absolute; position: absolute;
top: 20px; top: 20px;

+ 37
- 26
src/components/MarketPlace/Header/Header.js Ver arquivo

import { ArrowButton } from "../../Buttons/ArrowButton/ArrowButton"; import { ArrowButton } from "../../Buttons/ArrowButton/ArrowButton";
// import { ArrowButton } from "../../Buttons/ArrowButton/ArrowButton"; // import { ArrowButton } from "../../Buttons/ArrowButton/ArrowButton";
import history from "../../../store/utils/history"; import history from "../../../store/utils/history";
import { AccountCircle } from "@mui/icons-material";


const DownArrow = (props) => ( const DownArrow = (props) => (
<IconStyled {...props}> <IconStyled {...props}>


const Header = (props) => { const Header = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const sorting = props.sorting;
const sorting = props?.sorting;
const headerString = useSelector(selectHeaderString); const headerString = useSelector(selectHeaderString);
const { isMobile } = useIsMobile(); const { isMobile } = useIsMobile();
// Changing header string on refresh or on load // Changing header string on refresh or on load


const altString = useMemo(() => { const altString = useMemo(() => {
if (sorting.selectedSortOption === sortEnum.OLD) {
return `: ${t("header.oldOffers")}`;
}
if (sorting.selectedSortOption === sortEnum.POPULAR) {
return `: ${t("header.popularOffers")}`;
if (!props?.users) {
if (sorting?.selectedSortOption === sortEnum.OLD) {
return `: ${t("header.oldOffers")}`;
}
if (sorting?.selectedSortOption === sortEnum.POPULAR) {
return `: ${t("header.popularOffers")}`;
}
} }
return `: ${t("header.newOffers")}`; return `: ${t("header.newOffers")}`;
}, [sorting.selectedSortOption]);
}, [sorting?.selectedSortOption]);


const handleChangeSelect = (event) => { const handleChangeSelect = (event) => {
sorting.changeSorting(event.target.value);
if (!props.users) sorting?.changeSorting(event.target.value);
}; };
const handleClickCategory = () => { const handleClickCategory = () => {
props.offers.filters.locations.clear();
props.offers.filters.subcategory.clear();
props.offers.applyFilters();
props?.offers?.filters?.locations.clear();
props?.offers?.filters?.subcategory.clear();
props?.offers?.applyFilters();
}; };
const handleClickSubcategory = () => { const handleClickSubcategory = () => {
props.offers.filters.locations.clear();
props.offers.applyFilters();
props?.offers?.filters?.locations.clear();
props?.offers?.applyFilters();
}; };
const goBack = () => { const goBack = () => {
history.goBack(); history.goBack();


return ( return (
<> <>
<SkeletonHeader skeleton={props.skeleton} myOffers={props.myOffers} />
<HeaderWrapperContainer skeleton={props.skeleton} isAdmin={props.isAdmin}>
<SkeletonHeader skeleton={props?.skeleton} myOffers={props?.myOffers} />
<HeaderWrapperContainer
skeleton={props?.skeleton}
isAdmin={props?.isAdmin}
>
<HeaderContainer> <HeaderContainer>
{/* Setting appropriate header title if page is market place or my offers */} {/* Setting appropriate header title if page is market place or my offers */}
<Tooltip title={headerString.text}> <Tooltip title={headerString.text}>
<TooltipInnerContainer> <TooltipInnerContainer>
{!props.myOffers ? (
{!props?.myOffers ? (
<> <>
<CategoryHeaderIcon /> <CategoryHeaderIcon />
<HeaderLocation> <HeaderLocation>
<> <>
{!isMobile ? ( {!isMobile ? (
<HeaderTitleContainer> <HeaderTitleContainer>
<SwapsHeaderIcon />
<HeaderTitleText>{t("header.myOffers")}</HeaderTitleText>
{props.users ? <AccountCircle /> : <SwapsHeaderIcon />}
<HeaderTitleText>
{props.users
? t("admin.users.headerTitle")
: t("header.myOffers")}
</HeaderTitleText>
</HeaderTitleContainer> </HeaderTitleContainer>
) : ( ) : (
<ButtonContainer onClick={goBack}> <ButtonContainer onClick={goBack}>
{/* Setting display of offer cards to full width */} {/* Setting display of offer cards to full width */}
<HeaderButton <HeaderButton
iconColor={ iconColor={
props.isGrid
props?.isGrid
? selectedTheme.colors.iconStrokeColor ? selectedTheme.colors.iconStrokeColor
: selectedTheme.colors.primaryPurple : selectedTheme.colors.primaryPurple
} }
onClick={() => props.setIsGrid(false)}
onClick={() => props?.setIsGrid(false)}
> >
<GridLine /> <GridLine />
</HeaderButton> </HeaderButton>
{/* Setting display of offer cards to half width (Grid) */} {/* Setting display of offer cards to half width (Grid) */}
<HeaderButton <HeaderButton
iconColor={ iconColor={
props.isGrid
props?.isGrid
? selectedTheme.colors.primaryPurple ? selectedTheme.colors.primaryPurple
: selectedTheme.colors.iconStrokeColor : selectedTheme.colors.iconStrokeColor
} }
onClick={() => props.setIsGrid(true)}
onClick={() => props?.setIsGrid(true)}
> >
<GridSquare /> <GridSquare />
</HeaderButton> </HeaderButton>
{/* Select option to choose sorting */} {/* Select option to choose sorting */}
<HeaderSelect <HeaderSelect
value={ value={
sorting.selectedSortOption?.value
? sorting.selectedSortOption
sorting?.selectedSortOption?.value
? sorting?.selectedSortOption
: "default" : "default"
} }
IconComponent={DownArrow} IconComponent={DownArrow}
onChange={handleChangeSelect} onChange={handleChangeSelect}
myOffers={props.myOffers}
myOffers={props?.myOffers}
> >
<SelectOption style={{ display: "none" }} value="default"> <SelectOption style={{ display: "none" }} value="default">
{t("reviews.sortBy")} {t("reviews.sortBy")}
<PageTitleContainer> <PageTitleContainer>
<SwapsIcon /> <SwapsIcon />
<SwapsTitle> <SwapsTitle>
{props.myOffers ? t("header.myOffers") : t("offer.offers")}
{props?.myOffers ? t("header.myOffers") : t("offer.offers")}
</SwapsTitle> </SwapsTitle>
</PageTitleContainer> </PageTitleContainer>
)} )}
skeleton: PropTypes.bool, skeleton: PropTypes.bool,
sorting: PropTypes.any, sorting: PropTypes.any,
isAdmin: PropTypes.bool, isAdmin: PropTypes.bool,
users: PropTypes.bool,
}; };
Header.defaultProps = { Header.defaultProps = {
isGrid: false, isGrid: false,

+ 10
- 0
src/components/MarketPlace/MarketPlace.js Ver arquivo

offers={props.offers} offers={props.offers}
skeleton={props.skeleton} skeleton={props.skeleton}
isAdmin={props.isAdmin} isAdmin={props.isAdmin}
users={props.users}
/> />
<Offers <Offers
isGrid={isGrid} isGrid={isGrid}
offers: PropTypes.any, offers: PropTypes.any,
toggleFilters: PropTypes.func, toggleFilters: PropTypes.func,
isAdmin: PropTypes.bool, isAdmin: PropTypes.bool,
users: PropTypes.bool,
};
MarketPlace.defaultProps = {
offers: {
sorting: {},
filters: {
numOfFiltersChosen: 0,
},
},
}; };


export default MarketPlace; export default MarketPlace;

+ 4
- 1
src/components/MarketPlace/Offers/HeaderMyOffers.js/HeadersMyOffers.js Ver arquivo

import React, { useCallback, useRef } from "react";
import React, { useCallback, useEffect, useRef } from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { EndIcon, SearchIcon, SearchInput } from "./HeadersMyOffers.styled"; import { EndIcon, SearchIcon, SearchInput } from "./HeadersMyOffers.styled";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
}, },
[searchRef.current] [searchRef.current]
); );
useEffect(() => {
searchRef.current.value = search.searchString || "";
}, []);
const handleFocusSearch = () => { const handleFocusSearch = () => {
searchRef.current.addEventListener("keyup", listener); searchRef.current.addEventListener("keyup", listener);
}; };

+ 18
- 17
src/components/MarketPlace/Offers/Offers.js Ver arquivo

const chats = useSelector(selectLatestChats); const chats = useSelector(selectLatestChats);
const offersRef = useRef(null); const offersRef = useRef(null);
const userId = useSelector(selectUserId); const userId = useSelector(selectUserId);
const offers = props.offers;
const offers = props?.offers;
// For skeleton screen // For skeleton screen
const arrayForMapping = Array.apply(null, Array(4)).map(() => {}); const arrayForMapping = Array.apply(null, Array(4)).map(() => {});


startChat(chats, offer, userId); startChat(chats, offer, userId);
}; };
const toggleFilters = () => { const toggleFilters = () => {
props.toggleFilters();
props?.toggleFilters();
}; };


return ( return (
<> <>
{!props.skeleton ? (
{!props?.skeleton ? (
<> <>
<FilterContainer <FilterContainer
isAdmin={props.isAdmin}
isAdmin={props?.isAdmin}
onClick={toggleFilters} onClick={toggleFilters}
number={offers.filters.numOfFiltersChosen}
myOffers={props.myOffers}
number={offers?.filters?.numOfFiltersChosen}
myOffers={props?.myOffers}
> >
<FilterIcon /> <FilterIcon />
</FilterContainer> </FilterContainer>
{(props.myOffers || props.isAdmin) && (
{(props?.myOffers || props?.isAdmin) && (
<HeadersMyOffers <HeadersMyOffers
searchMyOffers={offers.search.searchOffers}
handleSearch={offers.apply}
isAdmin={props.isAdmin}
searchMyOffers={offers?.search?.searchOffers}
handleSearch={offers?.apply}
isAdmin={props?.isAdmin}
offers={offers} offers={offers}
/> />
)} )}
{offers.allOffersToShow.length === 0 ? (
{offers?.allOffersToShow?.length === 0 ? (
<OffersNotFound /> <OffersNotFound />
) : ( ) : (
<OffersContainer ref={offersRef}> <OffersContainer ref={offersRef}>
{offers.allOffersToShow.map((item) => {
{offers?.allOffersToShow?.map((item) => {
return ( return (
<OfferCard <OfferCard
key={item._id} key={item._id}
offer={item} offer={item}
halfwidth={props.isGrid}
halfwidth={props?.isGrid}
messageUser={messageOneUser} messageUser={messageOneUser}
isMyOffer={item?.userId === userId || props.isAdmin}
isMyOffer={item?.userId === userId || props?.isAdmin}
isAdmin={props?.isAdmin}
/> />
); );
})} })}
<Paging <Paging
totalElements={offers.totalOffers}
totalElements={offers?.totalOffers}
elementsPerPage={10} elementsPerPage={10}
current={parseInt(offers.paging.currentPage)}
changePage={offers.paging.changePage}
current={parseInt(offers?.paging?.currentPage)}
changePage={offers?.paging?.changePage}
/> />
</OffersContainer> </OffersContainer>
)} )}

+ 1
- 0
src/constants/pages.js Ver arquivo

export const PRICES_PAGE = "/prices"; export const PRICES_PAGE = "/prices";
export const POLICY_PRIVACY_PAGE = "/policy"; export const POLICY_PRIVACY_PAGE = "/policy";
export const ADMIN_HOME_PAGE = "/admin/home"; export const ADMIN_HOME_PAGE = "/admin/home";
export const ADMIN_USERS_PAGE = "/admin/users";

+ 3
- 0
src/i18n/resources/rs.js Ver arquivo

passwordRequired: "Lozinka je obavezna!", passwordRequired: "Lozinka je obavezna!",
wrongCredentials: "Pogrešan mail ili lozinka!", wrongCredentials: "Pogrešan mail ili lozinka!",
headerTitle: "Ulogujte se", headerTitle: "Ulogujte se",
},
users: {
headerTitle: "Profili korisnika"
} }
} }
}; };

+ 7
- 1
src/pages/AdminHomePage/AdminHomePage.js Ver arquivo

import PropTypes from "prop-types"; import PropTypes from "prop-types";
import MarketPlace from "../../components/MarketPlace/MarketPlace"; import MarketPlace from "../../components/MarketPlace/MarketPlace";
import useOffers from "../../hooks/useOffers/useOffers"; import useOffers from "../../hooks/useOffers/useOffers";
import { useSelector } from "react-redux";
import { selectIsLoadingByActionType } from "../../store/selectors/loadingSelectors";
import { OFFERS_SCOPE } from "../../store/actions/offers/offersActionConstants";


const AdminHomePage = () => { const AdminHomePage = () => {
const offers = useOffers(); const offers = useOffers();
return <MarketPlace offers={offers} isAdmin />;
const isLoadingOffers = useSelector(
selectIsLoadingByActionType(OFFERS_SCOPE)
);
return <MarketPlace offers={offers} isAdmin skeleton={isLoadingOffers} />;
}; };


AdminHomePage.propTypes = { AdminHomePage.propTypes = {

+ 13
- 0
src/pages/AdminUsersPage/AdminUsersPage.js Ver arquivo

import React from "react";
import PropTypes from "prop-types";
import MarketPlace from "../../components/MarketPlace/MarketPlace";

const AdminUsersPage = () => {
return <MarketPlace isAdmin myOffers users />;
};

AdminUsersPage.propTypes = {
children: PropTypes.node,
};

export default AdminUsersPage;

+ 1
- 0
src/store/saga/loginSaga.js Ver arquivo

const accessToken = { const accessToken = {
token: token, token: token,
exp: tokenDecoded.exp, exp: tokenDecoded.exp,
roles: tokenDecoded.roles,
}; };
const refreshToken = { const refreshToken = {
token: refresh, token: refresh,

+ 6
- 1
src/util/helpers/routeHelpers.js Ver arquivo

import { import {
ADMIN_HOME_PAGE, ADMIN_HOME_PAGE,
ADMIN_LOGIN_PAGE, ADMIN_LOGIN_PAGE,
ADMIN_USERS_PAGE,
FORGOT_PASSWORD_MAIL_SENT, FORGOT_PASSWORD_MAIL_SENT,
FORGOT_PASSWORD_PAGE, FORGOT_PASSWORD_PAGE,
LOGIN_PAGE, LOGIN_PAGE,
return false; return false;
}; };
export const isAdminRoute = () => { export const isAdminRoute = () => {
if (routeMatches(ADMIN_LOGIN_PAGE) || routeMatches(ADMIN_HOME_PAGE))
if (
routeMatches(ADMIN_LOGIN_PAGE) ||
routeMatches(ADMIN_HOME_PAGE) ||
routeMatches(ADMIN_USERS_PAGE)
)
return true; return true;
return false; return false;
}; };

Carregando…
Cancelar
Salvar