Merge pull request #154 from Irev-Dev/kurt/issue-153
issue-153 Filter out parts without main image
This commit was merged in pull request #154.
This commit is contained in:
@@ -1,16 +1,29 @@
|
|||||||
|
import { useMemo } from 'react'
|
||||||
import { Link, routes } from '@redwoodjs/router'
|
import { Link, routes } from '@redwoodjs/router'
|
||||||
|
|
||||||
import { countEmotes } from 'src/helpers/emote'
|
import { countEmotes } from 'src/helpers/emote'
|
||||||
import ImageUploader from 'src/components/ImageUploader'
|
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 (
|
return (
|
||||||
<section className="max-w-6xl mx-auto mt-8">
|
<section className="max-w-6xl mx-auto mt-8">
|
||||||
<ul
|
<ul
|
||||||
className="grid gap-x-8 gap-y-12 items-center mx-4 relative"
|
className="grid gap-x-8 gap-y-12 items-center mx-4 relative"
|
||||||
style={{ gridTemplateColumns: 'repeat(auto-fit, minmax(16rem, 1fr))' }}
|
style={{ gridTemplateColumns: 'repeat(auto-fit, minmax(16rem, 1fr))' }}
|
||||||
>
|
>
|
||||||
{parts.map(({ title, mainImage, user, Reaction }) => (
|
{filteredParts.map(({ title, mainImage, user, Reaction }) => (
|
||||||
<li
|
<li
|
||||||
className="rounded-lg shadow-md hover:shadow-lg mx-px transform hover:-translate-y-px transition-all duration-150"
|
className="rounded-lg shadow-md hover:shadow-lg mx-px transform hover:-translate-y-px transition-all duration-150"
|
||||||
key={`${user?.userName}--${title}`}
|
key={`${user?.userName}--${title}`}
|
||||||
|
|||||||
@@ -34,6 +34,14 @@ export const Empty = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Success = ({ parts }) => {
|
export const Success = ({
|
||||||
return <Parts parts={parts} />
|
parts,
|
||||||
|
variables: { shouldFilterPartsWithoutImage },
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<Parts
|
||||||
|
parts={parts}
|
||||||
|
shouldFilterPartsWithoutImage={shouldFilterPartsWithoutImage}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const PartsPage = () => {
|
|||||||
<MainLayout>
|
<MainLayout>
|
||||||
<Seo title="Parts page" description="Cadhub parts page" lang="en-US" />
|
<Seo title="Parts page" description="Cadhub parts page" lang="en-US" />
|
||||||
<LandingSection />
|
<LandingSection />
|
||||||
<PartsCell />
|
<PartsCell shouldFilterPartsWithoutImage />
|
||||||
</MainLayout>
|
</MainLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user