chore: build
This commit is contained in:
@@ -276,14 +276,18 @@ export const confirmReceptionAdmin = async (commandId: number) => {
|
|||||||
// ============================================
|
// ============================================
|
||||||
|
|
||||||
export const getAvailableDeliveryPersons = async () => {
|
export const getAvailableDeliveryPersons = async () => {
|
||||||
const { data } = await apiClient.get(
|
try {
|
||||||
`${V2}/admin/protected/delivery-persons`,
|
const { data } = await apiClient.get(
|
||||||
);
|
`${V2}/admin/protected/delivery-persons`,
|
||||||
return {
|
);
|
||||||
success: true,
|
return {
|
||||||
livreurs: data.livreurs || [],
|
success: true,
|
||||||
count: data.count || 0,
|
livreurs: data.livreurs || [],
|
||||||
};
|
count: data.count || 0,
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return { success: false, livreurs: [], count: 0 };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const assignDeliveryPerson = async (
|
export const assignDeliveryPerson = async (
|
||||||
|
|||||||
@@ -1069,41 +1069,54 @@ export default function SettingsScreen() {
|
|||||||
const loadData = useCallback(async () => {
|
const loadData = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
isLoaded.current = false;
|
isLoaded.current = false;
|
||||||
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
try {
|
||||||
getSettings(),
|
const [settingsRes, categoriesRes, livreursRes, productsRes] = await Promise.all([
|
||||||
getCategories(),
|
getSettings(),
|
||||||
getAvailableDeliveryPersons(),
|
getCategories(),
|
||||||
getAllProductsAdmin(),
|
getAvailableDeliveryPersons(),
|
||||||
]);
|
getAllProductsAdmin(),
|
||||||
if (settingsRes.success && settingsRes.settings) {
|
]);
|
||||||
setSettings({
|
if (settingsRes.success && settingsRes.settings) {
|
||||||
...settingsRes.settings,
|
const s = settingsRes.settings;
|
||||||
points_pools: settingsRes.settings.points_pools ?? [],
|
setSettings({
|
||||||
delivery_schedule: settingsRes.settings.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
|
...s,
|
||||||
postal_zones: settingsRes.settings.postal_zones ?? DEFAULT_POSTAL_ZONES,
|
penalty_tiers: s.penalty_tiers ?? [],
|
||||||
delivery_mode: settingsRes.settings.delivery_mode ?? { mode: "single", category_routes: [] },
|
points_pools: (s.points_pools ?? []).map((p: any) => ({
|
||||||
points_reward: settingsRes.settings.points_reward ?? null,
|
...p,
|
||||||
});
|
categories: p.categories ?? [],
|
||||||
}
|
tiers: p.tiers ?? [],
|
||||||
if (categoriesRes) {
|
})),
|
||||||
setCategories(categoriesRes.filter((c) => !c.is_coming_soon));
|
nowpayments_currencies: s.nowpayments_currencies ?? [],
|
||||||
}
|
delivery_schedule: s.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
|
||||||
if (livreursRes.success) {
|
postal_zones: s.postal_zones ?? DEFAULT_POSTAL_ZONES,
|
||||||
setLivreurs(livreursRes.livreurs.map((l: any) => l.username));
|
delivery_mode: {
|
||||||
}
|
...(s.delivery_mode ?? { mode: "single" }),
|
||||||
if (productsRes.success) {
|
category_routes: s.delivery_mode?.category_routes ?? [],
|
||||||
const byCategory: Record<string, Product[]> = {};
|
},
|
||||||
for (const p of productsRes.data) {
|
points_reward: s.points_reward ?? null,
|
||||||
const cat = p.category || "";
|
});
|
||||||
if (!byCategory[cat]) byCategory[cat] = [];
|
|
||||||
byCategory[cat].push(p);
|
|
||||||
}
|
}
|
||||||
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(() => {
|
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