Update FamilyDetail.tsx
This commit is contained in:
@@ -167,8 +167,9 @@ export const FamilyDetail: React.FC = () => {
|
|||||||
} else {
|
} else {
|
||||||
setShowAddModal(false);
|
setShowAddModal(false);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
console.error("Failed to add payment", e);
|
console.error("Failed to add payment", e);
|
||||||
|
alert(`Errore durante il salvataggio del pagamento: ${e.message || "Errore sconosciuto"}`);
|
||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
@@ -509,17 +510,25 @@ export const FamilyDetail: React.FC = () => {
|
|||||||
description: `Quota ${MONTH_NAMES[newPaymentMonth - 1]} ${selectedYear} - Famiglia ${family.name}`,
|
description: `Quota ${MONTH_NAMES[newPaymentMonth - 1]} ${selectedYear} - Famiglia ${family.name}`,
|
||||||
amount: {
|
amount: {
|
||||||
currency_code: "EUR",
|
currency_code: "EUR",
|
||||||
value: newPaymentAmount.toString(),
|
value: newPaymentAmount.toFixed(2),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onApprove={(data, actions) => {
|
onApprove={async (data, actions) => {
|
||||||
if(!actions.order) return Promise.resolve();
|
if(!actions.order) return;
|
||||||
return actions.order.capture().then((details) => {
|
try {
|
||||||
handlePaymentSuccess(details);
|
const details = await actions.order.capture();
|
||||||
});
|
await handlePaymentSuccess(details);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("PayPal Capture Error", err);
|
||||||
|
alert("Errore durante il completamento del pagamento PayPal.");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onError={(err) => {
|
||||||
|
console.error("PayPal Button Error", err);
|
||||||
|
alert("Errore caricamento PayPal: " + err.toString());
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</PayPalScriptProvider>
|
</PayPalScriptProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user