mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-22 06:28:19 +02:00
Merge pull request #187 from R0m1k3/1.1
Update announcement cards to show different message types
This commit is contained in:
2 files changed
+35
-28
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 336 KiB |
@@ -4,7 +4,7 @@ import { useStore } from "@/components/Layout";
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Megaphone, Plus, X, AlertTriangle, Clock, Circle, Edit2 } from "lucide-react";
|
import { Megaphone, Plus, X, AlertTriangle, Clock, Circle, Edit2, Bell, Info, CheckCircle } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||||
@@ -20,12 +20,12 @@ import { z } from "zod";
|
|||||||
import { safeFormat, safeDate } from "@/lib/dateUtils";
|
import { safeFormat, safeDate } from "@/lib/dateUtils";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
|
|
||||||
// Schéma simplifié pour tester
|
// Schéma adapté pour DASHBOARD_MESSAGES
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
title: z.string().min(1, "Le titre est obligatoire"),
|
title: z.string().min(1, "Le titre est obligatoire"),
|
||||||
content: z.string().min(1, "Le contenu est obligatoire"),
|
content: z.string().min(1, "Le contenu est obligatoire"),
|
||||||
priority: z.enum(["normal", "important", "urgent"]).default("normal"),
|
type: z.enum(["info", "warning", "error", "success"]).default("info"),
|
||||||
groupId: z.number().optional().nullable(),
|
storeId: z.number().optional().nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function AnnouncementCard() {
|
export default function AnnouncementCard() {
|
||||||
@@ -41,8 +41,8 @@ export default function AnnouncementCard() {
|
|||||||
defaultValues: {
|
defaultValues: {
|
||||||
title: "",
|
title: "",
|
||||||
content: "",
|
content: "",
|
||||||
priority: "normal",
|
type: "info",
|
||||||
groupId: undefined,
|
storeId: undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,15 +52,15 @@ export default function AnnouncementCard() {
|
|||||||
form.reset({
|
form.reset({
|
||||||
title: editingAnnouncement.title,
|
title: editingAnnouncement.title,
|
||||||
content: editingAnnouncement.content,
|
content: editingAnnouncement.content,
|
||||||
priority: editingAnnouncement.priority as "normal" | "important" | "urgent",
|
type: editingAnnouncement.type as "info" | "warning" | "error" | "success",
|
||||||
groupId: editingAnnouncement.groupId || undefined,
|
storeId: editingAnnouncement.storeId || undefined,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
form.reset({
|
form.reset({
|
||||||
title: "",
|
title: "",
|
||||||
content: "",
|
content: "",
|
||||||
priority: "normal",
|
type: "info",
|
||||||
groupId: undefined,
|
storeId: undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [editingAnnouncement, form]);
|
}, [editingAnnouncement, form]);
|
||||||
@@ -228,26 +228,32 @@ export default function AnnouncementCard() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPriorityConfig = (priority: string) => {
|
const getPriorityConfig = (type: string) => {
|
||||||
switch (priority) {
|
switch (type) {
|
||||||
case 'urgent':
|
case 'error':
|
||||||
return {
|
return {
|
||||||
color: 'destructive' as const,
|
color: 'destructive' as const,
|
||||||
icon: AlertTriangle,
|
icon: AlertTriangle,
|
||||||
label: 'Urgente'
|
label: 'Erreur'
|
||||||
};
|
};
|
||||||
case 'important':
|
case 'warning':
|
||||||
return {
|
return {
|
||||||
color: 'default' as const,
|
color: 'default' as const,
|
||||||
icon: Clock,
|
icon: Bell,
|
||||||
label: 'Importante'
|
label: 'Attention'
|
||||||
};
|
};
|
||||||
case 'normal':
|
case 'success':
|
||||||
|
return {
|
||||||
|
color: 'default' as const,
|
||||||
|
icon: CheckCircle,
|
||||||
|
label: 'Succès'
|
||||||
|
};
|
||||||
|
case 'info':
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
color: 'secondary' as const,
|
color: 'secondary' as const,
|
||||||
icon: Circle,
|
icon: Info,
|
||||||
label: 'Normale'
|
label: 'Information'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -310,20 +316,21 @@ export default function AnnouncementCard() {
|
|||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="priority"
|
name="type"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Priorité</FormLabel>
|
<FormLabel>Type</FormLabel>
|
||||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue placeholder="Sélectionner une priorité" />
|
<SelectValue placeholder="Sélectionner un type" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="normal">Normale</SelectItem>
|
<SelectItem value="info">Information</SelectItem>
|
||||||
<SelectItem value="important">Importante</SelectItem>
|
<SelectItem value="warning">Attention</SelectItem>
|
||||||
<SelectItem value="urgent">Urgente</SelectItem>
|
<SelectItem value="error">Erreur</SelectItem>
|
||||||
|
<SelectItem value="success">Succès</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
@@ -332,7 +339,7 @@ export default function AnnouncementCard() {
|
|||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="groupId"
|
name="storeId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Magasin (optionnel)</FormLabel>
|
<FormLabel>Magasin (optionnel)</FormLabel>
|
||||||
@@ -393,7 +400,7 @@ export default function AnnouncementCard() {
|
|||||||
) : (
|
) : (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{announcements.map((announcement) => {
|
{announcements.map((announcement) => {
|
||||||
const priorityConfig = getPriorityConfig(announcement.priority);
|
const priorityConfig = getPriorityConfig(announcement.type);
|
||||||
const PriorityIcon = priorityConfig.icon;
|
const PriorityIcon = priorityConfig.icon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user