instead of rental data in local storage, using stripe metadata
This commit is contained in:
@@ -81,29 +81,6 @@ const RentItem: React.FC = () => {
|
||||
calculateTotalCost();
|
||||
}, [item, manualSelection]);
|
||||
|
||||
// Save rental data to localStorage whenever the form is ready
|
||||
useEffect(() => {
|
||||
if (
|
||||
item &&
|
||||
manualSelection.startDate &&
|
||||
manualSelection.endDate &&
|
||||
totalCost > 0
|
||||
) {
|
||||
const rentalData = {
|
||||
itemId: item.id,
|
||||
startDate: manualSelection.startDate,
|
||||
endDate: manualSelection.endDate,
|
||||
startTime: manualSelection.startTime,
|
||||
endTime: manualSelection.endTime,
|
||||
totalAmount: totalCost,
|
||||
deliveryMethod: "pickup",
|
||||
};
|
||||
|
||||
localStorage.setItem("pendingRental", JSON.stringify(rentalData));
|
||||
localStorage.setItem("lastItemId", item.id);
|
||||
}
|
||||
}, [item, manualSelection, totalCost]);
|
||||
|
||||
const fetchItem = async () => {
|
||||
try {
|
||||
const response = await itemAPI.getItem(id!);
|
||||
@@ -126,9 +103,6 @@ const RentItem: React.FC = () => {
|
||||
};
|
||||
|
||||
const handlePaymentSuccess = () => {
|
||||
// This is called when Stripe checkout session is created successfully
|
||||
// The rental data is already saved to localStorage via useEffect
|
||||
// The actual rental creation happens in CheckoutReturn component after payment
|
||||
console.log("Stripe checkout session created successfully");
|
||||
};
|
||||
|
||||
@@ -191,6 +165,15 @@ const RentItem: React.FC = () => {
|
||||
<StripePaymentForm
|
||||
total={totalCost}
|
||||
itemName={item.name}
|
||||
rentalData={{
|
||||
itemId: item.id,
|
||||
startDate: manualSelection.startDate,
|
||||
endDate: manualSelection.endDate,
|
||||
startTime: manualSelection.startTime,
|
||||
endTime: manualSelection.endTime,
|
||||
totalAmount: totalCost,
|
||||
deliveryMethod: "pickup",
|
||||
}}
|
||||
onSuccess={handlePaymentSuccess}
|
||||
onError={(error) => setError(error)}
|
||||
disabled={
|
||||
|
||||
Reference in New Issue
Block a user