chore: add new features

This commit is contained in:
2026-03-05 19:09:16 +01:00
parent 532584edb2
commit 5ca480ea0b
23 changed files with 695 additions and 284 deletions
@@ -18,6 +18,7 @@ import {
getCommandItems,
updateCommandStatus,
validateCommand,
confirmReceptionAdmin,
getDeliveryPersonDetails,
} from "../../api/api_admin";
import { geocodeAddress, calculateRoute } from "../../api/tomtom";
@@ -75,6 +76,16 @@ export default function OrderDetailScreen() {
load();
}, [orderId]);
useEffect(() => {
const interval = setInterval(async () => {
try {
const res = await getCommandByID(orderId);
setCommand(res.command);
} catch { /* ignore */ }
}, 20000);
return () => clearInterval(interval);
}, [orderId]);
const loadLivreurRoute = async (
livreurUsername: string,
deliveryAddress: string,
@@ -156,6 +167,20 @@ export default function OrderDetailScreen() {
}
};
const handleConfirmReception = async () => {
try {
const res = await confirmReceptionAdmin(orderId);
showSuccess(
"Réception confirmée",
`${res.points_earned} point(s) attribués au client ${res.client_username}`,
);
const updated = await getCommandByID(orderId);
setCommand(updated.command);
} catch (e: any) {
showError("Erreur", e.message);
}
};
const styles = useMemo(
() =>
StyleSheet.create({
@@ -622,6 +647,15 @@ export default function OrderDetailScreen() {
style={{ marginTop: spacing.s }}
/>
)}
{command.status === "livre" && (
<Button
title="Confirmer la réception"
onPress={handleConfirmReception}
variant="primary"
fullWidth
style={{ marginTop: spacing.s }}
/>
)}
</View>
<AlertModal
visible={alert.visible}