diff --git a/frontend/src/components/ItemCard.js b/frontend/src/components/ItemCard.js index 2bb0d1d..7195e07 100644 --- a/frontend/src/components/ItemCard.js +++ b/frontend/src/components/ItemCard.js @@ -1,9 +1,7 @@ import React, { useState, useCallback } from 'react'; -import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; -import Badge from './ui/Badge'; -import { ShieldCheck, MapPin } from './ui/icons'; -import { cardStyles } from '../lib/utils'; +import { MapPin } from 'lucide-react'; +import PropTypes from 'prop-types'; // Constants for better maintainability const PLACEHOLDER_IMAGE = '/placeholder.svg'; @@ -67,80 +65,70 @@ const ItemCard = ({ item }) => { const statusText = item.kind ? item.kind.charAt(0).toUpperCase() + item.kind.slice(1) : 'Unknown'; return ( - -
-
-
- {/* Item Image */} -
-
- {imageLoading && ( -
-
-
- )} - {imageAlt} -
- {item.reporter?.trust && ( -
- - - Trusted - -
- )} -
- - {/* Item Details */} -
- {/* Status and Category Badges */} -
- - {statusText} - - {item.claimed && ( - Claimed - )} - - {item.category || 'Uncategorized'} - -
- {/* Title */} -

- {item.title || 'Untitled Item'} -

- {/* Description */} -

- {item.description || 'No description provided'} -

- {/* Location and Date */} -
- - - {item.location || 'Unknown location'} - - - - 🕒 {formatDate(item.date)} - -
-
+ + {/* Image Section */} +
+ {imageLoading && ( +
+
+ )} + {imageAlt} +
+ + {/* Location and Date - Full width under image */} +
+ + + {item.location || 'Unknown location'} + + + 🕒 + {formatDate(item.date)} + +
+ + {/* Content Section */} +
+ {/* Title */} +

+ {item.title} +

+ + {/* Description */} +

+ {item.description || 'No description available'} +

+ + {/* Status and Category Tags - Stick to bottom */} +
+ + {statusText} + + {item.category && ( + + {item.category} + + )} + {item.claimed && ( + + Claimed + + )} + {item.reporter?.trust && ( + + ✓ Verified + + )}
@@ -157,10 +145,11 @@ ItemCard.propTypes = { imageUrl: PropTypes.string, kind: PropTypes.string, category: PropTypes.string, + claimed: PropTypes.bool, reporter: PropTypes.shape({ trust: PropTypes.bool }) }).isRequired }; -export default ItemCard; +export default ItemCard; \ No newline at end of file diff --git a/frontend/src/pages/ItemDetail.js b/frontend/src/pages/ItemDetail.js index 3ca67a7..72b3a0e 100644 --- a/frontend/src/pages/ItemDetail.js +++ b/frontend/src/pages/ItemDetail.js @@ -1,8 +1,7 @@ import React, { useEffect, useState, useCallback } from 'react'; import PropTypes from 'prop-types'; import { useParams, useNavigate, Link } from 'react-router-dom'; -import Badge from '../components/ui/Badge'; -import { ArrowLeft, ShieldCheck, MapPin } from '../components/ui/icons'; +import { ArrowLeft, MapPin } from '../components/ui/icons'; import { db } from '../firebase/config'; import { getAuth, onAuthStateChanged } from 'firebase/auth'; import { @@ -259,21 +258,31 @@ const ItemDetailPage = () => { className="rounded-lg border aspect-video object-cover" />
-
- - {item.kind || item.status} - + {/* Status and Category Tags */} +
+ + {item.kind?.charAt(0).toUpperCase() + item.kind?.slice(1) || 'Unknown'} + + {item.category && ( + + {item.category} + + )} {item.claimed && ( - Claimed + + Claimed + )} - - {item.category || item.type} - {userInfo?.trust && ( - - - Trusted - + + ✓ Verified + )}

{item.title}

diff --git a/frontend/src/pages/__tests__/ItemDetail.test.js b/frontend/src/pages/__tests__/ItemDetail.test.js index 9802746..ab10027 100644 --- a/frontend/src/pages/__tests__/ItemDetail.test.js +++ b/frontend/src/pages/__tests__/ItemDetail.test.js @@ -153,7 +153,7 @@ describe('ItemDetailPage', () => { }); }; - const assertItemStatusBadge = async (status = 'lost') => { + const assertItemStatusBadge = async (status = 'Lost') => { await waitFor(() => { expect(screen.getByText(status)).toBeInTheDocument(); }); @@ -262,14 +262,14 @@ describe('ItemDetailPage', () => { test('displays item status badge correctly', async () => { setupOnSnapshotMock(); renderItemDetailPage(); - await assertItemStatusBadge('lost'); + await assertItemStatusBadge('Lost'); }); test('displays found item status badge correctly', async () => { const foundItem = { ...mockItem, kind: 'found' }; setupOnSnapshotMock(foundItem); renderItemDetailPage(); - await assertItemStatusBadge('found'); + await assertItemStatusBadge('Found'); }); test('displays claimed badge when item is claimed', async () => {