mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-18 04:37:19 +02:00
Move order validation button to the order detail modal
Refactors the UI by removing the order validation button from the calendar grid and adding it to the order detail modal, improving user experience and interface cleanliness. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/CRhacll
This commit is contained in:
1 parent
95823a90c3
commit
f81b90018e
5 files changed
+112
-81
No files matched your search
@@ -11,7 +11,7 @@ import { safeFormat } from "@/lib/dateUtils";
|
||||
import EditOrderModal from "./EditOrderModal";
|
||||
import EditDeliveryModal from "./EditDeliveryModal";
|
||||
import ValidateDeliveryModal from "./ValidateDeliveryModal";
|
||||
import { Package, Truck, Edit, Trash2, Check, X } from "lucide-react";
|
||||
import { Package, Truck, Edit, Trash2, Check, X, CheckCircle } from "lucide-react";
|
||||
|
||||
interface OrderDetailModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -33,6 +33,39 @@ export default function OrderDetailModal({
|
||||
const isOrder = item?.type === 'order';
|
||||
const isDelivery = item?.type === 'delivery';
|
||||
|
||||
const validateOrderMutation = useMutation({
|
||||
mutationFn: async (orderId: number) => {
|
||||
await apiRequest(`/api/orders/${orderId}`, "PUT", { status: 'delivered' });
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast({
|
||||
title: "Succès",
|
||||
description: "Commande validée avec succès",
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/orders'] });
|
||||
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
||||
onClose();
|
||||
},
|
||||
onError: (error) => {
|
||||
if (isUnauthorizedError(error)) {
|
||||
toast({
|
||||
title: "Non autorisé",
|
||||
description: "Vous êtes déconnecté. Reconnexion...",
|
||||
variant: "destructive",
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.href = "/api/login";
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
toast({
|
||||
title: "Erreur",
|
||||
description: "Impossible de valider la commande",
|
||||
variant: "destructive",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const validateDeliveryMutation = useMutation({
|
||||
mutationFn: async (data: { id: number; blNumber: string; blAmount: number }) => {
|
||||
await apiRequest(`/api/deliveries/${data.id}/validate`, "POST", data);
|
||||
@@ -354,6 +387,18 @@ export default function OrderDetailModal({
|
||||
Modifier
|
||||
</Button>
|
||||
)}
|
||||
{/* Bouton de validation pour les commandes (admin seulement) */}
|
||||
{isOrder && user?.role === 'admin' && item?.status !== 'delivered' && (
|
||||
<Button
|
||||
onClick={() => validateOrderMutation.mutate(item.id)}
|
||||
disabled={validateOrderMutation.isPending}
|
||||
className="bg-green-600 hover:bg-green-700"
|
||||
>
|
||||
<CheckCircle className="w-4 h-4 mr-2" />
|
||||
{validateOrderMutation.isPending ? 'Validation...' : 'Valider Commande'}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{canValidate && (
|
||||
<Button
|
||||
onClick={handleValidateDelivery}
|
||||
|
||||
Reference in new issue
Block a user