Kaynağa Gözat

Partly finished feature 638

feature/638
djordjemitrovic00 3 yıl önce
ebeveyn
işleme
87a0de4640

+ 1
- 1
src/components/Cards/CreateOfferCard/CreateOffer.js Dosyayı Görüntüle

// 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}));
} else { } else {
dispatch(addOffer({ offerData, handleApiResponseSuccess })); dispatch(addOffer({ offerData, handleApiResponseSuccess }));
} }

+ 38
- 10
src/components/MarketPlace/Header/Header.js Dosyayı Görüntüle

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 handleClickCategory = () => {
props.offers.filters.locations.clear();
props.offers.filters.subcategory.clear();
props.offers.applyFilters();
};
const handleClickSubcategory = () => {
props.offers.filters.locations.clear();
props.offers.applyFilters();
};
// const goBack = () => { // const goBack = () => {
// history.goBack(); // history.goBack();
// }; // };
console.log(headerString.text);


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 onClick={handleClickCategory}>
{headerString.categoryString}
{headerString.subcategoryString && <>&nbsp;</>}
</HeaderCategoryString>
<HeaderSubcategoryString onClick={handleClickSubcategory}>
{headerString.subcategoryString}
{headerString.locationsString && <>&nbsp;</>}
</HeaderSubcategoryString>
<HeaderLocationsString>
<HeaderLocationsMainString>
{headerString.locationsString}
</HeaderLocationsMainString>
<HeaderAltLocation>{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,

+ 47
- 7
src/components/MarketPlace/Header/Header.styled.js Dosyayı Görüntüle

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%;
`;
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%")};
max-width: 50%;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
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;
`;
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;
`;
export const HeaderLocationsString = styled(Typography)`
/* position: relative;
bottom: 2px; */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
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;
`;
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;
/* margin-left: 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 Dosyayı Görüntüle

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

+ 5
- 0
src/hooks/useOffers/useOffers.js Dosyayı Görüntüle

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,

+ 6
- 1
src/store/reducers/filters/filtersReducer.js Dosyayı Görüntüle

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

+ 16
- 8
src/util/helpers/queryHelpers.js Dosyayı Görüntüle

}; };


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

Loading…
İptal
Kaydet