chore: add select
This commit is contained in:
@@ -22,6 +22,7 @@ import {
|
|||||||
notifyClientToDescend,
|
notifyClientToDescend,
|
||||||
confirmReceptionAdmin,
|
confirmReceptionAdmin,
|
||||||
deleteCommand,
|
deleteCommand,
|
||||||
|
deleteCommandItem,
|
||||||
} from "../../api/api_admin";
|
} from "../../api/api_admin";
|
||||||
import type { CommandResponse } from "../../api/types";
|
import type { CommandResponse } from "../../api/types";
|
||||||
import type { AdminStackParamList } from "../../navigation/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) => {
|
const handleDelete = (commandId: number) => {
|
||||||
showConfirm(
|
showConfirm(
|
||||||
"Supprimer",
|
"Supprimer",
|
||||||
@@ -345,6 +363,15 @@ export default function OrdersScreen() {
|
|||||||
color: colors.textMuted,
|
color: colors.textMuted,
|
||||||
fontSize: fontSize.xs,
|
fontSize: fontSize.xs,
|
||||||
},
|
},
|
||||||
|
itemRow: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
},
|
||||||
|
itemDeleteBtn: {
|
||||||
|
padding: spacing.xs,
|
||||||
|
marginLeft: spacing.s,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
[colors],
|
[colors],
|
||||||
);
|
);
|
||||||
@@ -558,13 +585,33 @@ export default function OrdersScreen() {
|
|||||||
{itemsModal.items.map((item: any) => (
|
{itemsModal.items.map((item: any) => (
|
||||||
<View key={item.id} style={styles.itemCard}>
|
<View key={item.id} style={styles.itemCard}>
|
||||||
<View style={styles.itemCardBody}>
|
<View style={styles.itemCardBody}>
|
||||||
<Text style={styles.itemName}>
|
<View style={styles.itemRow}>
|
||||||
{item.produit ?? item.product_name}
|
<View style={{ flex: 1 }}>
|
||||||
</Text>
|
<Text style={styles.itemName}>
|
||||||
<Text style={styles.itemMeta}>
|
{item.produit ?? item.product_name}
|
||||||
Qté: {item.quantite ?? item.quantity} ·{" "}
|
</Text>
|
||||||
{(item.prix ?? item.price)?.toFixed(2)} €
|
<Text style={styles.itemMeta}>
|
||||||
</Text>
|
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>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user