mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-18 12:47:33 +02:00
Remove store selection and simplify announcement creation
Remove the store selection field and associated logic from the announcement creation form and backend API to simplify the process and ensure all announcements are globally applicable. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce/CvLQ6E2
This commit is contained in:
1 parent
ec1fe2284f
commit
ce92323060
4 files changed
+212
-36
No files matched your search
@@ -25,7 +25,6 @@ const formSchema = z.object({
|
||||
title: z.string().min(1, "Le titre est obligatoire"),
|
||||
content: z.string().min(1, "Le contenu est obligatoire"),
|
||||
type: z.enum(["info", "warning", "error", "success"]).default("info"),
|
||||
storeId: z.number().optional().nullable(),
|
||||
});
|
||||
|
||||
export default function AnnouncementCard() {
|
||||
@@ -42,7 +41,6 @@ export default function AnnouncementCard() {
|
||||
title: "",
|
||||
content: "",
|
||||
type: "info",
|
||||
storeId: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -53,14 +51,12 @@ export default function AnnouncementCard() {
|
||||
title: editingAnnouncement.title,
|
||||
content: editingAnnouncement.content,
|
||||
type: editingAnnouncement.type as "info" | "warning" | "error" | "success",
|
||||
storeId: editingAnnouncement.storeId || undefined,
|
||||
});
|
||||
} else {
|
||||
form.reset({
|
||||
title: "",
|
||||
content: "",
|
||||
type: "info",
|
||||
storeId: undefined,
|
||||
});
|
||||
}
|
||||
}, [editingAnnouncement, form]);
|
||||
@@ -87,11 +83,7 @@ export default function AnnouncementCard() {
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
// Fetch groups for admin
|
||||
const { data: groups = [] } = useQuery<any[]>({
|
||||
queryKey: ['/api/groups'],
|
||||
enabled: user?.role === 'admin',
|
||||
});
|
||||
|
||||
|
||||
// Create/Update announcement mutation
|
||||
const createMutation = useMutation({
|
||||
@@ -337,31 +329,7 @@ export default function AnnouncementCard() {
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="storeId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Magasin (optionnel)</FormLabel>
|
||||
<Select onValueChange={(value) => field.onChange(value === 'all' ? null : parseInt(value))}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Tous les magasins" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">Tous les magasins</SelectItem>
|
||||
{groups.map((group: any) => (
|
||||
<SelectItem key={group.id} value={group.id.toString()}>
|
||||
{group.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-end space-x-2 pt-4">
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user