Canteen Management - 22bd1a0527
Canteen Management - 22bd1a0527
App.js
function App() {
};
};
const menuItems = [
];
return (
<div className="container">
<OrderCounter />
<CanteenApp />
<DiscountCalculator />
</div>
);
AddMenuItem.jsx
constructor(props) {
super(props);
this.state = {
name: "",
price: "",
};
};
// Validate input
return;
};
render() {
return (
<form onSubmit={this.handleSubmit}>
<div>
<label>
Item Name:
<input
type="text"
name="name"
value={this.state.name}
onChange={this.handleChange}
/>
</label>
</div>
<div>
<label>
Price:
<input
type="text"
name="price"
value={this.state.price}
onChange={this.handleChange}
placeholder="Enter price"
/>
</label>
</div>
</form>
);
CanteenApp.jsx
constructor(props) {
super(props);
this.state = {
menuItems: [],
};
}
addMenuItem = (item) => {
this.setState((prevState) => ({
}));
};
render() {
return (
<div>
<h2>Menu Items</h2>
<ul>
{this.state.menuItems.length === 0 ? (
):(
<li key={index}>
{item.name} - ${item.price.toFixed(2)}
</li>
))
)}
</ul>
</div>
);
return (
<div>
<h2>Cart</h2>
{cartItems.length === 0 ? (
<p>Cart is empty</p>
):(
<ul>
{cartItems.map((item) => (
<li key={item.id}>
</li>
))}
</ul>
)}
</div>
);
};
DailySpecial.jsx
<div>
<h2>Today's Special</h2>
<h3>Paneer Tikka</h3>
<p>Price: $6.99</p>
</div>
);
DiscountCalculator.jsx
constructor(props) {
super(props);
this.state = {
originalPrice: 100,
discount: 10,
finalPrice: 100,
};
applyDiscount = () => {
this.setState((prevState) => ({
}));
};
render() {
return (
<div>
<h2>Discount Calculator</h2>
<p>Discount: {this.state.discount}%</p>
</div>
);
FoodItem.jsx
return (
<div className="card-body">
<h5 className="card-title">{name}</h5>
Add to Cart
</button>
</div>
</div>
);
};
return (
<div className="row">
{items.map((item) => (
</div>
))}
</div>
</div>
);
};
OrderCounter.jsx
constructor(props) {
super(props);
this.state = {
orders: 0,
totalRevenue: 0,
};
this.setState((prevState) => ({
orders: prevState.orders + 1,
}));
};
render() {
return (
<div>
<h2>Order Counter</h2>
<p>Orders: {this.state.orders}</p>
</div>
);
OrderDetails.jsx
return (
<div>
<h3>{orderId}</h3>
<p>Customer: {customerName}</p>
<p>Total: ${amount}</p>
</div>
);