Checkpoint: Rétablissement des modes Quotidienne, Hebdomadaire (choix du jour), Mensuelle (choix du jour du mois) et Intervalle dans la section Planification des Paramètres. Ajout de fetch_day_of_week et fetch_day_of_month dans le schéma Zod du backend.

This commit is contained in:
Manus
2026-07-05 06:51:43 -04:00
parent b0550f3298
commit f0be15d432
3 changed files with 68 additions and 27 deletions

View File

@@ -1,4 +1,4 @@
{
"version": "413ddf45",
"timestamp": 1783072421404
"version": "af33c6e1",
"timestamp": 1783248703843
}

View File

@@ -222,6 +222,8 @@ export default function SettingsPage() {
import_time: "06:00",
fetch_mode: "scheduled",
fetch_interval_minutes: "1440",
fetch_day_of_week: "1",
fetch_day_of_month: "1",
});
useEffect(() => {
@@ -467,55 +469,95 @@ export default function SettingsPage() {
<CardContent className="space-y-5">
{/* Mode */}
<div className="space-y-2">
<Label className="text-sm font-medium">Mode de planification</Label>
<div className="grid grid-cols-2 gap-3 max-w-md">
{(["scheduled", "interval"] as const).map((mode) => (
<Label className="text-sm font-medium">Fréquence de mise à jour</Label>
<div className="grid grid-cols-2 gap-3 max-w-xl">
{([
{ value: "scheduled", label: "Quotidienne", desc: "Chaque jour à une heure précise" },
{ value: "weekly", label: "Hebdomadaire", desc: "Un jour précis de la semaine" },
{ value: "monthly", label: "Mensuelle", desc: "Un jour précis du mois" },
{ value: "interval", label: "Intervalle", desc: "Toutes les N heures" },
] as const).map((mode) => (
<button
key={mode}
key={mode.value}
type="button"
onClick={() => set("fetch_mode", mode)}
onClick={() => set("fetch_mode", mode.value)}
className={cn(
"flex items-center gap-2 p-3 rounded-lg border-2 text-left transition-all text-sm",
(form.fetch_mode || "scheduled") === mode
(form.fetch_mode || "scheduled") === mode.value
? "border-primary bg-primary/5"
: "border-border hover:border-primary/40"
)}
>
<Clock className={cn("h-4 w-4", (form.fetch_mode || "scheduled") === mode ? "text-primary" : "text-muted-foreground")} />
<Clock className={cn("h-4 w-4", (form.fetch_mode || "scheduled") === mode.value ? "text-primary" : "text-muted-foreground")} />
<div>
<p className="font-medium">{mode === "scheduled" ? "Heure fixe" : "Intervalle"}</p>
<p className="text-xs text-muted-foreground">{mode === "scheduled" ? "Chaque jour à une heure précise" : "Toutes les N heures"}</p>
<p className="font-medium">{mode.label}</p>
<p className="text-xs text-muted-foreground">{mode.desc}</p>
</div>
</button>
))}
</div>
</div>
{/* Heure fixe */}
{(form.fetch_mode || "scheduled") === "scheduled" && (
{/* Heure (quotidien, hebdo, mensuel) */}
{["scheduled", "weekly", "monthly"].includes(form.fetch_mode || "scheduled") && (
<div className="space-y-2 max-w-xs">
<Label>Heure d'import quotidien</Label>
<Label>Heure de déclenchement</Label>
<Input
type="time"
value={form.import_time || "06:00"}
onChange={(e) => set("import_time", e.target.value)}
/>
<p className="text-xs text-muted-foreground">
Prochain import : demain à {form.import_time || "06:00"}
</p>
</div>
)}
{/* Jour de la semaine (hebdo) */}
{(form.fetch_mode || "scheduled") === "weekly" && (
<div className="space-y-2 max-w-xs">
<Label>Jour de la semaine</Label>
<div className="grid grid-cols-7 gap-1">
{["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"].map((day, i) => (
<button
key={i}
type="button"
onClick={() => set("fetch_day_of_week", String(i))}
className={cn(
"py-1.5 rounded-md border-2 text-xs font-medium transition-all",
(form.fetch_day_of_week || "1") === String(i)
? "border-primary bg-primary/5 text-primary"
: "border-border hover:border-primary/40 text-foreground"
)}
>
{day}
</button>
))}
</div>
</div>
)}
{/* Jour du mois (mensuel) */}
{(form.fetch_mode || "scheduled") === "monthly" && (
<div className="space-y-2 max-w-xs">
<Label>Jour du mois (128)</Label>
<Input
type="number"
min={1}
max={28}
value={form.fetch_day_of_month || "1"}
onChange={(e) => set("fetch_day_of_month", e.target.value)}
/>
</div>
)}
{/* Intervalle */}
{(form.fetch_mode || "scheduled") === "interval" && (
<div className="space-y-2 max-w-xs">
<Label>Fréquence de mise à jour</Label>
<Label>Intervalle de mise à jour</Label>
<div className="grid grid-cols-3 gap-2">
{[
{ label: "1h", value: "60" },
{ label: "2h", value: "120" },
{ label: "4h", value: "240" },
{ label: "6h", value: "360" },
{ label: "1h", value: "60" },
{ label: "2h", value: "120" },
{ label: "4h", value: "240" },
{ label: "6h", value: "360" },
{ label: "12h", value: "720" },
{ label: "24h", value: "1440" },
].map((opt) => (
@@ -534,9 +576,6 @@ export default function SettingsPage() {
</button>
))}
</div>
<p className="text-xs text-muted-foreground">
Import toutes les {(form.fetch_interval_minutes || "1440") === "60" ? "heure" : `${parseInt(form.fetch_interval_minutes || "1440") / 60} heures`}
</p>
</div>
)}
</CardContent>

View File

@@ -372,8 +372,10 @@ export const appRouter = router({
sharepoint_token: z.string().optional(),
auth_mode: z.enum(["local", "free"]).optional(),
import_time: z.string().optional(),
fetch_mode: z.enum(["scheduled", "interval"]).optional(),
fetch_mode: z.enum(["scheduled", "weekly", "monthly", "interval"]).optional(),
fetch_interval_minutes: z.string().optional(),
fetch_day_of_week: z.string().optional(),
fetch_day_of_month: z.string().optional(),
})
)
.mutation(async ({ input }) => {
@@ -383,7 +385,7 @@ export const appRouter = router({
}
await setSettings(toSave);
// Recharger le cron si la planification a changé
if (toSave.import_time || toSave.fetch_mode || toSave.fetch_interval_minutes) {
if (toSave.import_time || toSave.fetch_mode || toSave.fetch_interval_minutes || toSave.fetch_day_of_week || toSave.fetch_day_of_month) {
await scheduleDailyImport();
}
return { success: true };