chore: add select
This commit is contained in:
@@ -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,6 +585,8 @@ export default function OrdersScreen() {
|
||||
{itemsModal.items.map((item: any) => (
|
||||
<View key={item.id} style={styles.itemCard}>
|
||||
<View style={styles.itemCardBody}>
|
||||
<View style={styles.itemRow}>
|
||||
<View style={{ flex: 1 }}>
|
||||
<Text style={styles.itemName}>
|
||||
{item.produit ?? item.product_name}
|
||||
</Text>
|
||||
@@ -566,6 +595,24 @@ export default function OrdersScreen() {
|
||||
{(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>
|
||||
))}
|
||||
{itemsModal.items.length === 0 && (
|
||||
|
||||
Reference in New Issue
Block a user