mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 02:38:58 +02:00
Restrict employee access to orders and deliveries while fixing supplier visibility
Fixes bugs that prevented employees from viewing supplier lists and restricted their access to order and delivery creation functionalities. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/9RgkyCi
This commit is contained in:
1 parent
5fe9763763
commit
5ea3481dc0
7 files changed
+263
-45
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Package, Truck } from "lucide-react";
|
||||
import { useAuthUnified } from "@/hooks/useAuthUnified";
|
||||
import { hasPermission } from "@/lib/permissions";
|
||||
|
||||
interface QuickCreateMenuProps {
|
||||
isOpen: boolean;
|
||||
@@ -15,6 +17,11 @@ export default function QuickCreateMenu({
|
||||
onCreateOrder,
|
||||
onCreateDelivery,
|
||||
}: QuickCreateMenuProps) {
|
||||
const { user } = useAuthUnified();
|
||||
|
||||
const canCreateOrders = hasPermission(user?.role || '', 'orders', 'create');
|
||||
const canCreateDeliveries = hasPermission(user?.role || '', 'deliveries', 'create');
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="sm:max-w-md" aria-describedby="quick-create-modal-description">
|
||||
@@ -25,33 +32,43 @@ export default function QuickCreateMenu({
|
||||
</p>
|
||||
</DialogHeader>
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start space-x-3 p-4 h-auto hover:bg-blue-50 hover:border-blue-300"
|
||||
onClick={onCreateOrder}
|
||||
>
|
||||
<div className="w-10 h-10 bg-primary rounded-lg flex items-center justify-center">
|
||||
<Package className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<p className="font-medium text-gray-900">Nouvelle Commande</p>
|
||||
<p className="text-sm text-gray-600">Créer une commande fournisseur</p>
|
||||
</div>
|
||||
</Button>
|
||||
{canCreateOrders && (
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start space-x-3 p-4 h-auto hover:bg-blue-50 hover:border-blue-300"
|
||||
onClick={onCreateOrder}
|
||||
>
|
||||
<div className="w-10 h-10 bg-primary rounded-lg flex items-center justify-center">
|
||||
<Package className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<p className="font-medium text-gray-900">Nouvelle Commande</p>
|
||||
<p className="text-sm text-gray-600">Créer une commande fournisseur</p>
|
||||
</div>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start space-x-3 p-4 h-auto hover:bg-green-50 hover:border-green-300"
|
||||
onClick={onCreateDelivery}
|
||||
>
|
||||
<div className="w-10 h-10 bg-secondary rounded-lg flex items-center justify-center">
|
||||
<Truck className="w-5 h-5 text-white" />
|
||||
{canCreateDeliveries && (
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start space-x-3 p-4 h-auto hover:bg-green-50 hover:border-green-300"
|
||||
onClick={onCreateDelivery}
|
||||
>
|
||||
<div className="w-10 h-10 bg-secondary rounded-lg flex items-center justify-center">
|
||||
<Truck className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<p className="font-medium text-gray-900">Nouvelle Livraison</p>
|
||||
<p className="text-sm text-gray-600">Planifier une livraison</p>
|
||||
</div>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{!canCreateOrders && !canCreateDeliveries && (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
<p>Vous n'avez pas les permissions nécessaires pour créer des commandes ou livraisons.</p>
|
||||
</div>
|
||||
<div className="text-left">
|
||||
<p className="font-medium text-gray-900">Nouvelle Livraison</p>
|
||||
<p className="text-sm text-gray-600">Planifier une livraison</p>
|
||||
</div>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
Reference in new issue
Block a user