From b0061cec8afcdf506e2d35ec11f617a673088b33 Mon Sep 17 00:00:00 2001 From: Xor290 Date: Sat, 7 Mar 2026 22:42:14 +0100 Subject: [PATCH] chore: fix --- frontend-admin/src/api/api_admin.ts | 5 + frontend-admin/src/api/api_cabine.ts | 6 +- .../src/screens/admin/SettingsScreen.tsx | 120 ++++++++++++++++++ .../src/screens/cabine/UsersScreen.tsx | 29 +++-- mobile/src/api/api.ts | 6 +- .../src/screens/client/OrderHistoryScreen.tsx | 80 +++++++----- 6 files changed, 203 insertions(+), 43 deletions(-) diff --git a/frontend-admin/src/api/api_admin.ts b/frontend-admin/src/api/api_admin.ts index 52d3424a..458af2b5 100644 --- a/frontend-admin/src/api/api_admin.ts +++ b/frontend-admin/src/api/api_admin.ts @@ -663,10 +663,15 @@ export const deleteCategoryAdmin = async ( export interface AppSettings { penalties_enabled: boolean; + show_amende_score: boolean; points_enabled: boolean; points_categories_weed: string[]; points_categories_zipette: string[]; points_separated: boolean; + points_weed_threshold_price: number; + points_weed_per_threshold: number; + points_zipette_threshold_price: number; + points_zipette_per_threshold: number; } export const getSettings = async (): Promise<{ success: boolean; settings?: AppSettings; error?: string }> => { diff --git a/frontend-admin/src/api/api_cabine.ts b/frontend-admin/src/api/api_cabine.ts index a89eb15c..f95c1736 100644 --- a/frontend-admin/src/api/api_cabine.ts +++ b/frontend-admin/src/api/api_cabine.ts @@ -346,7 +346,9 @@ export const getAllAlerts = async (): Promise<{ export interface PublicSettings { penalties_enabled: boolean; + show_amende_score: boolean; points_enabled: boolean; + points_separated: boolean; } export const getPublicSettings = async (): Promise => { @@ -354,9 +356,11 @@ export const getPublicSettings = async (): Promise => { const { data } = await apiClient.get(`http://5.181.0.112/api/v1/app-settings`); return { penalties_enabled: data.penalties_enabled ?? true, + show_amende_score: data.show_amende_score ?? true, points_enabled: data.points_enabled ?? true, + points_separated: data.points_separated ?? true, }; } catch { - return { penalties_enabled: true, points_enabled: true }; + return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true }; } }; diff --git a/frontend-admin/src/screens/admin/SettingsScreen.tsx b/frontend-admin/src/screens/admin/SettingsScreen.tsx index 485329e8..570789eb 100644 --- a/frontend-admin/src/screens/admin/SettingsScreen.tsx +++ b/frontend-admin/src/screens/admin/SettingsScreen.tsx @@ -7,6 +7,7 @@ import { Switch, TouchableOpacity, ActivityIndicator, + TextInput, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; import { spacing, fontSize, borderRadius } from "../../theme"; @@ -26,10 +27,15 @@ export default function SettingsScreen() { const [saving, setSaving] = useState(false); const [settings, setSettings] = useState({ penalties_enabled: true, + show_amende_score: true, points_enabled: true, points_categories_weed: [], points_categories_zipette: [], points_separated: true, + points_weed_threshold_price: 30, + points_weed_per_threshold: 1, + points_zipette_threshold_price: 30, + points_zipette_per_threshold: 1, }); const [categories, setCategories] = useState([]); @@ -142,6 +148,31 @@ export default function SettingsScreen() { paddingHorizontal: spacing.l, paddingBottom: spacing.m, }, + thresholdRow: { + flexDirection: "row", + alignItems: "center", + paddingHorizontal: spacing.l, + paddingVertical: spacing.m, + borderTopWidth: 1, + borderTopColor: colors.border, + gap: spacing.m, + }, + thresholdLabel: { flex: 1, fontSize: fontSize.md, color: colors.textPrimary, fontWeight: "600" }, + thresholdDesc: { fontSize: fontSize.sm, color: colors.textMuted, marginTop: 2 }, + thresholdInputs: { flexDirection: "row", alignItems: "center", gap: spacing.s }, + thresholdInput: { + backgroundColor: colors.bgPrimary, + borderWidth: 1, + borderColor: colors.border, + borderRadius: borderRadius.sm, + paddingHorizontal: spacing.s, + paddingVertical: 6, + color: colors.textPrimary, + fontSize: fontSize.md, + width: 64, + textAlign: "center", + }, + thresholdSep: { fontSize: fontSize.md, color: colors.textMuted }, saveButton: { backgroundColor: colors.accent, borderRadius: borderRadius.lg, @@ -188,6 +219,22 @@ export default function SettingsScreen() { thumbColor="#fff" /> + + + Afficher le score d'amendes + + Les clients et la cabine voient le nombre d'amendes + + + + setSettings((prev) => ({ ...prev, show_amende_score: v })) + } + trackColor={{ false: colors.border, true: colors.accent }} + thumbColor="#fff" + /> + {/* Système de points */} @@ -324,6 +371,79 @@ export default function SettingsScreen() { )} + {/* Barème de points */} + + Barème de points + + Pour chaque tranche de prix dépensée, le client gagne un nombre de points.{"\n"} + Exemple : 50€ = 2 pts → 100€ = 4 pts, 150€ = 6 pts... + + + {/* Weed */} + + + Pool Weed / Hash + Prix seuil → points gagnés + + + { + const n = parseFloat(v); + if (!isNaN(n) && n > 0) + setSettings((p) => ({ ...p, points_weed_threshold_price: n })); + }} + /> + € = + { + const n = parseInt(v, 10); + if (!isNaN(n) && n >= 0) + setSettings((p) => ({ ...p, points_weed_per_threshold: n })); + }} + /> + pts + + + + {/* Zipette */} + + + Pool Zipette + Prix seuil → points gagnés + + + { + const n = parseFloat(v); + if (!isNaN(n) && n > 0) + setSettings((p) => ({ ...p, points_zipette_threshold_price: n })); + }} + /> + € = + { + const n = parseInt(v, 10); + if (!isNaN(n) && n >= 0) + setSettings((p) => ({ ...p, points_zipette_per_threshold: n })); + }} + /> + pts + + + + ({ penalties_enabled: true, + show_amende_score: true, points_enabled: true, + points_separated: true, }); const [penaltyModal, setPenaltyModal] = useState<{ visible: boolean; @@ -145,22 +147,31 @@ export default function UsersScreen() { {appSettings.points_enabled && ( - <> + appSettings.points_separated ? ( + <> + + + {item.point} + + Points + + + + {item.points_zipette} + + Zipette + + + ) : ( {item.point} Points - - - {item.points_zipette} - - Zipette - - + ) )} - {appSettings.penalties_enabled && ( + {appSettings.show_amende_score && ( {item.amende} diff --git a/mobile/src/api/api.ts b/mobile/src/api/api.ts index 026c5a94..2c120ab9 100644 --- a/mobile/src/api/api.ts +++ b/mobile/src/api/api.ts @@ -710,7 +710,9 @@ export const markNotificationsRead = async (): Promise<{ export interface PublicSettings { penalties_enabled: boolean; + show_amende_score: boolean; points_enabled: boolean; + points_separated: boolean; } export const getPublicSettings = async (): Promise => { @@ -718,10 +720,12 @@ export const getPublicSettings = async (): Promise => { const { data } = await apiClient.get(`${V1}/app-settings`); return { penalties_enabled: data.penalties_enabled ?? true, + show_amende_score: data.show_amende_score ?? true, points_enabled: data.points_enabled ?? true, + points_separated: data.points_separated ?? true, }; } catch { - return { penalties_enabled: true, points_enabled: true }; + return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true }; } }; diff --git a/mobile/src/screens/client/OrderHistoryScreen.tsx b/mobile/src/screens/client/OrderHistoryScreen.tsx index b67e21ef..8931419d 100644 --- a/mobile/src/screens/client/OrderHistoryScreen.tsx +++ b/mobile/src/screens/client/OrderHistoryScreen.tsx @@ -44,7 +44,7 @@ export default function OrderHistoryScreen() { const [orders, setOrders] = useState([]); const [stats, setStats] = useState(null); const [penalties, setPenalties] = useState(null); - const [appSettings, setAppSettings] = useState({ penalties_enabled: true, points_enabled: true }); + const [appSettings, setAppSettings] = useState({ penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true }); const [loading, setLoading] = useState(true); const [refreshing, setRefreshing] = useState(false); @@ -245,33 +245,49 @@ export default function OrderHistoryScreen() { Commandes {appSettings.points_enabled && ( - <> - - - - {stats?.points || 0} - - - Pts Weed/Hash - - - - - - {stats?.points_zipette || 0} - - - Pts Zipette - - + appSettings.points_separated ? ( + <> + + + + {stats?.points || 0} + + + Pts Weed/Hash + + + + + + {stats?.points_zipette || 0} + + + Pts Zipette + + + + + + {totalPoints} + + + Total Points + + + + ) : ( - {totalPoints} + {stats?.points || 0} - Total Points + Points - + ) )} - {appSettings.penalties_enabled && penaltyCount > 0 && ( + {appSettings.show_amende_score && penaltyCount > 0 && (