Skip to content

Commit

Permalink
Display place image
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciabad committed Oct 24, 2023
1 parent c299115 commit 6e72f76
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions src/app/[locale]/(app)/explore/_components/place-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { useTranslations } from 'next-intl'
import type { FC, HTMLAttributes } from 'react'

import { trpc } from '~/trpc'
import { Card, CardBody, CardFooter } from '@nextui-org/card'
import { Image } from '@nextui-org/image'

function makeImageUrl<T extends string>(s3key: T | null) {
if (!s3key) {
return 'https://descobreix-begur-app-g3qf4o.s3.eu-west-1.amazonaws.com/static/app/content-placeholder.png'
}
return `https://descobreix-begur-app-g3qf4o.s3.eu-west-1.amazonaws.com/${s3key}` as const
}

export const PlaceList: FC<Omit<HTMLAttributes<HTMLElement>, 'children'>> = ({
className,
Expand All @@ -28,14 +37,32 @@ export const PlaceList: FC<Omit<HTMLAttributes<HTMLElement>, 'children'>> = ({
}

return (
<ul className={cn('grid gap-4', className)} {...props}>
<ul
className={cn('grid grid-cols-2 gap-2 sm:grid-cols-4', className)}
{...props}
>
{places?.map((place) => (
<li
<Card
as="li"
shadow="sm"
key={place.id}
className="flex items-center justify-between rounded border border-gray-500 px-4 py-2"
isPressable
onPress={() => console.log('item pressed')}
>
<span className="text-lg">{place.name}</span>
</li>
<CardBody className="overflow-visible p-0">
<Image
shadow="sm"
radius="lg"
width="100%"
alt={place.name}
className="aspect-video h-[140px] w-full object-cover"
src={makeImageUrl(place.mainImage)}
/>
</CardBody>
<CardFooter className="justify-between text-small">
<b>{place.name}</b>
</CardFooter>
</Card>
))}
</ul>
)
Expand Down

0 comments on commit 6e72f76

Please sign in to comment.