chore: add select

This commit is contained in:
2026-03-06 18:56:12 +01:00
parent 51a3426cf3
commit 3c2083c393
@@ -22,6 +22,7 @@ import {
notifyClientToDescend,
confirmReceptionAdmin,
deleteCommand,
deleteCommandItem,
} from "../../api/api_admin";
import type { CommandResponse } from "../../api/types";
import type { AdminStackParamList } from "../../navigation/types";
@@ -179,6 +180,23 @@ export default function OrdersScreen() {
);
};
const handleDeleteItem = (commandId: number, itemId: number, itemName: string) => {
showConfirm(
"Supprimer l'article",
`Supprimer "${itemName}" de la commande #${commandId} ?`,
async () => {
try {
await deleteCommandItem(commandId, itemId);
const result = await getCommandItems(commandId);
setItemsModal((prev) => ({ ...prev, items: result.items }));
} catch (e: any) {
showError("Erreur", e.message);
}
},
"Supprimer",
);
};
const handleDelete = (commandId: number) => {
showConfirm(
"Supprimer",
@@ -345,6 +363,15 @@ export default function OrdersScreen() {
color: colors.textMuted,
fontSize: fontSize.xs,
},
itemRow: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
},
itemDeleteBtn: {
padding: spacing.xs,
marginLeft: spacing.s,
},
}),
[colors],
);
@@ -558,13 +585,33 @@ export default function OrdersScreen() {
{itemsModal.items.map((item: any) => (
<View key={item.id} style={styles.itemCard}>
<View style={styles.itemCardBody}>
<Text style={styles.itemName}>
{item.produit ?? item.product_name}
</Text>
<Text style={styles.itemMeta}>
Qté: {item.quantite ?? item.quantity} ·{" "}
{(item.prix ?? item.price)?.toFixed(2)}
</Text>
<View style={styles.itemRow}>
<View style={{ flex: 1 }}>
<Text style={styles.itemName}>
{item.produit ?? item.product_name}
</Text>
<Text style={styles.itemMeta}>
Qté: {item.quantite ?? item.quantity} ·{" "}
{(item.prix ?? item.price)?.toFixed(2)}
</Text>
</View>
<TouchableOpacity
style={styles.itemDeleteBtn}
onPress={() =>
handleDeleteItem(
itemsModal.commandId!,
item.id,
item.produit ?? item.product_name,
)
}
>
<Ionicons
name="trash-outline"
size={18}
color={colors.danger}
/>
</TouchableOpacity>
</View>
</View>
</View>
))}