Fix permission errors on delivery and order pages

Address ReferenceError by correctly importing and utilizing the usePermissions hook in Deliveries.tsx and Orders.tsx, resolving undefined permission issues and refining the handling of modal data for deliveries and orders.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 76582ba3-44cb-4730-92fa-66f28725967b
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/76582ba3-44cb-4730-92fa-66f28725967b/QrspnZr
This commit is contained in:
michaelschal committed 2025-08-12 20:47:03 +00:00
1 parent a4a637d415
commit a7936fab8d
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 { apiRequest } from "@/lib/queryClient";
import { isUnauthorizedError } from "@/lib/authUtils";
import { usePermissions } from "@shared/permissions";
import {
Plus,
Search,
@@ -36,6 +37,7 @@ export default function Deliveries() {
const { selectedStoreId } = useStore();
const { toast } = useToast();
const queryClient = useQueryClient();
const permissions = usePermissions(user?.role);
// Redirection pour les employés
if (user?.role === 'employee') {
@@ -219,7 +221,7 @@ export default function Deliveries() {
};
const handleViewDelivery = (delivery: DeliveryWithRelations) => {
setSelectedDelivery({ ...delivery, type: 'delivery' });
setSelectedDelivery(delivery);
setShowDetailModal(true);
};
@@ -316,7 +318,7 @@ export default function Deliveries() {
<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>
) : (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">
<Truck className="w-16 h-16 mb-4 text-gray-300" />
<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 { apiRequest } from "@/lib/queryClient";
import { isUnauthorizedError } from "@/lib/authUtils";
import { usePermissions } from "@shared/permissions";
import {
Plus,
Search,
@@ -34,6 +35,7 @@ export default function Orders() {
const { selectedStoreId } = useStore();
const { toast } = useToast();
const queryClient = useQueryClient();
const permissions = usePermissions(user?.role);
// Redirection pour les employés
if (user?.role === 'employee') {
@@ -197,7 +199,7 @@ export default function Orders() {
};
const handleViewOrder = (order: OrderWithRelations) => {
setSelectedOrder({ ...order, type: 'order' });
setSelectedOrder(order);
setShowDetailModal(true);
};
@@ -285,7 +287,7 @@ export default function Orders() {
<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>
) : (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">
<Package className="w-16 h-16 mb-4 text-gray-300" />
<h3 className="text-lg font-medium mb-2">Aucune commande trouvée</h3>