Browse Source

Immage order

Sviluppo_Carrello_Immagini
Lorenzo Pollutri 1 month ago
parent
commit
7a6d685457
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      app/admin/page.tsx

+ 28
- 0
app/admin/page.tsx View File

@@ -322,6 +322,20 @@ export default function AdminDashboard() {
}));
};
const moveExtraMedia = (index: number, direction: 'up' | 'down') => {
setIsEditing(prev => {
const items = [...(prev?.extraMedia || [])];
if (direction === 'up' && index > 0) {
[items[index - 1], items[index]] = [items[index], items[index - 1]];
} else if (direction === 'down' && index < items.length - 1) {
[items[index + 1], items[index]] = [items[index], items[index + 1]];
} else {
return prev;
}
return { ...prev, extraMedia: items };
});
};
const toggleAutoplay = (index: number) => {
setIsEditing(prev => ({
...prev,
@@ -807,6 +821,20 @@ export default function AdminDashboard() {
</div>
)}
</div>
<button
onClick={() => moveExtraMedia(i, 'up')}
className="bg-gray-200 hover:bg-gray-300 text-gray-700 w-8 h-8 rounded-full text-sm font-bold shrink-0 flex items-center justify-center disabled:opacity-40 disabled:cursor-not-allowed"
title="Sposta su"
aria-label="Sposta su"
disabled={i === 0}
>↑</button>
<button
onClick={() => moveExtraMedia(i, 'down')}
className="bg-gray-200 hover:bg-gray-300 text-gray-700 w-8 h-8 rounded-full text-sm font-bold shrink-0 flex items-center justify-center disabled:opacity-40 disabled:cursor-not-allowed"
title="Sposta giù"
aria-label="Sposta giù"
disabled={i === (isEditing.extraMedia || []).length - 1}
>↓</button>
<a
href={item.url}
download={extractFileName(item.url)}


Loading…
Cancel
Save