chore: fix
This commit is contained in:
@@ -730,9 +730,11 @@ export interface PublicSettings {
|
||||
points_enabled: boolean;
|
||||
points_separated: boolean;
|
||||
referral_enabled: boolean;
|
||||
pool_names: string[];
|
||||
}
|
||||
|
||||
export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
const defaults: PublicSettings = { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true, pool_names: ['Pool 1', 'Pool 2'] };
|
||||
try {
|
||||
const { data } = await apiClient.get(`${V1}/app-settings`);
|
||||
return {
|
||||
@@ -741,9 +743,12 @@ export const getPublicSettings = async (): Promise<PublicSettings> => {
|
||||
points_enabled: data.points_enabled ?? true,
|
||||
points_separated: data.points_separated ?? true,
|
||||
referral_enabled: data.referral_enabled ?? true,
|
||||
pool_names: Array.isArray(data.pool_names) && data.pool_names.length > 0
|
||||
? data.pool_names
|
||||
: defaults.pool_names,
|
||||
};
|
||||
} catch {
|
||||
return { penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: true };
|
||||
return defaults;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -585,7 +585,8 @@ export interface ClientStats {
|
||||
telephone?: string;
|
||||
total_commands: number;
|
||||
points: number;
|
||||
points_zipette: number; // ✅ AJOUTER CETTE LIGNE
|
||||
pool_points: number[];
|
||||
pool_names: string[];
|
||||
penalties: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function OrderHistoryScreen() {
|
||||
const [orders, setOrders] = useState<CompletedOrder[]>([]);
|
||||
const [stats, setStats] = useState<ClientStats | null>(null);
|
||||
const [penalties, setPenalties] = useState<PenaltyInfo | null>(null);
|
||||
const [appSettings, setAppSettings] = useState<PublicSettings>({ penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: false });
|
||||
const [appSettings, setAppSettings] = useState<PublicSettings>({ penalties_enabled: true, show_amende_score: true, points_enabled: true, points_separated: true, referral_enabled: false, pool_names: ['Pool 1', 'Pool 2'] });
|
||||
const [referralBalance, setReferralBalance] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
@@ -216,7 +216,9 @@ export default function OrderHistoryScreen() {
|
||||
if (loading && !refreshing)
|
||||
return <LoadingSpinner message="Chargement historique..." />;
|
||||
|
||||
const totalPoints = (stats?.points || 0) + (stats?.points_zipette || 0);
|
||||
const poolNames = stats?.pool_names?.length ? stats.pool_names : appSettings.pool_names;
|
||||
const poolPoints = stats?.pool_points ?? [stats?.points ?? 0];
|
||||
const totalPoints = poolPoints.reduce((s, v) => s + (v || 0), 0);
|
||||
const penaltyCount = penalties?.total_penalty || stats?.penalties || 0;
|
||||
|
||||
return (
|
||||
@@ -247,64 +249,33 @@ export default function OrderHistoryScreen() {
|
||||
<Text style={styles.statLabel}>Commandes</Text>
|
||||
</View>
|
||||
{appSettings.points_enabled && (
|
||||
appSettings.points_separated ? (
|
||||
poolNames.length <= 1 ? (
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons name="trophy-outline" size={24} color={colors.warning} />
|
||||
<Text style={styles.statValue}>{poolPoints[0] || 0}</Text>
|
||||
<Text style={styles.statLabel}>Pts {poolNames[0] ?? 'Points'}</Text>
|
||||
</View>
|
||||
) : (
|
||||
<>
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons
|
||||
name="leaf-outline"
|
||||
size={24}
|
||||
color={colors.categoryWeedHash}
|
||||
/>
|
||||
<Text style={styles.statValue}>
|
||||
{stats?.points || 0}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>
|
||||
Pts Weed/Hash
|
||||
</Text>
|
||||
</View>
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons
|
||||
name="flash-outline"
|
||||
size={24}
|
||||
color={colors.info}
|
||||
/>
|
||||
<Text style={styles.statValue}>
|
||||
{stats?.points_zipette || 0}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>
|
||||
Pts Zipette
|
||||
</Text>
|
||||
</View>
|
||||
{(stats?.points || 0) > 0 && (stats?.points_zipette || 0) > 0 && (
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
{poolNames.map((name, i) => (
|
||||
<View key={i} style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons
|
||||
name="trophy-outline"
|
||||
name={i === 0 ? "leaf-outline" : i === 1 ? "flash-outline" : "star-outline"}
|
||||
size={24}
|
||||
color={colors.warning}
|
||||
color={i === 0 ? colors.categoryWeedHash : i === 1 ? colors.info : colors.accent}
|
||||
/>
|
||||
<Text style={styles.statValue}>
|
||||
{totalPoints}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>
|
||||
Total Points
|
||||
</Text>
|
||||
<Text style={styles.statValue}>{poolPoints[i] || 0}</Text>
|
||||
<Text style={styles.statLabel}>Pts {name}</Text>
|
||||
</View>
|
||||
))}
|
||||
{totalPoints > 0 && (
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons name="trophy-outline" size={24} color={colors.warning} />
|
||||
<Text style={styles.statValue}>{totalPoints}</Text>
|
||||
<Text style={styles.statLabel}>Total Points</Text>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<View style={[styles.statCard, shadows.sm]}>
|
||||
<Ionicons
|
||||
name="trophy-outline"
|
||||
size={24}
|
||||
color={colors.warning}
|
||||
/>
|
||||
<Text style={styles.statValue}>
|
||||
{stats?.points || 0}
|
||||
</Text>
|
||||
<Text style={styles.statLabel}>
|
||||
Points
|
||||
</Text>
|
||||
</View>
|
||||
)
|
||||
)}
|
||||
{appSettings.show_amende_score && (
|
||||
|
||||
@@ -537,8 +537,9 @@ export default function OrderTrackingScreen() {
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{(order.status === "en_route" ||
|
||||
order.status === "arrived") && (
|
||||
{order.status === "en_route" &&
|
||||
eta?.eta_minutes != null &&
|
||||
eta.eta_minutes > 0 && (
|
||||
<View style={styles.trackRow}>
|
||||
<Ionicons
|
||||
name="timer-outline"
|
||||
@@ -546,8 +547,19 @@ export default function OrderTrackingScreen() {
|
||||
color={colors.warning}
|
||||
/>
|
||||
<Text style={styles.trackText}>
|
||||
Temps de livraison estimé :
|
||||
~
|
||||
Temps de livraison estimé : ~{eta.eta_minutes} min
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
{order.status === "arrived" && (
|
||||
<View style={styles.trackRow}>
|
||||
<Ionicons
|
||||
name="timer-outline"
|
||||
size={16}
|
||||
color={colors.warning}
|
||||
/>
|
||||
<Text style={styles.trackText}>
|
||||
Temps de livraison estimé : ~
|
||||
{eta?.eta_minutes != null &&
|
||||
eta.eta_minutes > 0 &&
|
||||
eta.eta_minutes < 5
|
||||
|
||||
Reference in New Issue
Block a user