-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #991 from haseebzaki-07/new_branch_7
Add agriproducts page
- Loading branch information
Showing
16 changed files
with
479 additions
and
36 deletions.
There are no files selected for viewing
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
frontend/src/AgroRentAI/components/sub-components/CompareProducts.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
|
||
const CompareProducts = ({ products }) => { | ||
const compareItems = products.slice(0, 2); // Comparing the first two products | ||
|
||
return ( | ||
<div className="my-8 p-6 bg-white rounded-lg shadow-lg max-w-6xl mx-auto"> | ||
<h3 className="text-2xl font-semibold text-center mb-6">Compare Products</h3> | ||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-8"> | ||
{compareItems.map((product) => ( | ||
<div | ||
key={product._id} | ||
className="border-2 border-green-500 p-6 rounded-lg shadow-md hover:shadow-xl transition-shadow duration-300" | ||
> | ||
<img | ||
src={product.image || "/path/to/default-image.png"} | ||
alt={product.name} | ||
className="w-full h-48 object-cover rounded-lg mb-4" | ||
/> | ||
<h4 className="text-xl font-bold text-gray-800">{product.name}</h4> | ||
<p className="text-sm text-gray-600 mb-4">{product.description}</p> | ||
<div className="flex items-center justify-between"> | ||
<p className="text-xl font-semibold text-green-600">{`$${product.price} per day`}</p> | ||
<button className="bg-green-500 text-white px-4 py-2 rounded-lg hover:bg-green-600 transition-colors"> | ||
Compare | ||
</button> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CompareProducts; |
123 changes: 123 additions & 0 deletions
123
frontend/src/AgroRentAI/components/sub-components/PriceCalculator.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import React, { useState } from "react"; | ||
|
||
const PriceCalculator = () => { | ||
const [quantity, setQuantity] = useState(1); | ||
const [duration, setDuration] = useState("daily"); | ||
const [discountCode, setDiscountCode] = useState(""); | ||
const [currency, setCurrency] = useState("USD"); | ||
|
||
const pricePerDay = 50; // Base price per day for simplicity | ||
|
||
// Price calculation based on duration | ||
const durations = { | ||
hourly: 5, | ||
daily: 50, | ||
weekly: 300, | ||
monthly: 1200, | ||
}; | ||
|
||
const calculatePrice = () => { | ||
let totalPrice = durations[duration] * quantity; | ||
|
||
// Applying a discount code (example logic) | ||
if (discountCode === "DISCOUNT10") { | ||
totalPrice *= 0.9; // Apply a 10% discount | ||
} | ||
|
||
// Adding currency conversion (just for demonstration) | ||
if (currency === "EUR") { | ||
totalPrice *= 0.85; // Conversion rate from USD to EUR | ||
} | ||
|
||
return totalPrice.toFixed(2); | ||
}; | ||
|
||
return ( | ||
<div className="my-8 p-6 bg-white rounded-lg shadow-2xl max-w-6xl mx-auto"> | ||
<h3 className="text-2xl font-semibold mb-6 text-center">Price Calculator</h3> | ||
|
||
<div className="space-y-4"> | ||
{/* Horizontal Flex Container for Fields */} | ||
<div className="flex space-x-8 items-center"> | ||
{/* Quantity Field */} | ||
<div className="w-1/4"> | ||
<label className="block text-lg font-medium mb-2">Quantity:</label> | ||
<input | ||
type="number" | ||
value={quantity} | ||
onChange={(e) => setQuantity(Number(e.target.value))} | ||
min="1" | ||
className="w-full p-3 rounded-lg border-2 border-green-500" | ||
placeholder="Enter quantity" | ||
/> | ||
</div> | ||
|
||
{/* Duration Field */} | ||
<div className="w-1/4"> | ||
<label className="block text-lg font-medium mb-2">Duration:</label> | ||
<select | ||
value={duration} | ||
onChange={(e) => setDuration(e.target.value)} | ||
className="w-full p-3 rounded-lg border-2 border-green-500" | ||
> | ||
<option value="hourly">Hourly</option> | ||
<option value="daily">Daily</option> | ||
<option value="weekly">Weekly</option> | ||
<option value="monthly">Monthly</option> | ||
</select> | ||
</div> | ||
|
||
{/* Discount Code Field */} | ||
<div className="w-1/4"> | ||
<label className="block text-lg font-medium mb-2">Discount Code (Optional):</label> | ||
<input | ||
type="text" | ||
value={discountCode} | ||
onChange={(e) => setDiscountCode(e.target.value)} | ||
className="w-full p-3 rounded-lg border-2 border-green-500" | ||
placeholder="Enter discount code" | ||
/> | ||
</div> | ||
|
||
{/* Currency Selector */} | ||
<div className="w-1/4"> | ||
<label className="block text-lg font-medium mb-2">Currency:</label> | ||
<select | ||
value={currency} | ||
onChange={(e) => setCurrency(e.target.value)} | ||
className="w-full p-3 rounded-lg border-2 border-green-500" | ||
> | ||
<option value="USD">USD</option> | ||
<option value="EUR">EUR</option> | ||
</select> | ||
</div> | ||
</div> | ||
|
||
{/* Price Breakdown */} | ||
<div className="mt-8"> | ||
<div className="flex justify-between mb-2"> | ||
<span className="font-medium">Base Price:</span> | ||
<span>{`${durations[duration]} per ${duration}`}</span> | ||
</div> | ||
<div className="flex justify-between mb-2"> | ||
<span className="font-medium">Quantity:</span> | ||
<span>{quantity}</span> | ||
</div> | ||
{discountCode && discountCode === "DISCOUNT10" && ( | ||
<div className="flex justify-between text-green-600 font-medium mb-2" > | ||
<span>Discount Applied:</span> | ||
<span>-10%</span> | ||
</div> | ||
)} | ||
<div className="border-t-2 border-gray-200 my-4"></div> | ||
<div className="flex justify-between text-xl font-semibold text-green-600"> | ||
<span>Total Price:</span> | ||
<span>{currency === "USD" ? `$${calculatePrice()}` : `€${calculatePrice()}`}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PriceCalculator; |
Oops, something went wrong.