chore: build
Backend - Build & Lint / build (push) Has been cancelled
Frontend Client - EAS Build / build (push) Has been cancelled
Frontend Web - Build & Lint / build (push) Has been cancelled

This commit is contained in:
2026-06-30 19:24:36 +02:00
parent 781212f706
commit 8d131a1ade
6 changed files with 420 additions and 139 deletions
@@ -20,6 +20,7 @@ import {
formatOrderDate,
formatPrice,
calculateOrderTotal,
getPublicSettings,
} from "../../api/api";
import type {
OrderDetail,
@@ -72,6 +73,7 @@ export default function OrderTrackingScreen() {
const [penaltyWarning, setPenaltyWarning] =
useState<CancelCommandResponse | null>(null);
const [penaltyOrderId, setPenaltyOrderId] = useState<number | null>(null);
const [penaltiesEnabled, setPenaltiesEnabled] = useState(false);
const [toastMsg, setToastMsg] = useState("");
const [toastType, setToastType] = useState<
"success" | "error" | "warning" | "info"
@@ -98,6 +100,12 @@ export default function OrderTrackingScreen() {
}
}, []);
useEffect(() => {
getPublicSettings()
.then((s) => setPenaltiesEnabled(s.penalties_enabled))
.catch(() => {});
}, []);
useFocusEffect(
useCallback(() => {
setLoading(true);
@@ -140,7 +148,6 @@ export default function OrderTrackingScreen() {
"success",
);
fetchOrders();
navigation.navigate("OrderDetails", { orderId });
} else {
showToast(res.message || "Erreur", "error");
}
@@ -274,21 +281,6 @@ export default function OrderTrackingScreen() {
gap: spacing.s,
marginTop: spacing.l,
},
confirmBanner: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
gap: spacing.s,
backgroundColor: colors.success,
borderRadius: borderRadius.md,
paddingVertical: spacing.m,
marginTop: spacing.m,
},
confirmBannerText: {
color: "#fff",
fontWeight: "700",
fontSize: fontSize.sm,
},
proposalBox: {
backgroundColor: colors.warning + "18",
borderWidth: 1,
@@ -402,7 +394,10 @@ export default function OrderTrackingScreen() {
renderItem={({ item: order }) => {
const expanded = expandedId === order.id;
const gross = calculateOrderTotal(order);
const total = Math.max(0, gross - (order.referral_used ?? 0));
const total = Math.max(
0,
gross - (order.referral_used ?? 0),
);
const progress = STATUS_PROGRESS[order.status] || 0;
const track = tracking[order.id];
const eta = etas[order.id];
@@ -466,8 +461,18 @@ export default function OrderTrackingScreen() {
{formatPrice(total)}
</Text>
{(order.referral_used ?? 0) > 0 && (
<Text style={{ fontSize: 11, color: colors.success, marginTop: 2 }}>
dont -{(order.referral_used as number).toFixed(2)} parrainage
<Text
style={{
fontSize: 11,
color: colors.success,
marginTop: 2,
}}
>
dont -
{(
order.referral_used as number
).toFixed(2)}{" "}
parrainage
</Text>
)}
</View>
@@ -481,16 +486,6 @@ export default function OrderTrackingScreen() {
color={colors.textMuted}
/>
</View>
{canConfirm && (
<TouchableOpacity
activeOpacity={0.85}
onPress={() => setConfirmingId(order.id)}
style={styles.confirmBanner}
>
<Ionicons name="checkmark-circle-outline" size={18} color="#fff" />
<Text style={styles.confirmBannerText}>Valider la réception</Text>
</TouchableOpacity>
)}
{order.address_proposal_status === "pending" &&
order.proposed_address && (
<View style={styles.proposalBox}>
@@ -571,9 +566,7 @@ export default function OrderTrackingScreen() {
</Text>
</View>
)}
{order.status === "en_route" &&
eta?.eta_minutes != null &&
eta.eta_minutes > 0 && (
{order.status === "en_route" && (
<View style={styles.trackRow}>
<Ionicons
name="timer-outline"
@@ -581,7 +574,10 @@ export default function OrderTrackingScreen() {
color={colors.warning}
/>
<Text style={styles.trackText}>
Temps de livraison estimé : ~{eta.eta_minutes} min
{eta?.eta_minutes != null &&
eta.eta_minutes > 0
? `Temps de livraison estimé : ~${eta.eta_minutes} min`
: "Aucune heure disponible"}
</Text>
</View>
)}
@@ -593,7 +589,8 @@ export default function OrderTrackingScreen() {
color={colors.warning}
/>
<Text style={styles.trackText}>
Temps de livraison estimé : ~
Temps de livraison estimé :
~
{eta?.eta_minutes != null &&
eta.eta_minutes > 0 &&
eta.eta_minutes < 5
@@ -627,6 +624,18 @@ export default function OrderTrackingScreen() {
variant="outline"
size="sm"
/>
{canConfirm && (
<Button
title="Confirmer reception"
onPress={() =>
setConfirmingId(
order.id,
)
}
variant="success"
size="sm"
/>
)}
{canCancel && (
<Button
title="Annuler"
@@ -691,6 +700,39 @@ export default function OrderTrackingScreen() {
iconColor={colors.danger}
>
<View style={styles.modalBody}>
{penaltiesEnabled && (
<View
style={{
flexDirection: "row",
alignItems: "flex-start",
gap: 8,
backgroundColor: colors.danger + "18",
borderWidth: 1,
borderColor: colors.danger + "55",
borderRadius: 8,
padding: 12,
marginBottom: 12,
}}
>
<Ionicons
name="warning-outline"
size={18}
color={colors.danger}
style={{ marginTop: 1 }}
/>
<Text
style={{
flex: 1,
color: colors.danger,
fontSize: 13,
lineHeight: 18,
}}
>
Attention : en cas d'annulations répétées, une
amende sera appliquée à votre compte.
</Text>
</View>
)}
<Text style={styles.modalText}>
Raison de l'annulation :
</Text>
@@ -753,12 +795,17 @@ export default function OrderTrackingScreen() {
<Ionicons
name="remove-circle-outline"
size={16}
color={colors.warning}
color={colors.danger}
/>
<Text style={styles.penaltyDetail}>
Penalite:{" "}
<Text
style={[
styles.penaltyDetail,
{ color: colors.danger, fontWeight: "700" },
]}
>
Amende :{" "}
{penaltyWarning.penalty_warning.penalty_amount}{" "}
points
</Text>
</View>
)}