Djordje Mitrovic hace 3 años
padre
commit
85374f74e9

+ 1
- 1
src/components/Cards/CreateOfferCard/CreateOffer.js Ver fichero

// Create (or edit) offer // Create (or edit) offer
const handleSubmitOffer = () => { const handleSubmitOffer = () => {
if (editOffer) { if (editOffer) {
dispatch(editOneOffer(offer._id, offerData));
dispatch(editOneOffer({offerId: offer._id, offerData, handleApiResponseSuccess}));
} else { } else {
dispatch(addOffer({ offerData, handleApiResponseSuccess })); dispatch(addOffer({ offerData, handleApiResponseSuccess }));
} }

+ 2
- 2
src/components/Cards/MessageCard/MessageCard.js Ver fichero

MessageText, MessageText,
ProfileImage, ProfileImage,
} from "./MessageCard.styled"; } from "./MessageCard.styled";
import { formatDateTime } from "../../../util/helpers/dateHelpers";
import useIsMobile from "../../../hooks/useIsMobile"; import useIsMobile from "../../../hooks/useIsMobile";
import { getImageUrl, variants } from "../../../util/helpers/imageUrlGetter"; import { getImageUrl, variants } from "../../../util/helpers/imageUrlGetter";
import { getMessageDate } from "../../../util/helpers/dateHelpers";


