chore: build
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useState, useEffect, useCallback, useRef } from "react";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
@@ -1290,9 +1291,13 @@ export default function SettingsScreen() {
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
}, [loadData]);
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
if (!isDirty.current) {
|
||||
loadData();
|
||||
}
|
||||
}, [loadData])
|
||||
);
|
||||
|
||||
// Retourne l'index du pool auquel la catégorie est assignée, ou -1 si aucun
|
||||
const getPoolIndexFor = (catName: string): number => {
|
||||
@@ -1366,6 +1371,7 @@ export default function SettingsScreen() {
|
||||
setSaving(false);
|
||||
if (res.success) {
|
||||
isDirty.current = false;
|
||||
await loadData();
|
||||
await refreshColors();
|
||||
showSuccess("Succès", "Paramètres sauvegardés");
|
||||
} else {
|
||||
|
||||
+18
-9
@@ -420,10 +420,6 @@ export const respondToAddressProposal = async (
|
||||
}
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// TRACKING
|
||||
// ============================================
|
||||
|
||||
export const getOrderTracking = async (
|
||||
commandId: number,
|
||||
): Promise<TrackingResponse> => {
|
||||
@@ -984,7 +980,10 @@ export const getMyPointsRewards = async (): Promise<{
|
||||
}
|
||||
};
|
||||
|
||||
export const claimMyReward = async (poolKey: string, productId?: number): Promise<{
|
||||
export const claimMyReward = async (
|
||||
poolKey: string,
|
||||
productId?: number,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
description?: string;
|
||||
remaining_rewards?: number;
|
||||
@@ -993,7 +992,9 @@ export const claimMyReward = async (poolKey: string, productId?: number): Promis
|
||||
error?: string;
|
||||
}> => {
|
||||
try {
|
||||
const body: { pool_key: string; product_id?: number } = { pool_key: poolKey };
|
||||
const body: { pool_key: string; product_id?: number } = {
|
||||
pool_key: poolKey,
|
||||
};
|
||||
if (productId !== undefined) body.product_id = productId;
|
||||
const { data } = await apiClient.post(`${V1}/points/claim`, body);
|
||||
return {
|
||||
@@ -1014,7 +1015,10 @@ export const submitLivreurRating = async (
|
||||
comment: string,
|
||||
): Promise<{ success: boolean; error?: string }> => {
|
||||
try {
|
||||
await apiClient.post(`${V1}/orders/${orderId}/rate`, { rating, comment });
|
||||
await apiClient.post(`${V1}/orders/${orderId}/rate`, {
|
||||
rating,
|
||||
comment,
|
||||
});
|
||||
return { success: true };
|
||||
} catch (e: any) {
|
||||
return { success: false, error: e?.response?.data?.error || "Erreur" };
|
||||
@@ -1033,11 +1037,16 @@ export const getOrderRatingStatus = async (
|
||||
};
|
||||
|
||||
export const calculateOrderTotal = (order: any): number => {
|
||||
if (typeof order.total_prix === "number" && order.total_prix > 0) return order.total_prix;
|
||||
if (typeof order.total_prix === "number" && order.total_prix > 0)
|
||||
return order.total_prix;
|
||||
if (typeof order.total === "number" && order.total > 0) return order.total;
|
||||
if (Array.isArray(order.items) && order.items.length > 0) {
|
||||
return order.items.reduce((sum: number, item: any) => {
|
||||
return sum + (item.prix || item.price || 0) * (item.quantite || item.quantity || 1);
|
||||
return (
|
||||
sum +
|
||||
(item.prix || item.price || 0) *
|
||||
(item.quantite || item.quantity || 1)
|
||||
);
|
||||
}, 0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -24,12 +24,13 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
|
||||
const fetchClientColors = useCallback(async () => {
|
||||
try {
|
||||
const s = await getPublicSettings();
|
||||
const overrides: Partial<Colors> = {};
|
||||
if (s.client_color_primary) overrides.accent = s.client_color_primary;
|
||||
if (s.client_color_secondary) overrides.secondary = s.client_color_secondary;
|
||||
if (s.client_color_success) overrides.success = s.client_color_success;
|
||||
if (s.client_color_danger) overrides.danger = s.client_color_danger;
|
||||
if (s.client_color_warning) overrides.warning = s.client_color_warning;
|
||||
const overrides: Partial<Colors> = {
|
||||
...(s.client_color_primary && { accent: s.client_color_primary }),
|
||||
...(s.client_color_secondary && { secondary: s.client_color_secondary }),
|
||||
...(s.client_color_success && { success: s.client_color_success }),
|
||||
...(s.client_color_danger && { danger: s.client_color_danger }),
|
||||
...(s.client_color_warning && { warning: s.client_color_warning }),
|
||||
};
|
||||
setColorOverrides(overrides);
|
||||
AsyncStorage.setItem(COLORS_CACHE_KEY, JSON.stringify(overrides)).catch(() => {});
|
||||
} catch {}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Pressable,
|
||||
Switch,
|
||||
Alert,
|
||||
Modal,
|
||||
|
||||
Reference in New Issue
Block a user