chore: build
Backend - Build & Lint / build (push) Canceled after 1m5s
Frontend Client - EAS Build / build (push) Canceled after 23s
Frontend Web - Build & Lint / build (push) Canceled after 0s

This commit is contained in:
Xor290
2026-09-10 19:26:05 +02:00
parent c69dc70680
commit f904a37964
6 changed files with 370 additions and 0 deletions
+54
View File
@@ -1440,6 +1440,60 @@ export const cancelCommand = async (
}
};
/**
* ✅ UPDATE OWN COMMAND ADDRESS - Corriger l'adresse de sa propre commande
* PUT /api/v1/commands/:id/address
*/
export const updateOwnCommandAddress = async (
commandId: number,
deliveryAddress: string,
): Promise<{ success: boolean; message: string }> => {
const token = sessionStorage.getItem("token");
if (!token) {
return {
success: false,
message: "Session invalide",
};
}
try {
const response = await fetch(
`${API_URL}/commands/${commandId}/address`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ delivery_address: deliveryAddress }),
},
);
const data = await safeJson(response);
if (!response.ok) {
return {
success: false,
message: data.error || "Erreur lors de la mise à jour de l'adresse",
};
}
return {
success: true,
message: data.message || "Adresse mise à jour",
};
} catch (error) {
return {
success: false,
message:
error instanceof Error
? error.message
: "Erreur lors de la mise à jour de l'adresse",
};
}
};
/**
* ✅ GET MY CANCELLATION HISTORY - Historique des annulations
* GET /api/v1/my-cancellation-history
@@ -14,6 +14,7 @@ import {
getOrderETA,
confirmReception,
cancelCommand,
updateOwnCommandAddress,
isUserAuthenticated,
getPublicSettings,
} from "../../api/api";
@@ -287,6 +288,12 @@ function SuiviLivraison() {
useState<CancelCommandResponse | null>(null);
const [poolNames, setPoolNames] = useState<string[]>([]);
const [editingAddressOrder, setEditingAddressOrder] = useState<
number | null
>(null);
const [newAddress, setNewAddress] = useState("");
const [editAddressLoading, setEditAddressLoading] = useState(false);
useEffect(() => {
getPublicSettings().then((s) => setPoolNames(s.pool_names ?? []));
}, []);
@@ -574,6 +581,53 @@ function SuiviLivraison() {
handleCancelOrder(true);
};
const openEditAddressDialog = (orderId: number) => {
if (!isUserAuthenticated()) {
navigate("/login/client", { replace: true });
return;
}
const order = orders.find((o) => o.id === orderId);
setNewAddress(order ? getDeliveryAddress(order) : "");
setEditingAddressOrder(orderId);
};
const closeEditAddressDialog = () => {
setEditingAddressOrder(null);
setNewAddress("");
};
const handleUpdateAddress = async () => {
if (!editingAddressOrder || !newAddress.trim()) return;
try {
setEditAddressLoading(true);
const response = await updateOwnCommandAddress(
editingAddressOrder,
newAddress.trim(),
);
if (response.success) {
showToast("Adresse mise à jour", "success");
closeEditAddressDialog();
loadOrders();
} else {
showToast(
response.message || "Erreur lors de la mise à jour",
"error",
);
}
} catch (error: unknown) {
showToast(
error instanceof Error
? error.message
: "Erreur lors de la mise à jour de l'adresse",
"error",
);
} finally {
setEditAddressLoading(false);
}
};
if (loading && orders.length === 0) {
return (
<>
@@ -1143,6 +1197,27 @@ function SuiviLivraison() {
</div>
) : (
<div className="action-buttons">
{(statusLow ===
"pending" ||
statusLow ===
"assigned") && (
<button
className="btn-secondary"
onClick={() =>
openEditAddressDialog(
order.id,
)
}
>
<FontAwesomeIcon
icon={
faMapMarkerAlt
}
/>{" "}
Modifier
l'adresse
</button>
)}
<button
className="btn-cancel-order"
onClick={() =>
@@ -1263,6 +1338,73 @@ function SuiviLivraison() {
</div>
)}
{/* Dialog de modification d'adresse */}
{editingAddressOrder !== null && (
<div
className="confirm-dialog-overlay"
onClick={closeEditAddressDialog}
>
<div
className="confirm-dialog"
onClick={(e) => e.stopPropagation()}
>
<div className="confirm-dialog-header">
<h3>
<FontAwesomeIcon icon={faMapMarkerAlt} />{" "}
Modifier l'adresse de livraison
</h3>
</div>
<div className="confirm-dialog-body">
<div className="form-group">
<label htmlFor="new-address">
Nouvelle adresse de livraison
</label>
<textarea
id="new-address"
value={newAddress}
onChange={(e) =>
setNewAddress(e.target.value)
}
placeholder="Adresse complète"
rows={3}
/>
</div>
</div>
<div className="confirm-dialog-actions">
<button
className="btn-secondary"
onClick={closeEditAddressDialog}
disabled={editAddressLoading}
>
Retour
</button>
<button
className="btn-confirm"
onClick={handleUpdateAddress}
disabled={
editAddressLoading || !newAddress.trim()
}
>
{editAddressLoading ? (
<>
<FontAwesomeIcon
icon={faClock}
spin
/>{" "}
Enregistrement...
</>
) : (
<>
<FontAwesomeIcon icon={faCheck} />{" "}
Enregistrer
</>
)}
</button>
</div>
</div>
</div>
)}
{/* Dialog d'annulation */}
{showCancelDialog && (
<div