-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListingSection.tsx
More file actions
48 lines (44 loc) · 1.47 KB
/
ListingSection.tsx
File metadata and controls
48 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import Link from "next/link";
import { ShoppingBag, Bookmark } from "lucide-react";
import { ListingsCard } from "@/components/listings/ListingsCard";
import { Listing } from "@/lib/types";
interface Props {
title: string;
count: number;
listings: Listing[];
seeAllHref: string;
icon: "listings" | "saved";
}
export const ListingSection = ({ title, count, listings, seeAllHref, icon }: Props) => {
const Icon = icon === "listings" ? ShoppingBag : Bookmark;
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Icon className="h-5 w-5" />
<h2 className="text-lg font-bold">
{title} ({count})
</h2>
</div>
<Link href={seeAllHref} className="text-brand text-sm font-medium hover:underline">
See All {title}
</Link>
</div>
{listings.length === 0 ? (
<p className="text-sm text-gray-500">No {title.toLowerCase()} yet.</p>
) : (
<div className="flex gap-4 overflow-x-auto pb-2">
{listings.map((listing) => (
<div key={listing.id} className="w-48 flex-shrink-0">
<ListingsCard
listing={listing}
previewImageUrl={listing.images[0]}
href={`/${listing.listing_type === "item" ? "items" : "sublets"}/${listing.id}`}
/>
</div>
))}
</div>
)}
</div>
);
};