chore: add new features cabine & admin
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
TouchableOpacity,
|
||||
Modal,
|
||||
StatusBar,
|
||||
Alert,
|
||||
} from "react-native";
|
||||
import { useRoute, type RouteProp } from "@react-navigation/native";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
@@ -19,7 +20,9 @@ import {
|
||||
updateCommandStatus,
|
||||
validateCommand,
|
||||
confirmReceptionAdmin,
|
||||
notifyClientToDescend,
|
||||
getDeliveryPersonDetails,
|
||||
deleteCommandItem,
|
||||
} from "../../api/api_admin";
|
||||
import { geocodeAddress, calculateRoute } from "../../api/tomtom";
|
||||
import type { RouteInfo, LatLng } from "../../api/tomtom";
|
||||
@@ -167,6 +170,40 @@ export default function OrderDetailScreen() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleNotifyClient = async () => {
|
||||
try {
|
||||
await notifyClientToDescend(orderId);
|
||||
showSuccess("Notification envoyée", "Le client a été prévenu de descendre");
|
||||
} catch (e: any) {
|
||||
showError("Erreur", e.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteItem = (itemId: number, itemName: string) => {
|
||||
Alert.alert(
|
||||
"Supprimer l'article",
|
||||
`Supprimer "${itemName}" de la commande ?`,
|
||||
[
|
||||
{ text: "Annuler", style: "cancel" },
|
||||
{
|
||||
text: "Supprimer",
|
||||
style: "destructive",
|
||||
onPress: async () => {
|
||||
try {
|
||||
await deleteCommandItem(orderId, itemId);
|
||||
const itemsRes = await getCommandItems(orderId);
|
||||
setItems(itemsRes.items);
|
||||
const cmdRes = await getCommandByID(orderId);
|
||||
setCommand(cmdRes.command);
|
||||
} catch (e: any) {
|
||||
showError("Erreur", e.message);
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
);
|
||||
};
|
||||
|
||||
const handleConfirmReception = async () => {
|
||||
try {
|
||||
const res = await confirmReceptionAdmin(orderId);
|
||||
@@ -222,6 +259,11 @@ export default function OrderDetailScreen() {
|
||||
itemDetails: {
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
},
|
||||
itemDeleteBtn: {
|
||||
padding: spacing.xs,
|
||||
marginLeft: spacing.s,
|
||||
},
|
||||
actions: { marginTop: spacing.m, marginBottom: spacing.xxl },
|
||||
empty: {
|
||||
@@ -605,7 +647,26 @@ export default function OrderDetailScreen() {
|
||||
<Text style={styles.sectionTitle}>Articles ({items.length})</Text>
|
||||
{items.map((item: any) => (
|
||||
<Card key={item.id} style={{ marginBottom: spacing.s }}>
|
||||
<Text style={styles.itemName}>{item.product_name}</Text>
|
||||
<View style={styles.row}>
|
||||
<Text style={[styles.itemName, { flex: 1 }]}>
|
||||
{item.produit ?? item.product_name}
|
||||
</Text>
|
||||
<TouchableOpacity
|
||||
style={styles.itemDeleteBtn}
|
||||
onPress={() =>
|
||||
handleDeleteItem(
|
||||
item.id,
|
||||
item.produit ?? item.product_name,
|
||||
)
|
||||
}
|
||||
>
|
||||
<Ionicons
|
||||
name="trash-outline"
|
||||
size={18}
|
||||
color={colors.danger}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View style={styles.itemDetails}>
|
||||
<Text style={styles.info}>
|
||||
Quantité: {item.quantite}
|
||||
@@ -647,6 +708,15 @@ export default function OrderDetailScreen() {
|
||||
style={{ marginTop: spacing.s }}
|
||||
/>
|
||||
)}
|
||||
{!["approved", "cancelled"].includes(command.status) && (
|
||||
<Button
|
||||
title="Le client est là"
|
||||
onPress={handleNotifyClient}
|
||||
variant="warning"
|
||||
fullWidth
|
||||
style={{ marginTop: spacing.s }}
|
||||
/>
|
||||
)}
|
||||
{command.status === "livre" && (
|
||||
<Button
|
||||
title="Confirmer la réception"
|
||||
|
||||
Reference in New Issue
Block a user