Преглед на файлове

Finished feature 638

feature/638
Djordje Mitrovic преди 3 години
родител
ревизия
d2f49e953e

+ 1
- 1
src/components/Cards/CreateOfferCard/CreateOffer.js Целия файл

// Create (or edit) offer // Create (or edit) offer
const handleSubmitOffer = () => { const handleSubmitOffer = () => {
if (editOffer) { if (editOffer) {
dispatch(editOneOffer({offerId: 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 Целия файл

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 Целия файл

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 Целия файл

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 Целия файл

// 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 Целия файл

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()),
}, },
}) })
); );

+ 5
- 9
src/components/MarketPlace/Header/Header.js Целия файл

props.offers.filters.locations.clear(); props.offers.filters.locations.clear();
props.offers.applyFilters(); props.offers.applyFilters();
}; };
// const goBack = () => {
// history.goBack();
// };
console.log(headerString.text);


return ( return (
<> <>
<CategoryHeaderIcon /> <CategoryHeaderIcon />
<HeaderLocation> <HeaderLocation>
{/* {headerString} */} {/* {headerString} */}
<HeaderCategoryString onClick={handleClickCategory}>
<HeaderCategoryString component="span" onClick={handleClickCategory}>
{headerString.categoryString} {headerString.categoryString}
{headerString.subcategoryString && <>&nbsp;</>} {headerString.subcategoryString && <>&nbsp;</>}
</HeaderCategoryString> </HeaderCategoryString>
<HeaderSubcategoryString onClick={handleClickSubcategory}>
<HeaderSubcategoryString component="span" onClick={handleClickSubcategory}>
{headerString.subcategoryString} {headerString.subcategoryString}
{headerString.locationsString && <>&nbsp;</>} {headerString.locationsString && <>&nbsp;</>}
</HeaderSubcategoryString> </HeaderSubcategoryString>
<HeaderLocationsString>
<HeaderLocationsMainString>
<HeaderLocationsString component="span">
<HeaderLocationsMainString component="span">
{headerString.locationsString} {headerString.locationsString}
</HeaderLocationsMainString> </HeaderLocationsMainString>
<HeaderAltLocation>{altString}</HeaderAltLocation>
<HeaderAltLocation component="span">{altString}</HeaderAltLocation>
</HeaderLocationsString> </HeaderLocationsString>
</HeaderLocation> </HeaderLocation>
</> </>

+ 27
- 4
src/components/MarketPlace/Header/Header.styled.js Целия файл

`; `;
export const TooltipInnerContainer = styled(Box)` export const TooltipInnerContainer = styled(Box)`
width: 100%; width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
& * {
display: inline;
}
`; `;
export const HeaderLocation = styled(Typography)` export const HeaderLocation = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont}; font-family: ${selectedTheme.fonts.textFont};
flex: 2; flex: 2;
margin-left: 9px; margin-left: 9px;
max-width: 50%; max-width: 50%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: relative;
top: -2px;
&:after { &:after {
content: ${(props) => (props.initial ? `":"` : `""`)}; content: ${(props) => (props.initial ? `":"` : `""`)};
@media (max-width: 600px) { @media (max-width: 600px) {
/* position: relative; /* position: relative;
bottom: 2px; */ bottom: 2px; */
cursor: pointer; cursor: pointer;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
`; `;
export const HeaderSubcategoryString = styled(Typography)` export const HeaderSubcategoryString = styled(Typography)`
font-family: ${selectedTheme.fonts.textFont}; font-family: ${selectedTheme.fonts.textFont};
/* position: relative; /* position: relative;
bottom: 2px; */ bottom: 2px; */
cursor: pointer; cursor: pointer;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
`; `;
export const HeaderLocationsString = styled(Typography)` export const HeaderLocationsString = styled(Typography)`
/* position: relative; /* position: relative;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@media (max-width: 600px) {
font-size: 12px;
padding-top: 3px;
}
max-width: 100%; max-width: 100%;
`; `;
export const HeaderLocationsMainString = styled(Typography)` export const HeaderLocationsMainString = styled(Typography)`
font-weight: 700; font-weight: 700;
line-height: 22px; line-height: 22px;
font-size: 16px; 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;
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;
} }

+ 0
- 1
src/components/Popovers/PhonePopover/PhonePopover.js Целия файл



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

+ 4
- 2
src/hooks/useOffers/useOffers.js Целия файл

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]);




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


const clearFiltersAndApply = () => { const clearFiltersAndApply = () => {
clear(); clear();

+ 0
- 1
src/pages/RegisterPages/Register/Register.js Целия файл

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



+ 47
- 18
src/util/helpers/dateHelpers.js Целия файл

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);
}

+ 35
- 0
src/util/helpers/queryHelpers.js Целия файл

text: headerStringLocal, 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 (filters.category.selectedCategoryLocally?.name) { if (filters.category.selectedCategoryLocally?.name) {

Loading…
Отказ
Запис