chore: build
This commit is contained in:
@@ -276,14 +276,18 @@ export const confirmReceptionAdmin = async (commandId: number) => {
|
||||
// ============================================
|
||||
|
||||
export const getAvailableDeliveryPersons = async () => {
|
||||
const { data } = await apiClient.get(
|
||||
`${V2}/admin/protected/delivery-persons`,
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
livreurs: data.livreurs || [],
|
||||
count: data.count || 0,
|
||||
};
|
||||
try {
|
||||
const { data } = await apiClient.get(
|
||||
`${V2}/admin/protected/delivery-persons`,
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
livreurs: data.livreurs || [],
|
||||
count: data.count || 0,
|
||||
};
|
||||
} catch {
|
||||
return { success: false, livreurs: [], count: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
export const assignDeliveryPerson = async (
|
||||
|
||||
@@ -1069,41 +1069,54 @@ export default function SettingsScreen() {
|
||||
const loadData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
isLoaded.current = false;
|
||||
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
||||
getSettings(),
|
||||
getCategories(),
|
||||
getAvailableDeliveryPersons(),
|
||||
getAllProductsAdmin(),
|
||||
]);
|
||||
if (settingsRes.success && settingsRes.settings) {
|
||||
setSettings({
|
||||
...settingsRes.settings,
|
||||
points_pools: settingsRes.settings.points_pools ?? [],
|
||||
delivery_schedule: settingsRes.settings.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
|
||||
postal_zones: settingsRes.settings.postal_zones ?? DEFAULT_POSTAL_ZONES,
|
||||
delivery_mode: settingsRes.settings.delivery_mode ?? { mode: "single", category_routes: [] },
|
||||
points_reward: settingsRes.settings.points_reward ?? null,
|
||||
});
|
||||
}
|
||||
if (categoriesRes) {
|
||||
setCategories(categoriesRes.filter((c) => !c.is_coming_soon));
|
||||
}
|
||||
if (livreursRes.success) {
|
||||
setLivreurs(livreursRes.livreurs.map((l: any) => l.username));
|
||||
}
|
||||
if (productsRes.success) {
|
||||
const byCategory: Record<string, Product[]> = {};
|
||||
for (const p of productsRes.data) {
|
||||
const cat = p.category || "";
|
||||
if (!byCategory[cat]) byCategory[cat] = [];
|
||||
byCategory[cat].push(p);
|
||||
try {
|
||||
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
||||
getSettings(),
|
||||
getCategories(),
|
||||
getAvailableDeliveryPersons(),
|
||||
getAllProductsAdmin(),
|
||||
]);
|
||||
if (settingsRes.success && settingsRes.settings) {
|
||||
const s = settingsRes.settings;
|
||||
setSettings({
|
||||
...s,
|
||||
penalty_tiers: s.penalty_tiers ?? [],
|
||||
points_pools: (s.points_pools ?? []).map((p: any) => ({
|
||||
...p,
|
||||
categories: p.categories ?? [],
|
||||
tiers: p.tiers ?? [],
|
||||
})),
|
||||
nowpayments_currencies: s.nowpayments_currencies ?? [],
|
||||
delivery_schedule: s.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
|
||||
postal_zones: s.postal_zones ?? DEFAULT_POSTAL_ZONES,
|
||||
delivery_mode: {
|
||||
...(s.delivery_mode ?? { mode: "single" }),
|
||||
category_routes: s.delivery_mode?.category_routes ?? [],
|
||||
},
|
||||
points_reward: s.points_reward ?? null,
|
||||
});
|
||||
}
|
||||
setProductsByCategory(byCategory);
|
||||
if (categoriesRes) {
|
||||
setCategories(categoriesRes.filter((c) => !c.is_coming_soon));
|
||||
}
|
||||
if (livreursRes.success) {
|
||||
setLivreurs(livreursRes.livreurs.map((l: any) => l.username));
|
||||
}
|
||||
if (productsRes.success) {
|
||||
const byCategory: Record<string, Product[]> = {};
|
||||
for (const p of productsRes.data) {
|
||||
const cat = p.category || "";
|
||||
if (!byCategory[cat]) byCategory[cat] = [];
|
||||
byCategory[cat].push(p);
|
||||
}
|
||||
setProductsByCategory(byCategory);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[SettingsScreen] loadData error:", e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setTimeout(() => { isLoaded.current = true; isDirty.current = false; }, 0);
|
||||
}
|
||||
setLoading(false);
|
||||
// Marquer comme chargé après un tick pour que le useEffect de settings ne
|
||||
// considère pas le setSettings initial comme une modification utilisateur
|
||||
setTimeout(() => { isLoaded.current = true; isDirty.current = false; }, 0);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1391,7 +1404,7 @@ export default function SettingsScreen() {
|
||||
<Text style={[s.rowDesc, { width: inputMd, textAlign: "center" }]}>Montant</Text>
|
||||
<View style={{ width: 28 }} />
|
||||
</View>
|
||||
{settings.penalty_tiers.map((tier, i) => (
|
||||
{(settings.penalty_tiers ?? []).map((tier, i) => (
|
||||
<View key={i} style={{ flexDirection: "row", alignItems: "center", width: "100%", gap: spacing.s }}>
|
||||
<TextInput
|
||||
style={[s.thresholdInput, { flex: 1, textAlign: "center" }]}
|
||||
|
||||
Reference in New Issue
Block a user