- SellItemPage: real file upload + API listing creation + activate - CreateProfilePage: save profile via PUT /users/profile - ProductDetailPage: wire edit/delete/message buttons, show edit for owner - ListingCard: persist favorites via API, show real images - Footer: connect newsletter subscribe to API - Router: add /dashboard/listings and /dashboard/saved routes - Backend: add GET /listings/favorites endpoint - New pages: MyListingsPage, SavedItemsPage - Fix unused imports causing build failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { useState, useEffect } from 'react';
|
|
import { Card } from '../components/ui/Card';
|
|
import { ListingCard } from '../components/listings/ListingCard';
|
|
import { api } from '../api/client';
|
|
import type { Listing, PaginatedResponse } from '../types';
|
|
|
|
export function SavedItemsPage() {
|
|
const [listings, setListings] = useState<Listing[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
api.get<PaginatedResponse<Listing>>('/listings/favorites')
|
|
.then(res => setListings(res.data))
|
|
.catch(() => {})
|
|
.finally(() => setLoading(false));
|
|
}, []);
|
|
|
|
if (loading) return <div className="text-center py-12 text-gray-500">Loading...</div>;
|
|
|
|
return (
|
|
<div>
|
|
<h1 className="text-2xl font-bold text-gray-900 mb-6">Saved Items</h1>
|
|
|
|
{listings.length === 0 ? (
|
|
<Card>
|
|
<div className="text-center py-8">
|
|
<p className="text-gray-500">No saved items yet. Browse listings and tap the heart to save items you like.</p>
|
|
</div>
|
|
</Card>
|
|
) : (
|
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
{listings.map(listing => (
|
|
<ListingCard key={listing.id} listing={listing} />
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|