chore: add button for livreur
This commit is contained in:
@@ -446,6 +446,18 @@ export default function DashboardScreen() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleArrivedDelivery = async (deliveryId: number) => {
|
||||
const lat = lastCoords?.lat || 0;
|
||||
const lng = lastCoords?.lng || 0;
|
||||
const res = await updateDeliveryStatus(deliveryId, "arrived", lat, lng);
|
||||
if (res.success) {
|
||||
showSuccess("Succès", "Statut mis à jour : arrivé à destination");
|
||||
loadData();
|
||||
} else {
|
||||
showError("Erreur", res.error || "Erreur");
|
||||
}
|
||||
};
|
||||
|
||||
const handleCompleteDelivery = async (deliveryId: number) => {
|
||||
const lat = lastCoords?.lat || 0;
|
||||
const lng = lastCoords?.lng || 0;
|
||||
@@ -474,6 +486,7 @@ export default function DashboardScreen() {
|
||||
const isActive =
|
||||
item.status === "in_progress" ||
|
||||
item.status === "en_route" ||
|
||||
item.status === "arrived" ||
|
||||
item.status === "assigned";
|
||||
|
||||
return (
|
||||
@@ -494,6 +507,8 @@ export default function DashboardScreen() {
|
||||
item.status === "completed" ||
|
||||
item.status === "livre"
|
||||
? "Terminée"
|
||||
: item.status === "arrived"
|
||||
? "Arrivé"
|
||||
: item.status === "in_progress" ||
|
||||
item.status === "en_route"
|
||||
? "En cours"
|
||||
@@ -503,6 +518,8 @@ export default function DashboardScreen() {
|
||||
item.status === "completed" ||
|
||||
item.status === "livre"
|
||||
? colors.success
|
||||
: item.status === "arrived"
|
||||
? colors.accent
|
||||
: item.status === "in_progress" ||
|
||||
item.status === "en_route"
|
||||
? colors.warning
|
||||
@@ -629,6 +646,16 @@ export default function DashboardScreen() {
|
||||
)}
|
||||
{(item.status === "in_progress" ||
|
||||
item.status === "en_route") && (
|
||||
<Button
|
||||
title="J'arrive"
|
||||
onPress={() => handleArrivedDelivery(item.id)}
|
||||
style={{
|
||||
marginTop: spacing.s,
|
||||
backgroundColor: colors.warning,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{item.status === "arrived" && (
|
||||
<Button
|
||||
title="Terminer la livraison"
|
||||
onPress={() => handleCompleteDelivery(item.id)}
|
||||
|
||||
Reference in New Issue
Block a user