Lab 5
Lab 5
Name: K BHAVANA
import { Navbar, Container, Nav, Card, Row, Col, Form } from 'react-bootstrap';
function ProductCatalog() {
]);
setFilter(event.target.value);
};
setSortBy(event.target.value);
};
// Filter and sort products
product.name.toLowerCase().includes(filter.toLowerCase())
);
filteredProducts.sort((a, b) => {
} else {
return a.name.localeCompare(b.name);
});
return (
<div>
<Container>
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="ml-auto">
<Nav.Link href="#home">Home</Nav.Link>
<Nav.Link href="#link">Products</Nav.Link>
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
<Container className="mt-4">
<Form>
<Form.Group controlId="formFilter">
<Form.Label>Filter by Name:</Form.Label>
<Form.Control
type="text"
placeholder="Enter product name"
value={filter}
onChange={handleFilterChange}
/>
</Form.Group>
<Form.Group controlId="formSort">
<Form.Label>Sort by:</Form.Label>
<option value="price">Price</option>
<option value="name">Name</option>
</Form.Control>
</Form.Group>
</Form>
<Row>
{filteredProducts.map((product) => (
<Card className="mb-4">
<Card.Body>
<Card.Title>{product.name}</Card.Title>
<Card.Text>${product.price}</Card.Text>
View Details
</a>
</Card.Body>
</Card>
</Col>
))}
</Row>
</Container>
</div>
);
function App() {
return (
<Navbar.Brand href="#home">Navbar</Navbar.Brand>
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="ml-auto">
<Nav.Link href="#home">Home</Nav.Link>
<Nav.Link href="#link">Link</Nav.Link>
</Nav>
</Navbar.Collapse>
</Navbar>
);