Merge pull request #66 from R0m1k3/1.1

Fix permission errors on delivery and order pages
This commit is contained in:
LogiFlow authored and GitHub committed 2025-08-12 22:48:18 +02:00
commit 0ed8cf3780
4 files changed
+8 -4

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

+4 -2
View File
@@ -10,6 +10,7 @@ import { useStore } from "@/components/Layout";
import { useToast } from "@/hooks/use-toast"; import { useToast } from "@/hooks/use-toast";
import { apiRequest } from "@/lib/queryClient"; import { apiRequest } from "@/lib/queryClient";
import { isUnauthorizedError } from "@/lib/authUtils"; import { isUnauthorizedError } from "@/lib/authUtils";
import { usePermissions } from "@shared/permissions";
import { import {
Plus, Plus,
Search, Search,
@@ -36,6 +37,7 @@ export default function Deliveries() {
const { selectedStoreId } = useStore(); const { selectedStoreId } = useStore();
const { toast } = useToast(); const { toast } = useToast();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const permissions = usePermissions(user?.role);
// Redirection pour les employés // Redirection pour les employés
if (user?.role === 'employee') { if (user?.role === 'employee') {
@@ -219,7 +221,7 @@ export default function Deliveries() {
}; };
const handleViewDelivery = (delivery: DeliveryWithRelations) => { const handleViewDelivery = (delivery: DeliveryWithRelations) => {
setSelectedDelivery({ ...delivery, type: 'delivery' }); setSelectedDelivery(delivery);
setShowDetailModal(true); setShowDetailModal(true);
}; };
@@ -316,7 +318,7 @@ export default function Deliveries() {
<div className="flex items-center justify-center h-64"> <div className="flex items-center justify-center h-64">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-secondary"></div> <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-secondary"></div>
</div> </div>
) : (console.log('🚚 Filtered deliveries length:', filteredDeliveries.length) || filteredDeliveries.length === 0) ? ( ) : filteredDeliveries.length === 0 ? (
<div className="flex flex-col items-center justify-center h-64 text-gray-500"> <div className="flex flex-col items-center justify-center h-64 text-gray-500">
<Truck className="w-16 h-16 mb-4 text-gray-300" /> <Truck className="w-16 h-16 mb-4 text-gray-300" />
<h3 className="text-lg font-medium mb-2">Aucune livraison trouvée</h3> <h3 className="text-lg font-medium mb-2">Aucune livraison trouvée</h3>
+4 -2
View File
@@ -10,6 +10,7 @@ import { useStore } from "@/components/Layout";
import { useToast } from "@/hooks/use-toast"; import { useToast } from "@/hooks/use-toast";
import { apiRequest } from "@/lib/queryClient"; import { apiRequest } from "@/lib/queryClient";
import { isUnauthorizedError } from "@/lib/authUtils"; import { isUnauthorizedError } from "@/lib/authUtils";
import { usePermissions } from "@shared/permissions";
import { import {
Plus, Plus,
Search, Search,
@@ -34,6 +35,7 @@ export default function Orders() {
const { selectedStoreId } = useStore(); const { selectedStoreId } = useStore();
const { toast } = useToast(); const { toast } = useToast();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const permissions = usePermissions(user?.role);
// Redirection pour les employés // Redirection pour les employés
if (user?.role === 'employee') { if (user?.role === 'employee') {
@@ -197,7 +199,7 @@ export default function Orders() {
}; };
const handleViewOrder = (order: OrderWithRelations) => { const handleViewOrder = (order: OrderWithRelations) => {
setSelectedOrder({ ...order, type: 'order' }); setSelectedOrder(order);
setShowDetailModal(true); setShowDetailModal(true);
}; };
@@ -285,7 +287,7 @@ export default function Orders() {
<div className="flex items-center justify-center h-64"> <div className="flex items-center justify-center h-64">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary"></div> <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary"></div>
</div> </div>
) : (console.log('📦 Filtered orders length:', filteredOrders.length) || filteredOrders.length === 0) ? ( ) : filteredOrders.length === 0 ? (
<div className="flex flex-col items-center justify-center h-64 text-gray-500"> <div className="flex flex-col items-center justify-center h-64 text-gray-500">
<Package className="w-16 h-16 mb-4 text-gray-300" /> <Package className="w-16 h-16 mb-4 text-gray-300" />
<h3 className="text-lg font-medium mb-2">Aucune commande trouvée</h3> <h3 className="text-lg font-medium mb-2">Aucune commande trouvée</h3>