onClick(label)}
19 | className={`
20 | rounded-xl
21 | border-2
22 | p-4
23 | flex
24 | flex-col
25 | gap-3
26 | hover:border-black
27 | transition
28 | cursor-pointer
29 | ${selected ? 'border-black' : 'border-neutral-200'}
30 | `}
31 | >
32 |
33 |
{label}
34 |
35 | )
36 | }
37 |
38 | export default CategoryInput
39 |
40 |
--------------------------------------------------------------------------------
/app/actions/getListingById.ts:
--------------------------------------------------------------------------------
1 | import prisma from '@/app/libs/prismadb'
2 |
3 | interface IParams {
4 | listingId?: string
5 | }
6 |
7 | export default async function getListingById(params: IParams) {
8 | try {
9 | const { listingId } = params
10 |
11 | const listing = await prisma.listing.findUnique({
12 | where: {
13 | id: listingId
14 | },
15 | include: {
16 | user: true
17 | }
18 | })
19 |
20 | if (!listing) {
21 | return null
22 | }
23 |
24 | return {
25 | ...listing,
26 | createdAt: listing.createdAt.toString(),
27 | user: {
28 | ...listing.user,
29 | createdAt: listing.user.createdAt.toString(),
30 | updatedAt: listing.user.updatedAt.toString(),
31 | emailVerified: listing.user.emailVerified?.toString() || null
32 | }
33 | }
34 | } catch (error: any) {
35 | throw new Error(error)
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/app/favorites/page.tsx:
--------------------------------------------------------------------------------
1 | import ClientOnly from '../components/ClientOnly'
2 | import EmptyState from '../components/EmptyState'
3 | import FavoritesClient from './FavoritesClient'
4 | import getCurrentUser from '../actions/getCurrentUser'
5 | import getFavoriteListings from '../actions/getFavoriteListings'
6 |
7 | const ListingPage = async () => {
8 | const listings = await getFavoriteListings()
9 | const currentUser = await getCurrentUser()
10 |
11 | if (listings.length === 0) {
12 | return (
13 |