const MessageCard = (props) => { const MessageCard = (props) => {
const message = props.message; const message = props.message;
const { isMobile } = useIsMobile(); const { isMobile } = useIsMobile();


const dateString = formatDateTime(new Date(message._created));
const dateString = getMessageDate(new Date(message._created));
return ( return (
<MessageCardContainer ismymessage={props.isMyMessage}> <MessageCardContainer ismymessage={props.isMyMessage}>
<ProfileImage <ProfileImage

+ 2
- 0
src/components/Cards/MessageCard/MessageCard.styled.js Ver fichero

export const ProfileImage = styled.img` export const ProfileImage = styled.img`
width: 54px; width: 54px;
height: 54px; height: 54px;
min-width: 54px;
overflow: hidden; overflow: hidden;
border-radius: 100%; border-radius: 100%;
@media (max-width: 600px) { @media (max-width: 600px) {
border-radius: ${(props) => border-radius: ${(props) =>
props.ismymessage ? "9px 0px 9px 9px" : "0px 9px 9px 9px"}; props.ismymessage ? "9px 0px 9px 9px" : "0px 9px 9px 9px"};
padding: 9px; padding: 9px;
padding-bottom: 31px;
position: relative; position: relative;
min-height: 65px; min-height: 65px;
margin: 0 18px; margin: 0 18px;

+ 0
- 1
src/components/Cards/ProfileCard/ProfileCard.js Ver fichero

const profileFromRedux = useSelector(selectProfile); const profileFromRedux = useSelector(selectProfile);
const userId = useSelector(selectUserId); const userId = useSelector(selectUserId);
const idProfile = useMemo(() => { const idProfile = useMemo(() => {
console.log("routematch", routeMatch);
return routeMatch.params.idProfile; return routeMatch.params.idProfile;
}, [routeMatch.params.idProfile]); }, [routeMatch.params.idProfile]);
const { t } = useTranslation(); const { t } = useTranslation();

+ 0
- 1
src/components/DirectChat/DirectChat.js Ver fichero

// Listener to socket.IO chat // Listener to socket.IO chat
useEffect(() => { useEffect(() => {
addMesageListener(({ succeed, data }) => { addMesageListener(({ succeed, data }) => {
console.log(succeed);
if (succeed) { if (succeed) {
if ( if (
[...allChats].find((item) => { [...allChats].find((item) => {

+ 2
- 1
src/components/DirectChat/DirectChatNewMessage/DirectChatNewMessage.js Ver fichero

import { selectExchange } from "../../../store/selectors/exchangeSelector"; import { selectExchange } from "../../../store/selectors/exchangeSelector";
import { validateExchange } from "../../../store/actions/exchange/exchangeActions"; import { validateExchange } from "../../../store/actions/exchange/exchangeActions";
import NotAllowedChat from "./NotAllowedChat/NotAllowedChat"; import NotAllowedChat from "./NotAllowedChat/NotAllowedChat";
import { convertLocalDateToUTCDate } from "../../../util/helpers/dateHelpers";


const DirectChatNewMessage = (props) => { const DirectChatNewMessage = (props) => {
const [typedValue, setTypedValue] = useState(""); const [typedValue, setTypedValue] = useState("");
message: { message: {
userId, userId,
text: typedValue, text: typedValue,
_created: new Date().toISOString(),
_created: convertLocalDateToUTCDate(new Date()),
}, },
}) })
); );

+ 37
- 13
src/components/MarketPlace/Header/Header.js Ver fichero

HeaderAltLocation, HeaderAltLocation,
HeaderButton, HeaderButton,
HeaderButtons, HeaderButtons,
HeaderCategoryString,
HeaderContainer, HeaderContainer,
HeaderLocation, HeaderLocation,
HeaderLocationsMainString,
HeaderLocationsString,
HeaderOptions, HeaderOptions,
HeaderSelect, HeaderSelect,
HeaderSubcategoryString,
// HeaderText, // HeaderText,
HeaderTitleContainer, HeaderTitleContainer,
HeaderTitleText, HeaderTitleText,
SwapsHeaderIcon, SwapsHeaderIcon,
SwapsIcon, SwapsIcon,
SwapsTitle, SwapsTitle,
TooltipInnerContainer,
} from "./Header.styled"; } from "./Header.styled";
import { ReactComponent as GridSquare } from "../../../assets/images/svg/offer-grid-square.svg"; import { ReactComponent as GridSquare } from "../../../assets/images/svg/offer-grid-square.svg";
import { ReactComponent as GridLine } from "../../../assets/images/svg/offer-grid-line.svg"; import { ReactComponent as GridLine } from "../../../assets/images/svg/offer-grid-line.svg";


const altString = useMemo(() => { const altString = useMemo(() => {
if (sorting.selectedSortOption === sortEnum.OLD) { if (sorting.selectedSortOption === sortEnum.OLD) {
return t("header.oldOffers");
return `: ${t("header.oldOffers")}`;
} }
if (sorting.selectedSortOption === sortEnum.POPULAR) { if (sorting.selectedSortOption === sortEnum.POPULAR) {
return t("header.popularOffers");
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); sorting.changeSorting(event.target.value);
}; };
// const goBack = () => {
// history.goBack();
// };
const handleClickCategory = () => {
props.offers.filters.locations.clear();
props.offers.filters.subcategory.clear();
props.offers.applyFilters();
};
const handleClickSubcategory = () => {
props.offers.filters.locations.clear();
props.offers.applyFilters();
};


return ( return (
<> <>
<HeaderWrapperContainer skeleton={props.skeleton}> <HeaderWrapperContainer skeleton={props.skeleton}>
<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}>
<>
<Tooltip title={headerString.text}>
<TooltipInnerContainer>
{!props.myOffers ? ( {!props.myOffers ? (
<> <>
<CategoryHeaderIcon /> <CategoryHeaderIcon />
<HeaderLocation initial={altString}>
{headerString}
<HeaderLocation>
{/* {headerString} */}
<HeaderCategoryString component="span" onClick={handleClickCategory}>
{headerString.categoryString}
{headerString.subcategoryString && <>&nbsp;</>}
</HeaderCategoryString>
<HeaderSubcategoryString component="span" onClick={handleClickSubcategory}>
{headerString.subcategoryString}
{headerString.locationsString && <>&nbsp;</>}
</HeaderSubcategoryString>
<HeaderLocationsString component="span">
<HeaderLocationsMainString component="span">
{headerString.locationsString}
</HeaderLocationsMainString>
<HeaderAltLocation component="span">{altString}</HeaderAltLocation>
</HeaderLocationsString>
</HeaderLocation> </HeaderLocation>
<HeaderAltLocation>{altString}</HeaderAltLocation>
</> </>
) : ( ) : (
<HeaderTitleContainer> <HeaderTitleContainer>
<HeaderTitleText>{t("header.myOffers")}</HeaderTitleText> <HeaderTitleText>{t("header.myOffers")}</HeaderTitleText>
</HeaderTitleContainer> </HeaderTitleContainer>
)} )}
</>
</TooltipInnerContainer>
</Tooltip> </Tooltip>
{/* ^^^^^^ */} {/* ^^^^^^ */}


children: PropTypes.node, children: PropTypes.node,
setIsGrid: PropTypes.func, setIsGrid: PropTypes.func,
isGrid: PropTypes.bool, isGrid: PropTypes.bool,
filters: PropTypes.any,
offers: PropTypes.any,
category: PropTypes.string, category: PropTypes.string,
myOffers: PropTypes.bool, myOffers: PropTypes.bool,
skeleton: PropTypes.bool, skeleton: PropTypes.bool,

+ 73
- 10
src/components/MarketPlace/Header/Header.styled.js Ver fichero

justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
`; `;
export const HeaderLocation = styled(Box)`
export const TooltipInnerContainer = styled(Box)`
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
& * {
display: inline;
}
`;
export const HeaderLocation = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont}; font-family: ${selectedTheme.fonts.textFont};
color: ${selectedTheme.colors.primaryPurple}; color: ${selectedTheme.colors.primaryPurple};
font-weight: 700; font-weight: 700;
font-size: 16px; font-size: 16px;
flex: 2; flex: 2;
margin-left: 9px; margin-left: 9px;
max-width: ${(props) => (props.initial ? "fit-content" : "50%")};
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 50%;
position: relative;
top: -2px;
&:after { &:after {
content: ${(props) => (props.initial ? `":"` : `""`)}; content: ${(props) => (props.initial ? `":"` : `""`)};
@media (max-width: 600px) { @media (max-width: 600px) {
padding-top: 3px; padding-top: 3px;
} }
`; `;
export const HeaderCategoryString = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont};
color: ${selectedTheme.colors.primaryPurple};
font-weight: 700;
line-height: 22px;
font-size: 16px;
/* position: relative;
bottom: 2px; */
cursor: pointer;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
`;
export const HeaderSubcategoryString = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont};
color: ${selectedTheme.colors.primaryPurple};
font-weight: 700;
line-height: 22px;
font-size: 16px;
/* position: relative;
bottom: 2px; */
cursor: pointer;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
`;
export const HeaderLocationsString = styled(Typography)`
/* position: relative;
bottom: 2px; */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
max-width: 100%;
`;
export const HeaderLocationsMainString = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont};
max-width: 200px;
color: ${selectedTheme.colors.primaryPurple};
font-weight: 700;
line-height: 22px;
font-size: 16px;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
`;
export const HeaderButton = styled(IconButton)` export const HeaderButton = styled(IconButton)`
padding: 2px 10px; padding: 2px 10px;
@media (max-width: 1500px) { @media (max-width: 1500px) {
font-family: ${selectedTheme.fonts.textFont}; font-family: ${selectedTheme.fonts.textFont};
font-size: 16px; font-size: 16px;
color: ${selectedTheme.colors.primaryText}; color: ${selectedTheme.colors.primaryText};
margin-left: 5px;
position: relative;
top: 0.5px;
@media (max-width: 600px) { @media (max-width: 600px) {
display: none; display: none;
} }
left: 9px; left: 9px;
`; `;
export const CategoryHeaderIcon = styled(CategoryHeader)` export const CategoryHeaderIcon = styled(CategoryHeader)`
position: relative;
top: 4px;
@media (max-width: 600px) { @media (max-width: 600px) {
width: 12px; width: 12px;
height: 12px; height: 12px;
position: relative;
top: 1px; top: 1px;
} }
`; `;
export const SwapsHeaderIcon = styled(SwapsIcon)` export const SwapsHeaderIcon = styled(SwapsIcon)`
width: 18px; width: 18px;
height: 18px; height: 18px;
`
`;
export const HeaderTitleContainer = styled(Box)` export const HeaderTitleContainer = styled(Box)`
position: relative; position: relative;
left: 5px; left: 5px;
`
`;
export const HeaderTitleText = styled(Typography)` export const HeaderTitleText = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont}; font-family: ${selectedTheme.fonts.textFont};
color: ${selectedTheme.colors.primaryText}; color: ${selectedTheme.colors.primaryText};
font-size: 16px; font-size: 16px;
position: relative; position: relative;
bottom: 2px; bottom: 2px;
`
`;

+ 1
- 0
src/components/MarketPlace/MarketPlace.js Ver fichero

setIsGrid={setIsGrid} setIsGrid={setIsGrid}
myOffers={props.myOffers} myOffers={props.myOffers}
sorting={props.offers.sorting} sorting={props.offers.sorting}
offers={props.offers}
skeleton={props.skeleton} skeleton={props.skeleton}
/> />
<Offers <Offers

+ 0
- 1
src/components/Popovers/PhonePopover/PhonePopover.js Ver fichero



const PhonePopover = (props) => { const PhonePopover = (props) => {
const {t} = useTranslation(); const {t} = useTranslation();
console.log(props);
return ( return (
<PhonePopoverContainer> <PhonePopoverContainer>
<Arrow /> <Arrow />

+ 8
- 1
src/hooks/useOffers/useOffers.js Ver fichero

import { setQueryString } from "../../store/actions/queryString/queryStringActions"; import { setQueryString } from "../../store/actions/queryString/queryStringActions";
import { import {
convertQueryStringForBackend, convertQueryStringForBackend,
makeHeaderStringFromQueryObjectHelper,
makeHeaderStringHelper, makeHeaderStringHelper,
makeQueryStringHelper, makeQueryStringHelper,
} from "../../util/helpers/queryHelpers"; } from "../../util/helpers/queryHelpers";
useEffect(() => { useEffect(() => {
const headerStringLocal = makeHeaderStringHelper(filters); const headerStringLocal = makeHeaderStringHelper(filters);
dispatch(setHeaderString(headerStringLocal)); dispatch(setHeaderString(headerStringLocal));
}, [queryStringHook.queryString]);
}, [queryStringHook.queryString, filtersCleared]);


// Initially set category, location and subcategory based on query string // Initially set category, location and subcategory based on query string
useEffect(() => { useEffect(() => {
search.clear(); search.clear();
} }
dispatch(setSearchString(queryObject[KEY_SEARCH])); dispatch(setSearchString(queryObject[KEY_SEARCH]));
dispatch(setHeaderString(makeHeaderStringFromQueryObjectHelper(queryObject)));
} }
}, [queryStringHook.isInitiallyLoaded]); }, [queryStringHook.isInitiallyLoaded]);


dispatch(setQueryString(convertQueryStringForBackend(newQueryString))); dispatch(setQueryString(convertQueryStringForBackend(newQueryString)));
}; };


const applyFilters = () => {
setFiltersCleared(true);
};

const clearFiltersAndApply = () => { const clearFiltersAndApply = () => {
clear(); clear();
setFiltersCleared(true); setFiltersCleared(true);
queryStringHook, queryStringHook,
allOffersToShow, allOffersToShow,
totalOffers, totalOffers,
applyFilters,
clearFiltersAndApply, clearFiltersAndApply,
clearOnlyFiltersAndApply, clearOnlyFiltersAndApply,
apply, apply,

+ 0
- 1
src/pages/RegisterPages/Register/Register.js Ver fichero

registerUser({ ...informations, ...values }); registerUser({ ...informations, ...values });
} }
} }
console.log({...informations, ...values})
setInformations({ ...informations, ...values }); setInformations({ ...informations, ...values });
}; };



+ 6
- 1
src/store/reducers/filters/filtersReducer.js Ver fichero

sortOption: null, sortOption: null,
isApplied: false, isApplied: false,
queryString: "", queryString: "",
headerString: "",
headerString: {
categoryString: "",
subcategoryString: "",
locationsString: "",
text: ""
},
searchString: "" searchString: ""
}, },
}; };

+ 47
- 18
src/util/helpers/dateHelpers.js Ver fichero

import { format } from 'date-fns';
// import { enUS } from 'date-fns/locale';
import i18next from 'i18next';
import { format } from "date-fns";
import { enUS, sr } from "date-fns/locale";
import i18next from "i18next";


export function formatDate(date, fmt = 'MM/dd/y', locale) {
export function formatDate(date, fmt = "MM/dd/y", locale = sr) {
const dt = new Date(date); const dt = new Date(date);
return format(dt, fmt, { locale }); return format(dt, fmt, { locale });
} }


export function formatDateTime(date) {
export function formatDateTime(date, locale = enUS) {
const dt = new Date(date); const dt = new Date(date);
return format(dt, 'MM.dd.y hh:mm');
return format(dt, "MM.dd.y hh:mm"), { locale };
} }


export function getDateDay(date) { export function getDateDay(date) {
const dt = new Date(date); const dt = new Date(date);
return format(dt, 'dd');
return format(dt, "dd");
} }


export function getDateMonth(date) { export function getDateMonth(date) {
const dt = new Date(date); const dt = new Date(date);
return format(dt, 'MM');
return format(dt, "MM");
} }


export function getDateYear(date) { export function getDateYear(date) {
const dt = new Date(date); const dt = new Date(date);
return format(dt, 'y');
return format(dt, "y");
} }


export function formatDateTimeLocale(date) { export function formatDateTimeLocale(date) {
const dt = new Date(date);
return format(dt, 'MM/dd/y hh:mm aa');
const dayCreated =
date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
const monthCreated =
date.getMonth() < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
const yearCreated = date.getFullYear();
const hourCreated =
date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
const minutesCreated =
date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
return `${dayCreated}.${monthCreated}.${yearCreated} ${hourCreated}:${minutesCreated}`;
} }


// TODO add locale // TODO add locale
export function formatDateRange(dates) { export function formatDateRange(dates) {
const start = formatDate(dates.start); const start = formatDate(dates.start);
const end = formatDate(dates.end); const end = formatDate(dates.end);
return i18next.t('common.date.range', { start, end });
return i18next.t("common.date.range", { start, end });
} }


export function formatDateLocale(date) { export function formatDateLocale(date) {
const dayCreated = const dayCreated =
date.getDate() < 10
? "0" + date.getDate()
: date.getDate();
date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
const monthCreated = const monthCreated =
date.getMonth() < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1;
date.getMonth() < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
const yearCreated = date.getFullYear(); const yearCreated = date.getFullYear();
return `${dayCreated}.${monthCreated}.${yearCreated}`; return `${dayCreated}.${monthCreated}.${yearCreated}`;
} }
export function convertUTCDateToLocalDate(date) {
var newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);

var offset = date.getTimezoneOffset() / 60;
var hours = date.getHours();

newDate.setHours(hours - offset);

return newDate;
}
export function convertLocalDateToUTCDate(date) {
var newDate = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);

var offset = date.getTimezoneOffset() / 60;
var hours = date.getHours();

newDate.setHours(hours + offset);

return newDate;
}
export function getMessageDate(date) {
const blankTime = new Date(date.toISOString());
const newDate = convertUTCDateToLocalDate(blankTime);
return formatDateTimeLocale(newDate);
}

+ 51
- 8
src/util/helpers/queryHelpers.js Ver fichero

}; };


export const makeHeaderStringHelper = (filters) => { export const makeHeaderStringHelper = (filters) => {
let headerStringLocal = ALL_CATEGORIES;
let categoryString = `${ALL_CATEGORIES}`;
let subcategoryString = "";
let locationsString = "";
// Adding category to header string // Adding category to header string
if (filters?.category?.selectedCategory?.name) { if (filters?.category?.selectedCategory?.name) {
headerStringLocal = filters.category.selectedCategory?.name;
categoryString = filters.category.selectedCategory?.name;
// Adding subcategories to header string // Adding subcategories to header string
if (filters.subcategory.selectedSubcategory?.name) { if (filters.subcategory.selectedSubcategory?.name) {
headerStringLocal += `${SPREAD}${filters.subcategory.selectedSubcategory.name}`;
subcategoryString = `${SPREAD}${filters.subcategory.selectedSubcategory.name}`;
} }
} }
// Adding locations to header string // Adding locations to header string
filters?.locations?.selectedLocations && filters?.locations?.selectedLocations &&
filters?.locations?.selectedLocations?.length > 0 filters?.locations?.selectedLocations?.length > 0
) { ) {
headerStringLocal += SPREAD;
locationsString = SPREAD;


filters.locations.selectedLocations.forEach((location, index) => { filters.locations.selectedLocations.forEach((location, index) => {
// Checking if item is last // Checking if item is last
if (index + 1 === filters.locations.selectedLocations.length) { if (index + 1 === filters.locations.selectedLocations.length) {
headerStringLocal += location.city;
locationsString += location.city;
} else { } else {
headerStringLocal += location.city + COMMA;
locationsString += location.city + COMMA;
} }
}); });
} }
return headerStringLocal;
let headerStringLocal = categoryString + subcategoryString + locationsString;
return {
categoryString,
subcategoryString,
locationsString,
text: headerStringLocal,
};
};
export const makeHeaderStringFromQueryObjectHelper = (queryObject) => {
new URLSearchParams().get;
let categoryString = `${ALL_CATEGORIES}`;
let subcategoryString = "";
let locationsString = "";
if (KEY_CATEGORY in queryObject) {
categoryString = queryObject[KEY_CATEGORY];
if (KEY_SUBCATEGORY in queryObject) {
subcategoryString = `${SPREAD}${queryObject[KEY_SUBCATEGORY]}`;
}
}
if (KEY_LOCATION in queryObject) {
locationsString = SPREAD;
if (!Array.isArray(queryObject[KEY_LOCATION])) {
locationsString += queryObject[KEY_LOCATION];
} else {
queryObject[KEY_LOCATION].forEach((location, index) => {
// Checking if item is last
if (index + 1 === queryObject[KEY_LOCATION].length) {
locationsString += location;
} else {
locationsString += location + COMMA;
}
});
}
}
let headerStringLocal = categoryString + subcategoryString + locationsString;

return {
categoryString,
subcategoryString,
locationsString,
text: headerStringLocal,
};
}; };
export const makeQueryStringHelper = (filters, paging, search, sorting) => { export const makeQueryStringHelper = (filters, paging, search, sorting) => {
const newQueryString = new URLSearchParams(); const newQueryString = new URLSearchParams();
if (newQueryString.has(KEY_PAGE)) newQueryString.delete(KEY_PAGE); if (newQueryString.has(KEY_PAGE)) newQueryString.delete(KEY_PAGE);
if (newQueryString.has(KEY_SIZE)) newQueryString.delete(KEY_SIZE); if (newQueryString.has(KEY_SIZE)) newQueryString.delete(KEY_SIZE);
return newQueryString.toString(); return newQueryString.toString();
}
};

Cargando…
Cancelar
Guardar