mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 22:18:17 +02:00
Merge pull request #427 from R0m1k3/1.1
Make delivery comments read-only after reconciliation
This commit is contained in:
2 files changed
+34
-15
No files matched your search
@@ -985,8 +985,8 @@ export default function BLReconciliation() {
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => handleOpenCommentModal(delivery)}
|
onClick={() => handleOpenCommentModal(delivery)}
|
||||||
className={`h-8 w-8 p-0 ${delivery.notes ? 'text-blue-600 hover:text-blue-700' : 'text-gray-400 hover:text-gray-600'}`}
|
className={`h-8 w-8 p-0 ${delivery.notes ? 'text-blue-600 hover:text-blue-700' : 'text-gray-400 hover:text-gray-600'} ${delivery.reconciled ? 'opacity-70' : ''}`}
|
||||||
title={delivery.notes ? "Voir/Modifier commentaire" : "Ajouter commentaire"}
|
title={delivery.reconciled ? (delivery.notes ? "Voir commentaire (lecture seule)" : "Aucun commentaire") : (delivery.notes ? "Voir/Modifier commentaire" : "Ajouter commentaire")}
|
||||||
>
|
>
|
||||||
<MessageSquare className="h-4 w-4" />
|
<MessageSquare className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -1199,8 +1199,8 @@ export default function BLReconciliation() {
|
|||||||
delivery.notes
|
delivery.notes
|
||||||
? 'text-blue-600 hover:text-blue-700 hover:bg-blue-50'
|
? 'text-blue-600 hover:text-blue-700 hover:bg-blue-50'
|
||||||
: 'text-gray-400 hover:text-gray-600 hover:bg-gray-50'
|
: 'text-gray-400 hover:text-gray-600 hover:bg-gray-50'
|
||||||
}`}
|
} ${delivery.reconciled ? 'opacity-70' : ''}`}
|
||||||
title={delivery.notes ? "Voir/Modifier commentaire" : "Ajouter commentaire"}
|
title={delivery.reconciled ? (delivery.notes ? "Voir commentaire (lecture seule)" : "Aucun commentaire") : (delivery.notes ? "Voir/Modifier commentaire" : "Ajouter commentaire")}
|
||||||
>
|
>
|
||||||
<MessageSquare className="h-4 w-4" />
|
<MessageSquare className="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
@@ -1389,6 +1389,9 @@ export default function BLReconciliation() {
|
|||||||
<DialogTitle className="flex items-center space-x-2">
|
<DialogTitle className="flex items-center space-x-2">
|
||||||
<MessageSquare className="w-5 h-5 text-blue-600" />
|
<MessageSquare className="w-5 h-5 text-blue-600" />
|
||||||
<span>Commentaire de livraison</span>
|
<span>Commentaire de livraison</span>
|
||||||
|
{selectedDeliveryForComment?.reconciled && (
|
||||||
|
<span className="text-sm bg-gray-100 text-gray-600 px-2 py-1 rounded">Lecture seule</span>
|
||||||
|
)}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
@@ -1411,15 +1414,24 @@ export default function BLReconciliation() {
|
|||||||
<Label htmlFor="comment">Commentaire</Label>
|
<Label htmlFor="comment">Commentaire</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
id="comment"
|
id="comment"
|
||||||
placeholder="Ajouter un commentaire sur cette livraison..."
|
placeholder={selectedDeliveryForComment?.reconciled ? "Aucun commentaire" : "Ajouter un commentaire sur cette livraison..."}
|
||||||
value={commentText}
|
value={commentText}
|
||||||
onChange={(e) => setCommentText(e.target.value)}
|
onChange={(e) => setCommentText(e.target.value)}
|
||||||
rows={4}
|
rows={4}
|
||||||
className="min-h-[100px]"
|
className="min-h-[100px]"
|
||||||
|
disabled={selectedDeliveryForComment?.reconciled}
|
||||||
|
readOnly={selectedDeliveryForComment?.reconciled}
|
||||||
/>
|
/>
|
||||||
<div className="text-xs text-gray-500">
|
{!selectedDeliveryForComment?.reconciled && (
|
||||||
{commentText.length}/500 caractères
|
<div className="text-xs text-gray-500">
|
||||||
</div>
|
{commentText.length}/500 caractères
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{selectedDeliveryForComment?.reconciled && (
|
||||||
|
<div className="text-xs text-orange-600">
|
||||||
|
Le commentaire ne peut pas être modifié car le rapprochement est validé
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -1430,14 +1442,16 @@ export default function BLReconciliation() {
|
|||||||
onClick={handleCloseCommentModal}
|
onClick={handleCloseCommentModal}
|
||||||
disabled={updateNoteMutation.isPending}
|
disabled={updateNoteMutation.isPending}
|
||||||
>
|
>
|
||||||
Annuler
|
{selectedDeliveryForComment?.reconciled ? "Fermer" : "Annuler"}
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={handleSaveComment}
|
|
||||||
disabled={updateNoteMutation.isPending || commentText.length > 500}
|
|
||||||
>
|
|
||||||
{updateNoteMutation.isPending ? "Sauvegarde..." : "Enregistrer"}
|
|
||||||
</Button>
|
</Button>
|
||||||
|
{!selectedDeliveryForComment?.reconciled && (
|
||||||
|
<Button
|
||||||
|
onClick={handleSaveComment}
|
||||||
|
disabled={updateNoteMutation.isPending || commentText.length > 500}
|
||||||
|
>
|
||||||
|
{updateNoteMutation.isPending ? "Sauvegarde..." : "Enregistrer"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -1356,6 +1356,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
|
|
||||||
const { notes } = req.body;
|
const { notes } = req.body;
|
||||||
|
|
||||||
|
// Check if delivery is reconciled (read-only)
|
||||||
|
if (delivery.reconciled) {
|
||||||
|
return res.status(403).json({ message: "Impossible de modifier le commentaire d'une livraison réconciliée" });
|
||||||
|
}
|
||||||
|
|
||||||
// Validate notes length
|
// Validate notes length
|
||||||
if (notes && notes.length > 500) {
|
if (notes && notes.length > 500) {
|
||||||
return res.status(400).json({ message: "Commentaire trop long (maximum 500 caractères)" });
|
return res.status(400).json({ message: "Commentaire trop long (maximum 500 caractères)" });
|
||||||
|
|||||||
Reference in new issue
Block a user