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 handleCompleteDelivery = async (deliveryId: number) => {
|
||||||
const lat = lastCoords?.lat || 0;
|
const lat = lastCoords?.lat || 0;
|
||||||
const lng = lastCoords?.lng || 0;
|
const lng = lastCoords?.lng || 0;
|
||||||
@@ -474,6 +486,7 @@ export default function DashboardScreen() {
|
|||||||
const isActive =
|
const isActive =
|
||||||
item.status === "in_progress" ||
|
item.status === "in_progress" ||
|
||||||
item.status === "en_route" ||
|
item.status === "en_route" ||
|
||||||
|
item.status === "arrived" ||
|
||||||
item.status === "assigned";
|
item.status === "assigned";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -494,6 +507,8 @@ export default function DashboardScreen() {
|
|||||||
item.status === "completed" ||
|
item.status === "completed" ||
|
||||||
item.status === "livre"
|
item.status === "livre"
|
||||||
? "Terminée"
|
? "Terminée"
|
||||||
|
: item.status === "arrived"
|
||||||
|
? "Arrivé"
|
||||||
: item.status === "in_progress" ||
|
: item.status === "in_progress" ||
|
||||||
item.status === "en_route"
|
item.status === "en_route"
|
||||||
? "En cours"
|
? "En cours"
|
||||||
@@ -503,6 +518,8 @@ export default function DashboardScreen() {
|
|||||||
item.status === "completed" ||
|
item.status === "completed" ||
|
||||||
item.status === "livre"
|
item.status === "livre"
|
||||||
? colors.success
|
? colors.success
|
||||||
|
: item.status === "arrived"
|
||||||
|
? colors.accent
|
||||||
: item.status === "in_progress" ||
|
: item.status === "in_progress" ||
|
||||||
item.status === "en_route"
|
item.status === "en_route"
|
||||||
? colors.warning
|
? colors.warning
|
||||||
@@ -629,6 +646,16 @@ export default function DashboardScreen() {
|
|||||||
)}
|
)}
|
||||||
{(item.status === "in_progress" ||
|
{(item.status === "in_progress" ||
|
||||||
item.status === "en_route") && (
|
item.status === "en_route") && (
|
||||||
|
<Button
|
||||||
|
title="J'arrive"
|
||||||
|
onPress={() => handleArrivedDelivery(item.id)}
|
||||||
|
style={{
|
||||||
|
marginTop: spacing.s,
|
||||||
|
backgroundColor: colors.warning,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{item.status === "arrived" && (
|
||||||
<Button
|
<Button
|
||||||
title="Terminer la livraison"
|
title="Terminer la livraison"
|
||||||
onPress={() => handleCompleteDelivery(item.id)}
|
onPress={() => handleCompleteDelivery(item.id)}
|
||||||
|
|||||||
Reference in New Issue
Block a user