mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-19 13:08:23 +02:00
Merge pull request #417 from R0m1k3/1.1
Prevent changing status for validated invoices and disable selection
This commit is contained in:
1 file changed
+14
-3
@@ -458,6 +458,18 @@ export default function Avoirs() {
|
|||||||
|
|
||||||
// Handle status change
|
// Handle status change
|
||||||
const handleStatusChange = (avoirId: number, newStatus: string) => {
|
const handleStatusChange = (avoirId: number, newStatus: string) => {
|
||||||
|
const avoir = avoirs?.find(a => a?.id === avoirId);
|
||||||
|
|
||||||
|
// Empêcher la modification du statut pour les avoirs validés
|
||||||
|
if (avoir?.nocodbVerified) {
|
||||||
|
toast({
|
||||||
|
title: "Modification interdite",
|
||||||
|
description: "Impossible de modifier le statut d'un avoir validé",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Empêcher les managers de mettre le statut en "Reçu"
|
// Empêcher les managers de mettre le statut en "Reçu"
|
||||||
if ((user as any)?.role === 'manager' && newStatus === 'Reçu') {
|
if ((user as any)?.role === 'manager' && newStatus === 'Reçu') {
|
||||||
toast({
|
toast({
|
||||||
@@ -467,8 +479,6 @@ export default function Avoirs() {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const avoir = avoirs?.find(a => a?.id === avoirId);
|
|
||||||
if (avoir && avoir.supplierId && avoir.groupId) {
|
if (avoir && avoir.supplierId && avoir.groupId) {
|
||||||
editAvoirMutation.mutate({
|
editAvoirMutation.mutate({
|
||||||
id: avoirId,
|
id: avoirId,
|
||||||
@@ -984,8 +994,9 @@ export default function Avoirs() {
|
|||||||
<Select
|
<Select
|
||||||
value={avoir?.status || ''}
|
value={avoir?.status || ''}
|
||||||
onValueChange={(newStatus) => handleStatusChange(avoir.id, newStatus)}
|
onValueChange={(newStatus) => handleStatusChange(avoir.id, newStatus)}
|
||||||
|
disabled={avoir.nocodbVerified}
|
||||||
>
|
>
|
||||||
<SelectTrigger className="w-full">
|
<SelectTrigger className={`w-full ${avoir.nocodbVerified ? 'opacity-50 cursor-not-allowed' : ''}`}>
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
|
|||||||
Reference in new issue
Block a user