correzione a modale di scarico e a drag & drop
All checks were successful
Deploy to VPS / build (push) Successful in 39s
Deploy to VPS / deploy (push) Successful in 27s

This commit is contained in:
AV77web 2026-05-29 16:59:26 +02:00
parent 17119cda99
commit 17592d1f35
3 changed files with 33 additions and 14 deletions

View file

@ -10,18 +10,18 @@ export default function Home() {
{/* Header */} {/* Header */}
<div className="mb-6 flex-shrink-0"> <div className="mb-6 flex-shrink-0">
<h1 className="text-2xl font-bold text-white">MagRicambi</h1> <h1 className="text-2xl font-bold text-white">MagRicambi</h1>
<p className="text-sm text-zinc-500">Gestione magazzino ricambi</p> <p className="text-sm text-zinc-500">Gestione magazzino ricambi - Trascina articoli sulle macchine per assegnarli</p>
</div> </div>
{/* Contenuto principale: split 50/50 */} {/* Contenuto principale: split 50/50 */}
<div className="flex-1 grid grid-cols-2 gap-6 min-h-0"> <div className="flex-1 grid grid-cols-2 gap-6 min-h-0">
{/* Colonna sinistra: Articoli */} {/* Colonna sinistra: Articoli */}
<div className="flex flex-col min-h-0 p-4 rounded-xl bg-zinc-900/50 border border-zinc-800"> <div className="flex flex-col min-h-0 p-4 rounded-xl bg-zinc-900/50 border border-zinc-800 overflow-visible">
<ArticlesList /> <ArticlesList />
</div> </div>
{/* Colonna destra: Macchine (placeholder) */} {/* Colonna destra: Macchine */}
<div className="flex flex-col min-h-0 p-4 rounded-xl bg-zinc-900/50 border border-zinc-800"> <div className="flex flex-col min-h-0 p-4 rounded-xl bg-zinc-900/50 border border-zinc-800 overflow-visible">
<MacchineTree /> <MacchineTree />
</div> </div>
</div> </div>

View file

@ -62,23 +62,17 @@ export default function MovimentoModal({
useEffect(() => { useEffect(() => {
function handleKeyDown(e: KeyboardEvent) { function handleKeyDown(e: KeyboardEvent) {
if (e.key === "Escape") onClose(); if (e.key === "Escape" && !showDestinazioneModal) {
}
function handleClickOutside(e: MouseEvent) {
if (modalRef.current && !modalRef.current.contains(e.target as Node)) {
onClose(); onClose();
} }
} }
document.addEventListener("keydown", handleKeyDown); document.addEventListener("keydown", handleKeyDown);
document.addEventListener("mousedown", handleClickOutside);
return () => { return () => {
document.removeEventListener("keydown", handleKeyDown); document.removeEventListener("keydown", handleKeyDown);
document.removeEventListener("mousedown", handleClickOutside);
}; };
}, [onClose]); }, [onClose, showDestinazioneModal]);
const filteredMagazzini = selectedStabilimento const filteredMagazzini = selectedStabilimento
? magazzini.filter((m) => m.id_stabilimento === selectedStabilimento) ? magazzini.filter((m) => m.id_stabilimento === selectedStabilimento)
@ -156,11 +150,21 @@ export default function MovimentoModal({
} }
}; };
const handleBackdropClick = (e: React.MouseEvent) => {
if (e.target === e.currentTarget && !showDestinazioneModal) {
onClose();
}
};
return ( return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm"> <div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm"
onClick={handleBackdropClick}
>
<div <div
ref={modalRef} ref={modalRef}
className="w-full max-w-md bg-zinc-900 rounded-2xl shadow-2xl border border-zinc-800 overflow-hidden" className="w-full max-w-md bg-zinc-900 rounded-2xl shadow-2xl border border-zinc-800 overflow-hidden"
onClick={(e) => e.stopPropagation()}
> >
{/* Header */} {/* Header */}
<div className={`flex items-center justify-between px-6 py-4 border-b ${ <div className={`flex items-center justify-between px-6 py-4 border-b ${

View file

@ -118,15 +118,29 @@ export default function TreeNode({
const handleDragOver = (e: DragEvent<HTMLDivElement>) => { const handleDragOver = (e: DragEvent<HTMLDivElement>) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
e.dataTransfer.dropEffect = "move";
setIsDragOver(true); setIsDragOver(true);
}; };
const handleDragLeave = (e: DragEvent<HTMLDivElement>) => { const handleDragLeave = (e: DragEvent<HTMLDivElement>) => {
const relatedTarget = e.relatedTarget as Node | null;
const currentTarget = e.currentTarget as Node;
if (relatedTarget && currentTarget.contains(relatedTarget)) {
return;
}
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
setIsDragOver(false); setIsDragOver(false);
}; };
const handleDragEnter = (e: DragEvent<HTMLDivElement>) => {
e.preventDefault();
e.stopPropagation();
setIsDragOver(true);
};
const safeTextColor = getReadableTextColor(node.colore_testo); const safeTextColor = getReadableTextColor(node.colore_testo);
const getNodeTypeIcon = () => { const getNodeTypeIcon = () => {
@ -155,8 +169,9 @@ export default function TreeNode({
<div <div
className={`flex items-center gap-2 px-3 py-2 rounded-lg border transition-all group className={`flex items-center gap-2 px-3 py-2 rounded-lg border transition-all group
${getNodeTypeBg()} ${getNodeTypeBg()}
${isDragOver ? "ring-2 ring-blue-500 bg-blue-900/50" : ""} ${isDragOver ? "ring-2 ring-blue-500 bg-blue-900/50 scale-[1.02]" : ""}
hover:bg-zinc-800/70`} hover:bg-zinc-800/70`}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver} onDragOver={handleDragOver}
onDragLeave={handleDragLeave} onDragLeave={handleDragLeave}
onDrop={handleDrop} onDrop={handleDrop}