From e14a1eb4b8a0224f0e3a2e28272fb72ccd2de989 Mon Sep 17 00:00:00 2001 From: Xor290 Date: Fri, 6 Mar 2026 18:21:33 +0100 Subject: [PATCH] chore: add select --- .../src/screens/admin/OrdersScreen.tsx | 221 ++++++++---- .../src/screens/cabine/OrdersScreen.tsx | 315 +++++++++--------- .../src/screens/delivery/DashboardScreen.tsx | 48 ++- 3 files changed, 347 insertions(+), 237 deletions(-) diff --git a/frontend-admin/src/screens/admin/OrdersScreen.tsx b/frontend-admin/src/screens/admin/OrdersScreen.tsx index 2ca2dbb8..2cef85f2 100644 --- a/frontend-admin/src/screens/admin/OrdersScreen.tsx +++ b/frontend-admin/src/screens/admin/OrdersScreen.tsx @@ -28,7 +28,6 @@ import type { AdminStackParamList } from "../../navigation/types"; import StatusBadge from "../../components/StatusBadge"; import LoadingSpinner from "../../components/ui/LoadingSpinner"; import Modal from "../../components/ui/Modal"; -import Button from "../../components/ui/Button"; import Card from "../../components/ui/Card"; import AlertModal from "../../components/ui/AlertModal"; import { useAlert } from "../../hooks/useAlert"; @@ -55,6 +54,7 @@ export default function OrdersScreen() { const [filter, setFilter] = useState("all"); const { alert, showError, showSuccess, showConfirm, hideAlert } = useAlert(); + const [openMenuId, setOpenMenuId] = useState(null); const [assignModal, setAssignModal] = useState<{ visible: boolean; commandId: number | null; @@ -243,11 +243,47 @@ export default function OrdersScreen() { alignItems: "center", marginBottom: spacing.s, }, - actions: { + selectBtn: { flexDirection: "row", - flexWrap: "wrap", - gap: spacing.s, + alignItems: "center", + justifyContent: "space-between", marginTop: spacing.m, + paddingHorizontal: spacing.m, + paddingVertical: spacing.s, + backgroundColor: colors.bgPrimary, + borderRadius: borderRadius.sm, + borderWidth: 1, + borderColor: colors.border, + }, + selectBtnText: { + color: colors.textSecondary, + fontSize: fontSize.sm, + }, + dropdown: { + marginTop: 2, + backgroundColor: colors.bgCard, + borderRadius: borderRadius.sm, + borderWidth: 1, + borderColor: colors.border, + overflow: "hidden", + }, + dropdownItem: { + flexDirection: "row", + alignItems: "center", + gap: spacing.s, + paddingHorizontal: spacing.m, + paddingVertical: spacing.m, + borderBottomWidth: 1, + borderBottomColor: colors.border, + }, + dropdownItemLast: { borderBottomWidth: 0 }, + dropdownText: { + color: colors.textWhite, + fontSize: fontSize.sm, + }, + dropdownTextDanger: { + color: colors.error, + fontSize: fontSize.sm, }, empty: { color: colors.textMuted, @@ -313,80 +349,117 @@ export default function OrdersScreen() { [colors], ); - const renderOrder = ({ item }: { item: CommandResponse }) => ( - - - navigation.navigate("OrderDetail", { orderId: item.id }) - } - activeOpacity={0.7} - > - - #{item.id} - - - Client: {item.username} - Adresse: {item.adresse} - - Total: {item.total_prix.toFixed(2)} € - - {item.livreur_assign && ( + const renderOrder = ({ item }: { item: CommandResponse }) => { + const isOpen = openMenuId === item.id; + const isDone = ["approved", "cancelled"].includes(item.status); + + type Action = { + label: string; + icon: keyof typeof Ionicons.glyphMap; + onPress: () => void; + danger?: boolean; + condition?: boolean; + }; + + const actions: Action[] = [ + { + label: "Voir items", + icon: "receipt-outline", + onPress: () => { setOpenMenuId(null); openItems(item.id); }, + }, + { + label: "Le client est là", + icon: "notifications-outline", + onPress: () => { setOpenMenuId(null); handleNotifyClient(item.id); }, + condition: !isDone, + }, + { + label: "Assigner livreur", + icon: "bicycle-outline", + onPress: () => { setOpenMenuId(null); openAssignModal(item.id); }, + condition: !isDone, + }, + { + label: "Passer en route", + icon: "car-outline", + onPress: () => { setOpenMenuId(null); handleStatusUpdate(item.id, "en_route"); }, + condition: item.status === "assigned", + }, + { + label: "Confirmer réception", + icon: "checkmark-circle-outline", + onPress: () => { setOpenMenuId(null); handleConfirmReception(item.id); }, + condition: item.status === "livre", + }, + { + label: "Supprimer", + icon: "trash-outline", + onPress: () => { setOpenMenuId(null); handleDelete(item.id); }, + danger: true, + }, + ].filter((a) => a.condition !== false); + + return ( + + navigation.navigate("OrderDetail", { orderId: item.id })} + activeOpacity={0.7} + > + + #{item.id} + + + Client: {item.username} + Adresse: {item.adresse} - Livreur: {item.livreur_assign} + Total: {item.total_prix.toFixed(2)} € - )} - - {new Date(item.created_at).toLocaleString("fr-FR")} - - - -