feat(frontend): add product detail view and navigation
- Create ProductView component with product details display - Add ProductView.css with responsive styling - Add product screen to App.jsx screen system - Pass onNavigateToProduct callback from App to SearchView - Update ProductResults onSelect to use callback instead of window.location
This commit is contained in:
@@ -14,7 +14,7 @@ const suggestions = [
|
||||
{ name: 'Omeprazol', icon: 'emergency_home', color: 'neutral-4' },
|
||||
];
|
||||
|
||||
function SearchView({ currentUser, onLoginRequest, initialQuery = '' }) {
|
||||
function SearchView({ currentUser, onLoginRequest, initialQuery = '', onNavigateToProduct }) {
|
||||
const [searchQuery, setSearchQuery] = useState(initialQuery);
|
||||
const [medicines, setMedicines] = useState([]);
|
||||
const [products, setProducts] = useState([]);
|
||||
@@ -331,7 +331,11 @@ function SearchView({ currentUser, onLoginRequest, initialQuery = '' }) {
|
||||
<ProductResults
|
||||
products={products}
|
||||
onSelect={(p) => {
|
||||
window.location.href = `/product/${p.source}/${p.id}`;
|
||||
if (onNavigateToProduct) {
|
||||
onNavigateToProduct(p.source, p.id);
|
||||
} else {
|
||||
window.location.href = `/product/${p.source}/${p.id}`;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user