From c38ed9c4767a415466dbb401888143992a419ae5 Mon Sep 17 00:00:00 2001 From: Xor290 Date: Sat, 3 Oct 2026 14:21:15 +0200 Subject: [PATCH] chore: build --- frontend-admin/src/api/client.ts | 2 +- frontend-admin/src/api/types.ts | 1 + .../src/screens/admin/OrderDetailScreen.tsx | 1 + .../src/screens/admin/UsersScreen.tsx | 1 + .../src/screens/delivery/DashboardScreen.tsx | 108 ++++++++++++++++-- 5 files changed, 100 insertions(+), 13 deletions(-) diff --git a/frontend-admin/src/api/client.ts b/frontend-admin/src/api/client.ts index a7478af8..d52169b2 100644 --- a/frontend-admin/src/api/client.ts +++ b/frontend-admin/src/api/client.ts @@ -2,7 +2,7 @@ import axios from "axios"; import { getToken, getAdminToken } from "../auth/tokenStorage"; export const API_BASE_URL = - process.env.EXPO_PUBLIC_API_URL ?? "https://uber-demo.club"; + process.env.EXPO_PUBLIC_API_URL ?? "https://mln-uber.club"; const apiClient = axios.create({ baseURL: API_BASE_URL, diff --git a/frontend-admin/src/api/types.ts b/frontend-admin/src/api/types.ts index e93cc343..e344c4b0 100644 --- a/frontend-admin/src/api/types.ts +++ b/frontend-admin/src/api/types.ts @@ -142,6 +142,7 @@ export interface DeliveryItem { adresse: string; total_prix: number; referral_used?: number; + is_new_client?: boolean; created_at: string; updated_at: string; eta?: string; diff --git a/frontend-admin/src/screens/admin/OrderDetailScreen.tsx b/frontend-admin/src/screens/admin/OrderDetailScreen.tsx index a8f8ab3e..05cc6a12 100644 --- a/frontend-admin/src/screens/admin/OrderDetailScreen.tsx +++ b/frontend-admin/src/screens/admin/OrderDetailScreen.tsx @@ -73,6 +73,7 @@ export default function OrderDetailScreen() { setCommand(cmdRes.command); setItems(itemsRes.items ?? []); + // If livreur assigned, fetch their location and calc route const cmd = cmdRes.command; if (cmd?.livreur_assign && cmd?.adresse) { loadLivreurRoute(cmd.livreur_assign, cmd.adresse); diff --git a/frontend-admin/src/screens/admin/UsersScreen.tsx b/frontend-admin/src/screens/admin/UsersScreen.tsx index 678ccfcc..f753a4a7 100644 --- a/frontend-admin/src/screens/admin/UsersScreen.tsx +++ b/frontend-admin/src/screens/admin/UsersScreen.tsx @@ -48,6 +48,7 @@ import { useAlert } from "../../hooks/useAlert"; // -------------------------------------------------- // Types +// -------------------------------------------------- interface UserItem { id: number; username: string; diff --git a/frontend-admin/src/screens/delivery/DashboardScreen.tsx b/frontend-admin/src/screens/delivery/DashboardScreen.tsx index 626da74d..dc1f9e25 100644 --- a/frontend-admin/src/screens/delivery/DashboardScreen.tsx +++ b/frontend-admin/src/screens/delivery/DashboardScreen.tsx @@ -22,7 +22,7 @@ import { useWindowDimensions, } from "react-native"; import Geolocation from "@react-native-community/geolocation"; -import { Ionicons } from "@expo/vector-icons"; +import { Ionicons, FontAwesome5 } from "@expo/vector-icons"; import * as Location from "expo-location"; import { spacing, fontSize, borderRadius } from "../../theme"; import { useTheme } from "../../context/ThemeContext"; @@ -75,7 +75,7 @@ interface EnrichedDelivery extends DeliveryItem { clientUsername?: string; clientNom?: string; clientPrenom?: string; - items?: Array<{ produit: string; quantite: number; prix: number; unit?: string; is_reward?: boolean }>; + items?: Array<{ produit: string; quantite: number; prix: number; unit?: string; is_reward?: boolean; promo_discount?: number }>; } export default function DashboardScreen() { @@ -271,6 +271,8 @@ export default function DashboardScreen() { [], referral_used: detail.delivery?.referral_used || 0, + is_new_client: + detail.delivery?.is_new_client || false, }; } } catch { @@ -623,6 +625,38 @@ export default function DashboardScreen() { {item.clientName} )} + {item.is_new_client && ( + + + + NEW + + + )} )} - {item.items.map((prod, idx) => ( + {item.items.map((prod, idx) => { + const promoDiscount = prod.promo_discount ?? 0; + const hasPromo = !prod.is_reward && promoDiscount > 0; + const originalPrice = (prod.prix ?? 0) + promoDiscount; + const promoPercent = hasPromo && originalPrice > 0 + ? Math.round((promoDiscount / originalPrice) * 100) + : 0; + return ( @@ -718,16 +759,34 @@ export default function DashboardScreen() { Récompense )} + {hasPromo && ( + + + -{promoPercent}% + + )} Quantité: {prod.quantite}{prod.unit || ""} - - {prod.is_reward && (prod.prix ?? 0) === 0 ? "Offert" : `${(prod.prix ?? 0).toFixed(2)}€`} - + {hasPromo ? ( + + + {originalPrice.toFixed(2)}€ + + + {(prod.prix ?? 0).toFixed(2)}€ + + + ) : ( + + {prod.is_reward && (prod.prix ?? 0) === 0 ? "Offert" : `${(prod.prix ?? 0).toFixed(2)}€`} + + )} - ))} + ); + })} Total @@ -2010,7 +2069,14 @@ export default function DashboardScreen() { )} - {detailsDelivery.items.map((prod, idx) => ( + {detailsDelivery.items.map((prod, idx) => { + const promoDiscount = prod.promo_discount ?? 0; + const hasPromo = !prod.is_reward && promoDiscount > 0; + const originalPrice = (prod.prix ?? 0) + promoDiscount; + const promoPercent = hasPromo && originalPrice > 0 + ? Math.round((promoDiscount / originalPrice) * 100) + : 0; + return ( @@ -2021,16 +2087,34 @@ export default function DashboardScreen() { Récompense )} + {hasPromo && ( + + + -{promoPercent}% + + )} Quantité : {prod.quantite}{prod.unit || ""} - - {prod.is_reward && (prod.prix ?? 0) === 0 ? "Offert" : `${(prod.prix ?? 0).toFixed(2)}€`} - + {hasPromo ? ( + + + {originalPrice.toFixed(2)}€ + + + {(prod.prix ?? 0).toFixed(2)}€ + + + ) : ( + + {prod.is_reward && (prod.prix ?? 0) === 0 ? "Offert" : `${(prod.prix ?? 0).toFixed(2)}€`} + + )} - ))} + ); + })} ) : ( Aucun produit