diff --git a/web/src/components/Parts/Parts.js b/web/src/components/Parts/Parts.js index efdc8bf..b2b1439 100644 --- a/web/src/components/Parts/Parts.js +++ b/web/src/components/Parts/Parts.js @@ -1,16 +1,29 @@ +import { useMemo } from 'react' import { Link, routes } from '@redwoodjs/router' import { countEmotes } from 'src/helpers/emote' import ImageUploader from 'src/components/ImageUploader' -const PartsList = ({ parts }) => { +const PartsList = ({ parts, shouldFilterPartsWithoutImage = false }) => { + // temporary filtering parts that don't have images until some kind of search is added and there are more things on the website + // it helps avoid the look of the website just being filled with dumby data. + // related issue-104 + const filteredParts = useMemo( + () => + shouldFilterPartsWithoutImage + ? parts.filter(({ mainImage }) => mainImage) + : [...parts] + // sort should probably be done on the service, but the filtering is temp too + .sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt)), + [parts, shouldFilterPartsWithoutImage] + ) return (