mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Add functionality to mark delivery controls as validated
Introduces a new API endpoint and UI elements to allow users to mark delivery controls as validated, including associated badges and mutation logic. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/Q8UjAXl
This commit is contained in:
1 parent
51e04fa9a1
commit
b73f9f25d1
3 files changed
+74
-2
No files matched your search
@@ -47,6 +47,10 @@ externalPort = 6000
|
|||||||
localPort = 44549
|
localPort = 44549
|
||||||
externalPort = 5173
|
externalPort = 5173
|
||||||
|
|
||||||
|
[[ports]]
|
||||||
|
localPort = 44701
|
||||||
|
externalPort = 8000
|
||||||
|
|
||||||
[[ports]]
|
[[ports]]
|
||||||
localPort = 44965
|
localPort = 44965
|
||||||
externalPort = 6800
|
externalPort = 6800
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ import {
|
|||||||
Building,
|
Building,
|
||||||
User,
|
User,
|
||||||
Check,
|
Check,
|
||||||
Package
|
Package,
|
||||||
|
AlertTriangle,
|
||||||
|
CheckCircle
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { safeFormat } from "@/lib/dateUtils";
|
import { safeFormat } from "@/lib/dateUtils";
|
||||||
import CreateDeliveryModal from "@/components/modals/CreateDeliveryModal";
|
import CreateDeliveryModal from "@/components/modals/CreateDeliveryModal";
|
||||||
@@ -111,6 +113,30 @@ export default function Deliveries() {
|
|||||||
const groups = Array.isArray(groupsData) ? groupsData : [];
|
const groups = Array.isArray(groupsData) ? groupsData : [];
|
||||||
|
|
||||||
|
|
||||||
|
const markControlValidatedMutation = useMutation({
|
||||||
|
mutationFn: async (id: number) => {
|
||||||
|
await apiRequest(`/api/deliveries/${id}/control`, "PUT");
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
toast({
|
||||||
|
title: "Succès",
|
||||||
|
description: "Contrôle validé avec succès",
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['/api/deliveries'] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: [deliveriesUrl] });
|
||||||
|
},
|
||||||
|
onError: (error: any) => {
|
||||||
|
if (isUnauthorizedError(error)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toast({
|
||||||
|
title: "Erreur",
|
||||||
|
description: "Impossible de valider le contrôle",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
const deleteMutation = useMutation({
|
||||||
mutationFn: async (id: number) => {
|
mutationFn: async (id: number) => {
|
||||||
await apiRequest(`/api/deliveries/${id}`, "DELETE");
|
await apiRequest(`/api/deliveries/${id}`, "DELETE");
|
||||||
@@ -180,6 +206,28 @@ export default function Deliveries() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getControlBadge = (delivery: DeliveryWithRelations) => {
|
||||||
|
if (!delivery.supplier?.requiresControl) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delivery.controlValidated) {
|
||||||
|
return (
|
||||||
|
<Badge className="bg-green-50 text-green-700 border-green-200 flex items-center gap-1">
|
||||||
|
<CheckCircle className="w-3 h-3" />
|
||||||
|
Contrôle validé
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Badge className="bg-orange-50 text-orange-700 border-orange-200 flex items-center gap-1">
|
||||||
|
<AlertTriangle className="w-3 h-3" />
|
||||||
|
Contrôle à faire
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const formatQuantity = (quantity: number, unit: string) => {
|
const formatQuantity = (quantity: number, unit: string) => {
|
||||||
return `${quantity} ${unit === 'palettes' ? 'P' : 'C'}`;
|
return `${quantity} ${unit === 'palettes' ? 'P' : 'C'}`;
|
||||||
};
|
};
|
||||||
@@ -209,6 +257,10 @@ export default function Deliveries() {
|
|||||||
setShowDeleteModal(true);
|
setShowDeleteModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleMarkControlValidated = (deliveryId: number) => {
|
||||||
|
markControlValidatedMutation.mutate(deliveryId);
|
||||||
|
};
|
||||||
|
|
||||||
const confirmDeleteDelivery = () => {
|
const confirmDeleteDelivery = () => {
|
||||||
if (deliveryToDelete) {
|
if (deliveryToDelete) {
|
||||||
deleteMutation.mutate(deliveryToDelete.id);
|
deleteMutation.mutate(deliveryToDelete.id);
|
||||||
@@ -375,7 +427,10 @@ export default function Deliveries() {
|
|||||||
</Badge>
|
</Badge>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
<td className="px-6 py-4 whitespace-nowrap">
|
||||||
{getStatusBadge(delivery.status)}
|
<div className="flex flex-col gap-1">
|
||||||
|
{getStatusBadge(delivery.status)}
|
||||||
|
{getControlBadge(delivery)}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
{delivery.order ? (
|
{delivery.order ? (
|
||||||
@@ -422,6 +477,18 @@ export default function Deliveries() {
|
|||||||
<Check className="w-4 h-4 border border-gray-300 rounded p-0.5" />
|
<Check className="w-4 h-4 border border-gray-300 rounded p-0.5" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{delivery.supplier?.requiresControl && !delivery.controlValidated && delivery.status === 'delivered' && (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handleMarkControlValidated(delivery.id)}
|
||||||
|
className="text-orange-600 hover:text-orange-700"
|
||||||
|
data-testid={`button-validate-control-${delivery.id}`}
|
||||||
|
title="Marquer le contrôle comme effectué"
|
||||||
|
>
|
||||||
|
<CheckCircle className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{canDelete && (
|
{canDelete && (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export interface IStorage {
|
|||||||
updateDelivery(id: number, delivery: Partial<InsertDelivery>): Promise<Delivery>;
|
updateDelivery(id: number, delivery: Partial<InsertDelivery>): Promise<Delivery>;
|
||||||
deleteDelivery(id: number): Promise<void>;
|
deleteDelivery(id: number): Promise<void>;
|
||||||
validateDelivery(id: number, blData?: { blNumber: string; blAmount: number }): Promise<void>;
|
validateDelivery(id: number, blData?: { blNumber: string; blAmount: number }): Promise<void>;
|
||||||
|
markDeliveryControlValidated(id: number, userId: string): Promise<void>;
|
||||||
|
|
||||||
// User-Group operations
|
// User-Group operations
|
||||||
getUserGroups(userId: string): Promise<UserGroup[]>;
|
getUserGroups(userId: string): Promise<UserGroup[]>;
|
||||||
|
|||||||
Reference in new issue
Block a user