chore: build
Frontend Admin - EAS Build / build (push) Canceled after 0s
Frontend Client - EAS Build / build (push) Canceled after 0s
Backend - Build & Lint / build (push) Failing after 25m18s
Frontend Web - Build & Lint / build (push) Failing after 9m58s

This commit is contained in:
Xor290
2026-08-06 12:06:05 +02:00
parent c034088bee
commit 22a8d5026c
174 changed files with 30315 additions and 16120 deletions
@@ -15,6 +15,8 @@ import {
Modal,
StatusBar,
useWindowDimensions,
ScrollView,
Pressable,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import { spacing, fontSize, borderRadius } from "../../theme";
@@ -22,7 +24,10 @@ import { useTheme } from "../../context/ThemeContext";
import {
getAllDeliveryPersonsWithDetails,
getCommandByID,
getLivreurRatings,
getLivreurLoginHistory,
} from "../../api/api_admin";
import type { LoginHistoryWeek } from "../../api/api_admin";
import { geocodeAddress, calculateRoute } from "../../api/tomtom";
import type { RouteInfo } from "../../api/tomtom";
import type { DeliveryPerson } from "../../api/types";
@@ -61,6 +66,76 @@ export default function DeliveryScreen() {
const [routeInfo, setRouteInfo] = useState<RouteInfo | null>(null);
const [routeLoading, setRouteLoading] = useState(false);
// Avis livreur
const [ratingsModal, setRatingsModal] = useState<{
username: string;
ratings: { id: number; order_id: number; client_username: string; rating: number; comment: string; created_at: string }[];
average: number;
count: number;
} | null>(null);
const [ratingsLoading, setRatingsLoading] = useState(false);
const openRatings = async (username: string) => {
setRatingsLoading(true);
const data = await getLivreurRatings(username);
setRatingsModal({ username, ...data });
setRatingsLoading(false);
};
// Historique de connexion livreur
const [loginHistoryModal, setLoginHistoryModal] = useState<{
username: string;
year: number;
month: number;
weeks: LoginHistoryWeek[];
} | null>(null);
const [loginHistoryLoading, setLoginHistoryLoading] = useState(false);
const loginHistoryRequestRef = useRef(0);
const fetchLoginHistory = async (
username: string,
year: number,
month: number,
) => {
const requestId = ++loginHistoryRequestRef.current;
setLoginHistoryLoading(true);
const res = await getLivreurLoginHistory(username, year, month);
if (requestId !== loginHistoryRequestRef.current) return;
setLoginHistoryModal({
username,
year: res.year,
month: res.month,
weeks: res.weeks,
});
setLoginHistoryLoading(false);
};
const openLoginHistory = (username: string) => {
const now = new Date();
fetchLoginHistory(username, now.getFullYear(), now.getMonth() + 1);
};
const changeLoginHistoryMonth = (delta: number) => {
if (!loginHistoryModal || loginHistoryLoading) return;
let year = loginHistoryModal.year;
let month = loginHistoryModal.month + delta;
if (month < 1) {
month = 12;
year -= 1;
} else if (month > 12) {
month = 1;
year += 1;
}
const now = new Date();
if (
year > now.getFullYear() ||
(year === now.getFullYear() && month > now.getMonth() + 1)
) {
return;
}
fetchLoginHistory(loginHistoryModal.username, year, month);
};
const loadData = useCallback(async () => {
try {
const result = await getAllDeliveryPersonsWithDetails();
@@ -338,6 +413,66 @@ export default function DeliveryScreen() {
fontWeight: "500",
},
ratingsBtn: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
gap: spacing.s,
marginTop: spacing.m,
paddingVertical: spacing.s,
paddingHorizontal: spacing.m,
borderRadius: borderRadius.sm,
borderWidth: 1,
borderColor: "#f59e0b",
},
ratingsBtnText: {
color: "#f59e0b",
fontSize: fontSize.sm,
fontWeight: "600",
},
historyBtn: {
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
gap: spacing.s,
marginTop: spacing.m,
paddingVertical: spacing.s,
paddingHorizontal: spacing.m,
borderRadius: borderRadius.sm,
borderWidth: 1,
borderColor: colors.accent,
},
historyBtnText: {
color: colors.accent,
fontSize: fontSize.sm,
fontWeight: "600",
},
historyWeekLabel: {
color: colors.textMuted,
fontSize: fontSize.xs,
fontWeight: "700",
textTransform: "uppercase",
marginBottom: spacing.xs,
marginTop: spacing.m,
},
historyEntryRow: {
flexDirection: "row",
justifyContent: "space-between",
paddingVertical: spacing.xs,
borderTopWidth: 1,
borderTopColor: colors.borderLight,
},
historyEntryDate: {
color: colors.textPrimary,
fontSize: fontSize.sm,
},
historyEntryTime: {
color: colors.textMuted,
fontSize: fontSize.sm,
},
trackBtn: {
flexDirection: "row",
alignItems: "center",
@@ -356,6 +491,80 @@ export default function DeliveryScreen() {
fontWeight: "600",
},
ratingsOverlay: {
flex: 1,
backgroundColor: "rgba(0,0,0,0.7)",
justifyContent: "flex-end",
},
ratingsSheet: {
backgroundColor: colors.bgCard,
borderTopLeftRadius: borderRadius.xl,
borderTopRightRadius: borderRadius.xl,
padding: spacing.l,
maxHeight: "80%",
},
ratingsHeader: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: spacing.s,
},
ratingsTitle: {
color: colors.textWhite,
fontSize: fontSize.lg,
fontWeight: "700",
},
ratingsAvg: {
flexDirection: "row",
alignItems: "center",
gap: spacing.xs,
marginBottom: spacing.l,
},
ratingsAvgText: {
color: "#f59e0b",
fontSize: fontSize.md,
fontWeight: "700",
},
ratingsCount: {
color: colors.textMuted,
fontSize: fontSize.sm,
},
ratingItem: {
borderTopWidth: 1,
borderTopColor: colors.borderLight,
paddingVertical: spacing.m,
},
ratingItemHeader: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: spacing.xs,
},
ratingItemClient: {
color: colors.textPrimary,
fontSize: fontSize.sm,
fontWeight: "600",
},
ratingItemDate: {
color: colors.textMuted,
fontSize: fontSize.xs,
},
ratingStarsRow: {
flexDirection: "row",
gap: 2,
marginBottom: spacing.xs,
},
ratingItemComment: {
color: colors.textSecondary,
fontSize: fontSize.sm,
fontStyle: "italic",
},
ratingsEmpty: {
color: colors.textMuted,
textAlign: "center",
paddingVertical: spacing.xl,
},
empty: {
color: colors.textMuted,
textAlign: "center",
@@ -523,6 +732,30 @@ export default function DeliveryScreen() {
</Text>
)}
<TouchableOpacity
style={styles.ratingsBtn}
onPress={() => openRatings(item.username)}
activeOpacity={0.7}
>
<Ionicons name="star-outline" size={14} color="#f59e0b" />
<Text style={styles.ratingsBtnText}>Voir les avis</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.historyBtn}
onPress={() => openLoginHistory(item.username)}
activeOpacity={0.7}
>
<Ionicons
name="time-outline"
size={14}
color={colors.accent}
/>
<Text style={styles.historyBtnText}>
Historique de connexion
</Text>
</TouchableOpacity>
{hasGPS && (
<TouchableOpacity
style={[
@@ -835,6 +1068,252 @@ export default function DeliveryScreen() {
<Text style={styles.empty}>Aucun livreur</Text>
}
/>
{/* ── Modal avis livreur ── */}
<Modal
visible={ratingsModal !== null}
transparent
animationType="slide"
onRequestClose={() => setRatingsModal(null)}
>
<Pressable style={styles.ratingsOverlay} onPress={() => setRatingsModal(null)}>
<Pressable onPress={() => {}}>
<View style={styles.ratingsSheet}>
<View style={styles.ratingsHeader}>
<Text style={styles.ratingsTitle}>
Avis — {ratingsModal?.username}
</Text>
<TouchableOpacity onPress={() => setRatingsModal(null)}>
<Ionicons name="close" size={22} color={colors.textMuted} />
</TouchableOpacity>
</View>
{ratingsLoading ? (
<Text style={styles.ratingsEmpty}>Chargement...</Text>
) : ratingsModal && ratingsModal.count > 0 ? (
<>
<View style={styles.ratingsAvg}>
{[1,2,3,4,5].map((s) => (
<Ionicons
key={s}
name={s <= Math.round(ratingsModal.average) ? "star" : "star-outline"}
size={20}
color="#f59e0b"
/>
))}
<Text style={styles.ratingsAvgText}>
{ratingsModal.average.toFixed(1)}
</Text>
<Text style={styles.ratingsCount}>
({ratingsModal.count} avis)
</Text>
</View>
<ScrollView showsVerticalScrollIndicator={false}>
{ratingsModal.ratings.map((r) => (
<View key={r.id} style={styles.ratingItem}>
<View style={styles.ratingItemHeader}>
<Text style={styles.ratingItemClient}>{r.client_username}</Text>
<Text style={styles.ratingItemDate}>
{new Date(r.created_at).toLocaleDateString("fr-FR")}
</Text>
</View>
<View style={styles.ratingStarsRow}>
{[1,2,3,4,5].map((s) => (
<Ionicons
key={s}
name={s <= r.rating ? "star" : "star-outline"}
size={14}
color="#f59e0b"
/>
))}
</View>
{r.comment !== "" && (
<Text style={styles.ratingItemComment}>"{r.comment}"</Text>
)}
</View>
))}
</ScrollView>
</>
) : (
<Text style={styles.ratingsEmpty}>Aucun avis pour ce livreur</Text>
)}
</View>
</Pressable>
</Pressable>
</Modal>
{/* ── Modal historique de connexion livreur ── */}
<Modal
visible={loginHistoryModal !== null}
transparent
animationType="slide"
onRequestClose={() => setLoginHistoryModal(null)}
>
<Pressable
style={styles.ratingsOverlay}
onPress={() => setLoginHistoryModal(null)}
>
<Pressable onPress={() => {}}>
<View style={styles.ratingsSheet}>
<View style={styles.ratingsHeader}>
<Text style={styles.ratingsTitle}>
Connexions — {loginHistoryModal?.username}
</Text>
<TouchableOpacity
onPress={() => setLoginHistoryModal(null)}
>
<Ionicons
name="close"
size={22}
color={colors.textMuted}
/>
</TouchableOpacity>
</View>
{(() => {
const now = new Date();
const isCurrentMonth =
!!loginHistoryModal &&
loginHistoryModal.year ===
now.getFullYear() &&
loginHistoryModal.month ===
now.getMonth() + 1;
const canGoBack = !loginHistoryLoading;
const canGoForward =
!loginHistoryLoading && !isCurrentMonth;
return (
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
marginBottom: spacing.m,
}}
>
<TouchableOpacity
disabled={!canGoBack}
onPress={() =>
changeLoginHistoryMonth(-1)
}
hitSlop={8}
>
<Ionicons
name="chevron-back"
size={20}
color={
canGoBack
? colors.textPrimary
: colors.textMuted
}
/>
</TouchableOpacity>
<Text
style={{
color: colors.textWhite,
fontWeight: "700",
fontSize: fontSize.md,
}}
>
{loginHistoryModal &&
new Date(
loginHistoryModal.year,
loginHistoryModal.month -
1,
1,
)
.toLocaleDateString(
"fr-FR",
{
month: "long",
year: "numeric",
},
)
.replace(/^./, (c) =>
c.toUpperCase(),
)}
</Text>
<TouchableOpacity
disabled={!canGoForward}
onPress={() =>
changeLoginHistoryMonth(1)
}
hitSlop={8}
>
<Ionicons
name="chevron-forward"
size={20}
color={
canGoForward
? colors.textPrimary
: colors.textMuted
}
/>
</TouchableOpacity>
</View>
);
})()}
{loginHistoryLoading ? (
<Text style={styles.ratingsEmpty}>
Chargement...
</Text>
) : loginHistoryModal &&
loginHistoryModal.weeks.length > 0 ? (
<ScrollView showsVerticalScrollIndicator={false}>
{loginHistoryModal.weeks.map((week) => (
<View key={week.week}>
<Text style={styles.historyWeekLabel}>
Semaine {week.week}
</Text>
{week.entries.map((entry) => (
<View
key={entry.id}
style={styles.historyEntryRow}
>
<Text
style={
styles.historyEntryDate
}
>
{new Date(
entry.created_at,
).toLocaleDateString(
"fr-FR",
{
weekday: "short",
day: "2-digit",
month: "2-digit",
},
)}
</Text>
<Text
style={
styles.historyEntryTime
}
>
{new Date(
entry.created_at,
).toLocaleTimeString(
"fr-FR",
{
hour: "2-digit",
minute: "2-digit",
},
)}
</Text>
</View>
))}
</View>
))}
</ScrollView>
) : (
<Text style={styles.ratingsEmpty}>
Aucune connexion ce mois-ci
</Text>
)}
</View>
</Pressable>
</Pressable>
</Modal>
</View>
);
}