chore: build
This commit is contained in:
@@ -276,6 +276,7 @@ export const confirmReceptionAdmin = async (commandId: number) => {
|
|||||||
// ============================================
|
// ============================================
|
||||||
|
|
||||||
export const getAvailableDeliveryPersons = async () => {
|
export const getAvailableDeliveryPersons = async () => {
|
||||||
|
try {
|
||||||
const { data } = await apiClient.get(
|
const { data } = await apiClient.get(
|
||||||
`${V2}/admin/protected/delivery-persons`,
|
`${V2}/admin/protected/delivery-persons`,
|
||||||
);
|
);
|
||||||
@@ -284,6 +285,9 @@ export const getAvailableDeliveryPersons = async () => {
|
|||||||
livreurs: data.livreurs || [],
|
livreurs: data.livreurs || [],
|
||||||
count: data.count || 0,
|
count: data.count || 0,
|
||||||
};
|
};
|
||||||
|
} catch {
|
||||||
|
return { success: false, livreurs: [], count: 0 };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const assignDeliveryPerson = async (
|
export const assignDeliveryPerson = async (
|
||||||
|
|||||||
@@ -1069,6 +1069,7 @@ export default function SettingsScreen() {
|
|||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
isLoaded.current = false;
|
isLoaded.current = false;
|
||||||
|
try {
|
||||||
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
||||||
getSettings(),
|
getSettings(),
|
||||||
getCategories(),
|
getCategories(),
|
||||||
@@ -1076,13 +1077,23 @@ export default function SettingsScreen() {
|
|||||||
getAllProductsAdmin(),
|
getAllProductsAdmin(),
|
||||||
]);
|
]);
|
||||||
if (settingsRes.success && settingsRes.settings) {
|
if (settingsRes.success && settingsRes.settings) {
|
||||||
|
const s = settingsRes.settings;
|
||||||
setSettings({
|
setSettings({
|
||||||
...settingsRes.settings,
|
...s,
|
||||||
points_pools: settingsRes.settings.points_pools ?? [],
|
penalty_tiers: s.penalty_tiers ?? [],
|
||||||
delivery_schedule: settingsRes.settings.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
|
points_pools: (s.points_pools ?? []).map((p: any) => ({
|
||||||
postal_zones: settingsRes.settings.postal_zones ?? DEFAULT_POSTAL_ZONES,
|
...p,
|
||||||
delivery_mode: settingsRes.settings.delivery_mode ?? { mode: "single", category_routes: [] },
|
categories: p.categories ?? [],
|
||||||
points_reward: settingsRes.settings.points_reward ?? null,
|
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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (categoriesRes) {
|
if (categoriesRes) {
|
||||||
@@ -1100,10 +1111,12 @@ export default function SettingsScreen() {
|
|||||||
}
|
}
|
||||||
setProductsByCategory(byCategory);
|
setProductsByCategory(byCategory);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("[SettingsScreen] loadData error:", e);
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
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);
|
setTimeout(() => { isLoaded.current = true; isDirty.current = false; }, 0);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -1391,7 +1404,7 @@ export default function SettingsScreen() {
|
|||||||
<Text style={[s.rowDesc, { width: inputMd, textAlign: "center" }]}>Montant</Text>
|
<Text style={[s.rowDesc, { width: inputMd, textAlign: "center" }]}>Montant</Text>
|
||||||
<View style={{ width: 28 }} />
|
<View style={{ width: 28 }} />
|
||||||
</View>
|
</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 }}>
|
<View key={i} style={{ flexDirection: "row", alignItems: "center", width: "100%", gap: spacing.s }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[s.thresholdInput, { flex: 1, textAlign: "center" }]}
|
style={[s.thresholdInput, { flex: 1, textAlign: "center" }]}
|
||||||
|
|||||||
Reference in New Issue
Block a user