fix: fixup adresse correction
This commit is contained in:
@@ -697,6 +697,8 @@ export const createCheckout = async (checkoutData: CheckoutData) => {
|
||||
message: data.error || "Erreur création",
|
||||
postal_code: data.postal_code as string | undefined,
|
||||
zone_error: isZoneError as boolean,
|
||||
invalid_address: !!data.corrected_address,
|
||||
suggested_address: data.corrected_address as string | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ function Checkout() {
|
||||
const [showZoneModal, setShowZoneModal] = useState(false);
|
||||
const [zoneErrorMsg, setZoneErrorMsg] = useState('');
|
||||
|
||||
// État pour le modal adresse invalide (correction suggérée)
|
||||
const [showInvalidAddressModal, setShowInvalidAddressModal] = useState(false);
|
||||
const [suggestedAddress, setSuggestedAddress] = useState('');
|
||||
|
||||
// Informations personnelles
|
||||
const [firstName, setFirstName] = useState('');
|
||||
const [lastName, setLastName] = useState('');
|
||||
@@ -315,6 +319,12 @@ function Checkout() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.success && response.invalid_address && response.suggested_address) {
|
||||
setSuggestedAddress(response.suggested_address);
|
||||
setShowInvalidAddressModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.success && response.command_id) {
|
||||
const { command_id, assigned_to, queue_info, delivery_address } = response;
|
||||
|
||||
@@ -725,6 +735,46 @@ function Checkout() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ============================================ */}
|
||||
{/* MODAL ADRESSE INVALIDE (CORRECTION SUGGÉRÉE) */}
|
||||
{/* ============================================ */}
|
||||
{showInvalidAddressModal && (
|
||||
<div className="confirmation-modal-overlay" onClick={() => setShowInvalidAddressModal(false)}>
|
||||
<div className="confirmation-modal" onClick={(e) => e.stopPropagation()}>
|
||||
<div className="confirmation-modal-header confirmation-modal-header--error">
|
||||
<i className="fas fa-map-marker-alt confirmation-icon"></i>
|
||||
<h2>Adresse invalide</h2>
|
||||
</div>
|
||||
<div className="confirmation-modal-body">
|
||||
<div className="confirmation-section">
|
||||
<div className="confirmation-detail confirmation-detail--centered">
|
||||
<p style={{ marginBottom: '0.75rem' }}>
|
||||
L'adresse saisie n'est pas reconnue. Voulez-vous utiliser l'adresse correcte suggérée ?
|
||||
</p>
|
||||
<p className="confirmation-detail--muted" style={{ fontWeight: 600 }}>
|
||||
{suggestedAddress}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="confirmation-modal-actions">
|
||||
<button className="confirmation-button confirmation-button--neutral" onClick={() => setShowInvalidAddressModal(false)}>
|
||||
Modifier
|
||||
</button>
|
||||
<button
|
||||
className="confirmation-button"
|
||||
onClick={() => {
|
||||
setAddress(suggestedAddress);
|
||||
setShowInvalidAddressModal(false);
|
||||
}}
|
||||
>
|
||||
Utiliser cette adresse
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ============================================ */}
|
||||
{/* MODAL DE CONFIRMATION STYLISÉ */}
|
||||
{/* ============================================ */}
|
||||
|
||||
Reference in New Issue
Block a user