diff --git a/frontend-admin/src/api/api_admin.ts b/frontend-admin/src/api/api_admin.ts
index 322c8a0f..6f2882de 100644
--- a/frontend-admin/src/api/api_admin.ts
+++ b/frontend-admin/src/api/api_admin.ts
@@ -704,6 +704,30 @@ export interface PointsTier {
points: number;
}
+export interface DaySchedule {
+ enabled: boolean;
+ open_time: string; // "09:00"
+ close_time: string; // "20:00"
+}
+
+export interface DeliverySchedule {
+ monday: DaySchedule;
+ tuesday: DaySchedule;
+ wednesday: DaySchedule;
+ thursday: DaySchedule;
+ friday: DaySchedule;
+ saturday: DaySchedule;
+ sunday: DaySchedule;
+}
+
+export const DEFAULT_DAY: DaySchedule = { enabled: true, open_time: "09:00", close_time: "20:00" };
+
+export const DEFAULT_DELIVERY_SCHEDULE: DeliverySchedule = {
+ monday: { ...DEFAULT_DAY }, tuesday: { ...DEFAULT_DAY }, wednesday: { ...DEFAULT_DAY },
+ thursday: { ...DEFAULT_DAY }, friday: { ...DEFAULT_DAY },
+ saturday: { ...DEFAULT_DAY }, sunday: { ...DEFAULT_DAY },
+};
+
export interface AppSettings {
penalties_enabled: boolean;
show_amende_score: boolean;
@@ -716,6 +740,7 @@ export interface AppSettings {
points_zipette_tiers: PointsTier[];
points_total_tiers: PointsTier[];
referral_enabled: boolean;
+ delivery_schedule: DeliverySchedule;
}
export const getSettings = async (): Promise<{
diff --git a/frontend-admin/src/screens/admin/ProductsScreen.tsx b/frontend-admin/src/screens/admin/ProductsScreen.tsx
index 6bfb79a9..56a26eef 100644
--- a/frontend-admin/src/screens/admin/ProductsScreen.tsx
+++ b/frontend-admin/src/screens/admin/ProductsScreen.tsx
@@ -33,8 +33,6 @@ import type { Product } from "../../api/types";
import LoadingSpinner from "../../components/ui/LoadingSpinner";
import Card from "../../components/ui/Card";
import Badge from "../../components/ui/Badge";
-import { getCategoryColor } from "../../utils/constants";
-
import AlertModal from "../../components/ui/AlertModal";
import { useAlert } from "../../hooks/useAlert";
@@ -759,7 +757,7 @@ export default function ProductsScreen() {
{item.name}
c.name === item.category)?.color || getCategoryColor(item.category, colors)}
+ color={categories.find(c => c.name === item.category)?.color || colors.accent}
/>
diff --git a/frontend-admin/src/screens/admin/SettingsScreen.tsx b/frontend-admin/src/screens/admin/SettingsScreen.tsx
index 11fd3ca5..bc022a6f 100644
--- a/frontend-admin/src/screens/admin/SettingsScreen.tsx
+++ b/frontend-admin/src/screens/admin/SettingsScreen.tsx
@@ -12,13 +12,113 @@ import {
import { Ionicons } from "@expo/vector-icons";
import { spacing, fontSize, borderRadius } from "../../theme";
import { useTheme } from "../../context/ThemeContext";
-import { getSettings, updateSettings, getCategories } from "../../api/api_admin";
-import type { AppSettings, Category, PointsTier } from "../../api/api_admin";
+import { getSettings, updateSettings, getCategories, DEFAULT_DELIVERY_SCHEDULE } from "../../api/api_admin";
+import type { AppSettings, Category, PointsTier, DaySchedule, DeliverySchedule } from "../../api/api_admin";
import AlertModal from "../../components/ui/AlertModal";
import { useAlert } from "../../hooks/useAlert";
type PoolAssignment = "weed" | "zipette" | "total" | "none";
+const DAYS: { key: keyof DeliverySchedule; label: string }[] = [
+ { key: "monday", label: "Lundi" },
+ { key: "tuesday", label: "Mardi" },
+ { key: "wednesday", label: "Mercredi" },
+ { key: "thursday", label: "Jeudi" },
+ { key: "friday", label: "Vendredi" },
+ { key: "saturday", label: "Samedi" },
+ { key: "sunday", label: "Dimanche" },
+];
+
+function DeliveryScheduleSection({
+ schedule,
+ onChange,
+ colors,
+ s,
+}: {
+ schedule: DeliverySchedule;
+ onChange: (sched: DeliverySchedule) => void;
+ colors: any;
+ s: any;
+}) {
+ const updateDay = (key: keyof DeliverySchedule, patch: Partial) => {
+ onChange({ ...schedule, [key]: { ...schedule[key], ...patch } });
+ };
+
+ return (
+
+ Horaires de livraison
+
+ Définissez les jours et horaires d'ouverture pour la livraison.
+
+ {DAYS.map(({ key, label }, index) => {
+ const day = schedule[key];
+ return (
+
+ {/* Ligne : jour + toggle */}
+
+
+
+ {label}
+
+ updateDay(key, { enabled: v })}
+ trackColor={{ false: colors.border, true: "#10b981" }}
+ thumbColor="#fff"
+ />
+
+ {/* Horaires */}
+ {day.enabled && (
+
+ Ouverture
+ updateDay(key, { open_time: v })}
+ placeholder="09:00"
+ placeholderTextColor={colors.textMuted}
+ keyboardType="numbers-and-punctuation"
+ maxLength={5}
+ />
+ →
+ Fermeture
+ updateDay(key, { close_time: v })}
+ placeholder="20:00"
+ placeholderTextColor={colors.textMuted}
+ keyboardType="numbers-and-punctuation"
+ maxLength={5}
+ />
+
+ )}
+ {!day.enabled && (
+
+ Fermé ce jour
+
+ )}
+
+ );
+ })}
+
+ );
+}
+
// ──────────────────────────────────────────────────────────────
// Composant éditeur de paliers
// ──────────────────────────────────────────────────────────────
@@ -169,6 +269,7 @@ export default function SettingsScreen() {
points_zipette_tiers: [],
points_total_tiers: [],
referral_enabled: true,
+ delivery_schedule: DEFAULT_DELIVERY_SCHEDULE,
});
const [categories, setCategories] = useState([]);
@@ -185,6 +286,7 @@ export default function SettingsScreen() {
points_categories_zipette: settingsRes.settings.points_categories_zipette ?? [],
points_categories_total: settingsRes.settings.points_categories_total ?? [],
points_total_tiers: settingsRes.settings.points_total_tiers ?? [],
+ delivery_schedule: settingsRes.settings.delivery_schedule ?? DEFAULT_DELIVERY_SCHEDULE,
});
}
if (categoriesRes) {
@@ -573,6 +675,14 @@ export default function SettingsScreen() {
active={!settings.points_separated}
/>
+ {/* Horaires de livraison */}
+ setSettings((p) => ({ ...p, delivery_schedule: sched }))}
+ colors={colors}
+ s={s}
+ />
+
=> ({
offline: colors.textMuted,
});
-export const getCategoryColor = (category: string, colors: Colors): string => {
- const map: Record = {
- "weed&hash": colors.categoryWeedHash,
- tous: colors.categoryTous,
- "zipette&co": colors.categoryZipette,
- "gros&semi": colors.categoryGros,
- };
- const key = category?.toLowerCase().trim();
- return map[key] || colors.accent;
-};