Initial commit - SaveTheMoment Atlas Basis-Setup
This commit is contained in:
546
app/dashboard/inventory/[id]/page.tsx
Normal file
546
app/dashboard/inventory/[id]/page.tsx
Normal file
@@ -0,0 +1,546 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import DashboardSidebar from '@/components/DashboardSidebar';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { FiPackage, FiArrowLeft, FiSave, FiEdit, FiX, FiTrash2, FiMapPin, FiCalendar } from 'react-icons/fi';
|
||||
import Link from 'next/link';
|
||||
import { formatDate } from '@/lib/date-utils';
|
||||
|
||||
export default function EquipmentDetailPage({ params }: { params: { id: string } }) {
|
||||
const router = useRouter();
|
||||
const { data: session } = useSession();
|
||||
const [equipment, setEquipment] = useState<any>(null);
|
||||
const [locations, setLocations] = useState<any[]>([]);
|
||||
const [projects, setProjects] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [editing, setEditing] = useState(false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [formData, setFormData] = useState<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetchEquipment();
|
||||
fetchLocationsAndProjects();
|
||||
}, [params.id]);
|
||||
|
||||
const fetchEquipment = async () => {
|
||||
try {
|
||||
const res = await fetch(`/api/inventory/${params.id}`);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setEquipment(data.equipment);
|
||||
setFormData(data.equipment);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching equipment:', err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const fetchLocationsAndProjects = async () => {
|
||||
try {
|
||||
const [locRes, projRes] = await Promise.all([
|
||||
fetch('/api/locations'),
|
||||
fetch('/api/projects'),
|
||||
]);
|
||||
|
||||
if (locRes.ok) {
|
||||
const locData = await locRes.json();
|
||||
setLocations(locData.locations || []);
|
||||
}
|
||||
|
||||
if (projRes.ok) {
|
||||
const projData = await projRes.json();
|
||||
setProjects(projData.projects || []);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching data:', err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true);
|
||||
try {
|
||||
const res = await fetch(`/api/inventory/${params.id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
...formData,
|
||||
purchaseDate: formData.purchaseDate || null,
|
||||
purchasePrice: formData.purchasePrice ? parseFloat(formData.purchasePrice) : null,
|
||||
minStockLevel: formData.minStockLevel ? parseInt(formData.minStockLevel) : null,
|
||||
currentStock: formData.currentStock ? parseInt(formData.currentStock) : null,
|
||||
locationId: formData.locationId || null,
|
||||
projectId: formData.projectId || null,
|
||||
}),
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
alert('Gespeichert!');
|
||||
setEditing(false);
|
||||
fetchEquipment();
|
||||
} else {
|
||||
alert('Fehler beim Speichern');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Fehler beim Speichern');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!confirm('Equipment wirklich löschen?')) return;
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/inventory/${params.id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
alert('Equipment gelöscht!');
|
||||
router.push('/dashboard/inventory');
|
||||
} else {
|
||||
alert('Fehler beim Löschen');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Fehler beim Löschen');
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
case 'AVAILABLE': return 'bg-green-500/20 text-green-400 border-green-500/50';
|
||||
case 'IN_USE': return 'bg-blue-500/20 text-blue-400 border-blue-500/50';
|
||||
case 'MAINTENANCE': return 'bg-yellow-500/20 text-yellow-400 border-yellow-500/50';
|
||||
case 'DAMAGED': return 'bg-red-500/20 text-red-400 border-red-500/50';
|
||||
case 'RESERVED': return 'bg-purple-500/20 text-purple-400 border-purple-500/50';
|
||||
default: return 'bg-gray-500/20 text-gray-400 border-gray-500/50';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusLabel = (status: string) => {
|
||||
const labels: any = {
|
||||
AVAILABLE: 'Verfügbar',
|
||||
IN_USE: 'Im Einsatz',
|
||||
MAINTENANCE: 'Wartung',
|
||||
DAMAGED: 'Beschädigt',
|
||||
RESERVED: 'Reserviert',
|
||||
};
|
||||
return labels[status] || status;
|
||||
};
|
||||
|
||||
const getTypeLabel = (type: string) => {
|
||||
const labels: any = {
|
||||
PRINTER: 'Drucker',
|
||||
CARPET: 'Roter Teppich',
|
||||
VIP_BARRIER: 'VIP Absperrband',
|
||||
ACCESSORIES_KIT: 'Accessoires-Koffer',
|
||||
PRINTER_PAPER: 'Druckerpapier',
|
||||
TRIPOD: 'Stativ',
|
||||
OTHER: 'Sonstiges',
|
||||
};
|
||||
return labels[type] || type;
|
||||
};
|
||||
|
||||
if (!session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center">
|
||||
<div className="text-white text-xl">Lade...</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!equipment) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 flex items-center justify-center">
|
||||
<div className="text-gray-400 text-xl">Equipment nicht gefunden</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
||||
<div className="flex">
|
||||
<DashboardSidebar user={session.user} />
|
||||
|
||||
<main className="flex-1 p-8">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div>
|
||||
<Link href="/dashboard/inventory" className="text-sm text-gray-400 hover:text-gray-300 mb-2 inline-flex items-center gap-2 transition-colors">
|
||||
<FiArrowLeft /> Zurück zum Inventar
|
||||
</Link>
|
||||
<h2 className="text-3xl font-bold text-white mt-2">{equipment.name}</h2>
|
||||
<p className="text-gray-400 mt-1">{getTypeLabel(equipment.type)}</p>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
{!editing ? (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setEditing(true)}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-gray-600 to-gray-700 text-white rounded-lg hover:from-gray-700 hover:to-gray-800 shadow-lg transition-all"
|
||||
>
|
||||
<FiEdit /> Bearbeiten
|
||||
</button>
|
||||
<button
|
||||
onClick={handleDelete}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-red-600 to-pink-600 text-white rounded-lg hover:from-red-700 hover:to-pink-700 shadow-lg transition-all"
|
||||
>
|
||||
<FiTrash2 /> Löschen
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
onClick={() => {
|
||||
setEditing(false);
|
||||
setFormData(equipment);
|
||||
}}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-gray-700 text-gray-300 rounded-lg hover:bg-gray-600 transition-colors"
|
||||
>
|
||||
<FiX /> Abbrechen
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={saving}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-red-600 to-pink-600 text-white rounded-lg hover:from-red-700 hover:to-pink-700 disabled:opacity-50 shadow-lg transition-all"
|
||||
>
|
||||
<FiSave /> {saving ? 'Speichern...' : 'Speichern'}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div className="lg:col-span-2 space-y-6">
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<h3 className="text-xl font-bold text-white">Status</h3>
|
||||
<div className={`px-4 py-2 border-2 rounded-lg font-semibold ${getStatusColor(equipment.status)}`}>
|
||||
{getStatusLabel(equipment.status)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{editing && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Status ändern</label>
|
||||
<select
|
||||
value={formData.status}
|
||||
onChange={(e) => setFormData({ ...formData, status: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="AVAILABLE">Verfügbar</option>
|
||||
<option value="IN_USE">Im Einsatz</option>
|
||||
<option value="MAINTENANCE">Wartung</option>
|
||||
<option value="DAMAGED">Beschädigt</option>
|
||||
<option value="RESERVED">Reserviert</option>
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4">Details</h3>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Name/Bezeichnung</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="text"
|
||||
value={formData.name}
|
||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.name}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Typ</label>
|
||||
{editing ? (
|
||||
<select
|
||||
value={formData.type}
|
||||
onChange={(e) => setFormData({ ...formData, type: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
>
|
||||
<option value="PRINTER">Drucker</option>
|
||||
<option value="CARPET">Roter Teppich</option>
|
||||
<option value="VIP_BARRIER">VIP Absperrband</option>
|
||||
<option value="ACCESSORIES_KIT">Accessoires-Koffer</option>
|
||||
<option value="PRINTER_PAPER">Druckerpapier</option>
|
||||
<option value="TRIPOD">Stativ</option>
|
||||
<option value="OTHER">Sonstiges</option>
|
||||
</select>
|
||||
) : (
|
||||
<p className="text-white">{getTypeLabel(equipment.type)}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{equipment.brand && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Hersteller</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="text"
|
||||
value={formData.brand || ''}
|
||||
onChange={(e) => setFormData({ ...formData, brand: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.brand}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{equipment.model && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Modell</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="text"
|
||||
value={formData.model || ''}
|
||||
onChange={(e) => setFormData({ ...formData, model: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.model}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{equipment.serialNumber && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Seriennummer</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="text"
|
||||
value={formData.serialNumber || ''}
|
||||
onChange={(e) => setFormData({ ...formData, serialNumber: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.serialNumber}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Anzahl</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="number"
|
||||
value={formData.quantity}
|
||||
onChange={(e) => setFormData({ ...formData, quantity: parseInt(e.target.value) })}
|
||||
min="1"
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.quantity}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{(equipment.currentStock !== null || equipment.minStockLevel !== null || editing) && (
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4">Bestandsverwaltung</h3>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Aktueller Bestand</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="number"
|
||||
value={formData.currentStock || ''}
|
||||
onChange={(e) => setFormData({ ...formData, currentStock: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.currentStock || '-'}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Mindestbestand</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="number"
|
||||
value={formData.minStockLevel || ''}
|
||||
onChange={(e) => setFormData({ ...formData, minStockLevel: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-white">{equipment.minStockLevel || '-'}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{equipment.currentStock !== null && equipment.minStockLevel !== null && equipment.currentStock < equipment.minStockLevel && (
|
||||
<div className="mt-4 bg-yellow-500/20 border border-yellow-500/50 text-yellow-400 px-4 py-3 rounded-lg">
|
||||
⚠️ Niedriger Bestand! Nachbestellen erforderlich.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{equipment.notes && (
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4">Notizen</h3>
|
||||
{editing ? (
|
||||
<textarea
|
||||
value={formData.notes || ''}
|
||||
onChange={(e) => setFormData({ ...formData, notes: e.target.value })}
|
||||
rows={4}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : (
|
||||
<p className="text-gray-300 whitespace-pre-wrap">{equipment.notes}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{equipment.bookingEquipment && equipment.bookingEquipment.length > 0 && (
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4 flex items-center gap-2">
|
||||
<FiCalendar /> Buchungen
|
||||
</h3>
|
||||
<div className="space-y-3">
|
||||
{equipment.bookingEquipment.map((be: any) => (
|
||||
<Link
|
||||
key={be.id}
|
||||
href={`/dashboard/bookings/${be.booking.id}`}
|
||||
className="block p-4 bg-gray-700/50 border border-gray-600 rounded-lg hover:bg-gray-700 hover:border-gray-500 transition-all"
|
||||
>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-semibold text-white">{be.booking.customerName}</p>
|
||||
<p className="text-sm text-gray-400">{be.booking.eventCity}</p>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<p className="text-sm text-gray-400">{formatDate(be.booking.eventDate)}</p>
|
||||
<p className="text-xs text-gray-500">Menge: {be.quantity}</p>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4 flex items-center gap-2">
|
||||
<FiMapPin /> Standort
|
||||
</h3>
|
||||
{editing ? (
|
||||
<select
|
||||
value={formData.locationId || ''}
|
||||
onChange={(e) => setFormData({ ...formData, locationId: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">Kein Standort</option>
|
||||
{locations.map((loc) => (
|
||||
<option key={loc.id} value={loc.id}>{loc.name}</option>
|
||||
))}
|
||||
</select>
|
||||
) : equipment.location ? (
|
||||
<div>
|
||||
<p className="text-white font-semibold">{equipment.location.name}</p>
|
||||
<p className="text-sm text-gray-400">{equipment.location.city}</p>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-400">Kein Standort zugewiesen</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(equipment.project || editing) && (
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4 flex items-center gap-2">
|
||||
<FiPackage /> Projekt
|
||||
</h3>
|
||||
{editing ? (
|
||||
<select
|
||||
value={formData.projectId || ''}
|
||||
onChange={(e) => setFormData({ ...formData, projectId: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">Kein Projekt</option>
|
||||
{projects.map((proj) => (
|
||||
<option key={proj.id} value={proj.id}>{proj.name}</option>
|
||||
))}
|
||||
</select>
|
||||
) : equipment.project ? (
|
||||
<div>
|
||||
<p className="text-white font-semibold">{equipment.project.name}</p>
|
||||
{equipment.project.description && (
|
||||
<p className="text-sm text-gray-400 mt-2">{equipment.project.description}</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-400">Kein Projekt zugewiesen</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(equipment.purchaseDate || equipment.purchasePrice || editing) && (
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4">Kaufinformationen</h3>
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Kaufdatum</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="date"
|
||||
value={formData.purchaseDate ? new Date(formData.purchaseDate).toISOString().split('T')[0] : ''}
|
||||
onChange={(e) => setFormData({ ...formData, purchaseDate: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : equipment.purchaseDate ? (
|
||||
<p className="text-white">{formatDate(equipment.purchaseDate)}</p>
|
||||
) : (
|
||||
<p className="text-gray-400">-</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-1">Kaufpreis</label>
|
||||
{editing ? (
|
||||
<input
|
||||
type="number"
|
||||
step="0.01"
|
||||
value={formData.purchasePrice || ''}
|
||||
onChange={(e) => setFormData({ ...formData, purchasePrice: e.target.value })}
|
||||
className="w-full px-3 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500"
|
||||
/>
|
||||
) : equipment.purchasePrice ? (
|
||||
<p className="text-white text-2xl font-bold">{equipment.purchasePrice}€</p>
|
||||
) : (
|
||||
<p className="text-gray-400">-</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6">
|
||||
<h3 className="text-xl font-bold text-white mb-4">Erstellt</h3>
|
||||
<p className="text-gray-400">{formatDate(equipment.createdAt)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
332
app/dashboard/inventory/new/page.tsx
Normal file
332
app/dashboard/inventory/new/page.tsx
Normal file
@@ -0,0 +1,332 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import DashboardSidebar from '@/components/DashboardSidebar';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { FiPackage, FiArrowLeft, FiSave } from 'react-icons/fi';
|
||||
import Link from 'next/link';
|
||||
|
||||
export default function NewEquipmentPage() {
|
||||
const router = useRouter();
|
||||
const { data: session } = useSession();
|
||||
const [locations, setLocations] = useState<any[]>([]);
|
||||
const [projects, setProjects] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
name: '',
|
||||
type: 'PRINTER',
|
||||
brand: '',
|
||||
model: '',
|
||||
serialNumber: '',
|
||||
quantity: 1,
|
||||
status: 'AVAILABLE',
|
||||
locationId: '',
|
||||
projectId: '',
|
||||
notes: '',
|
||||
purchaseDate: '',
|
||||
purchasePrice: '',
|
||||
minStockLevel: '',
|
||||
currentStock: '',
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
fetchLocationsAndProjects();
|
||||
}, []);
|
||||
|
||||
const fetchLocationsAndProjects = async () => {
|
||||
try {
|
||||
const [locRes, projRes] = await Promise.all([
|
||||
fetch('/api/locations'),
|
||||
fetch('/api/projects'),
|
||||
]);
|
||||
|
||||
if (locRes.ok) {
|
||||
const locData = await locRes.json();
|
||||
setLocations(locData.locations || []);
|
||||
}
|
||||
|
||||
if (projRes.ok) {
|
||||
const projData = await projRes.json();
|
||||
setProjects(projData.projects || []);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching data:', err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError('');
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/inventory', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
...formData,
|
||||
quantity: parseInt(formData.quantity.toString()),
|
||||
purchasePrice: formData.purchasePrice ? parseFloat(formData.purchasePrice) : null,
|
||||
minStockLevel: formData.minStockLevel ? parseInt(formData.minStockLevel.toString()) : null,
|
||||
currentStock: formData.currentStock ? parseInt(formData.currentStock.toString()) : null,
|
||||
locationId: formData.locationId || null,
|
||||
projectId: formData.projectId || null,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(data.error || 'Fehler beim Erstellen');
|
||||
}
|
||||
|
||||
alert('Equipment erfolgreich erstellt!');
|
||||
router.push('/dashboard/inventory');
|
||||
} catch (err: any) {
|
||||
setError(err.message);
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (!session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
||||
<div className="flex">
|
||||
<DashboardSidebar user={session.user} />
|
||||
|
||||
<main className="flex-1 p-8">
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<div className="mb-8">
|
||||
<Link href="/dashboard/inventory" className="text-sm text-gray-400 hover:text-gray-300 mb-2 inline-flex items-center gap-2 transition-colors">
|
||||
<FiArrowLeft /> Zurück zum Inventar
|
||||
</Link>
|
||||
<h2 className="text-3xl font-bold text-white mt-2">Neues Equipment anlegen</h2>
|
||||
<p className="text-gray-400 mt-1">Equipment zum Inventar hinzufügen</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl shadow-sm p-6 space-y-6">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white mb-4">Grunddaten</h3>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="col-span-2">
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Name/Bezeichnung</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.name}
|
||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||
required
|
||||
placeholder="z.B. Citizen CX-02 #1"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Typ</label>
|
||||
<select
|
||||
value={formData.type}
|
||||
onChange={(e) => setFormData({ ...formData, type: e.target.value })}
|
||||
required
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="PRINTER">Drucker</option>
|
||||
<option value="CARPET">Roter Teppich</option>
|
||||
<option value="VIP_BARRIER">VIP Absperrband</option>
|
||||
<option value="ACCESSORIES_KIT">Accessoires-Koffer</option>
|
||||
<option value="PRINTER_PAPER">Druckerpapier</option>
|
||||
<option value="TRIPOD">Stativ</option>
|
||||
<option value="OTHER">Sonstiges</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Status</label>
|
||||
<select
|
||||
value={formData.status}
|
||||
onChange={(e) => setFormData({ ...formData, status: e.target.value })}
|
||||
required
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="AVAILABLE">Verfügbar</option>
|
||||
<option value="IN_USE">Im Einsatz</option>
|
||||
<option value="MAINTENANCE">Wartung</option>
|
||||
<option value="DAMAGED">Beschädigt</option>
|
||||
<option value="RESERVED">Reserviert</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Hersteller</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.brand}
|
||||
onChange={(e) => setFormData({ ...formData, brand: e.target.value })}
|
||||
placeholder="z.B. Citizen"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Modell</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.model}
|
||||
onChange={(e) => setFormData({ ...formData, model: e.target.value })}
|
||||
placeholder="z.B. CX-02"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Seriennummer</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.serialNumber}
|
||||
onChange={(e) => setFormData({ ...formData, serialNumber: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Anzahl</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.quantity}
|
||||
onChange={(e) => setFormData({ ...formData, quantity: parseInt(e.target.value) })}
|
||||
required
|
||||
min="1"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white mb-4">Zuordnung</h3>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Standort (optional)</label>
|
||||
<select
|
||||
value={formData.locationId}
|
||||
onChange={(e) => setFormData({ ...formData, locationId: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">Kein Standort</option>
|
||||
{locations.map((loc) => (
|
||||
<option key={loc.id} value={loc.id}>{loc.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Projekt (optional)</label>
|
||||
<select
|
||||
value={formData.projectId}
|
||||
onChange={(e) => setFormData({ ...formData, projectId: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
>
|
||||
<option value="">Kein Projekt</option>
|
||||
{projects.map((proj) => (
|
||||
<option key={proj.id} value={proj.id}>{proj.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white mb-4">Bestandsverwaltung (für Verbrauchsmaterial)</h3>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Aktueller Bestand</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.currentStock}
|
||||
onChange={(e) => setFormData({ ...formData, currentStock: e.target.value })}
|
||||
placeholder="Nur für Verbrauchsmaterial"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Mindestbestand</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.minStockLevel}
|
||||
onChange={(e) => setFormData({ ...formData, minStockLevel: e.target.value })}
|
||||
placeholder="Warnung bei Unterschreitung"
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-500"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-white mb-4">Kaufinformationen (optional)</h3>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Kaufdatum</label>
|
||||
<input
|
||||
type="date"
|
||||
value={formData.purchaseDate}
|
||||
onChange={(e) => setFormData({ ...formData, purchaseDate: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Kaufpreis (€)</label>
|
||||
<input
|
||||
type="number"
|
||||
step="0.01"
|
||||
value={formData.purchasePrice}
|
||||
onChange={(e) => setFormData({ ...formData, purchasePrice: e.target.value })}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-300 mb-2">Notizen</label>
|
||||
<textarea
|
||||
value={formData.notes}
|
||||
onChange={(e) => setFormData({ ...formData, notes: e.target.value })}
|
||||
rows={4}
|
||||
className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="bg-red-500/20 border border-red-500/50 text-red-400 px-4 py-3 rounded-lg">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-4 pt-4 border-t border-gray-700">
|
||||
<Link
|
||||
href="/dashboard/inventory"
|
||||
className="flex-1 px-4 py-3 bg-gray-700 text-gray-300 rounded-lg font-semibold text-center hover:bg-gray-600 transition-colors"
|
||||
>
|
||||
Abbrechen
|
||||
</Link>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="flex-1 flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-red-600 to-pink-600 text-white rounded-lg font-semibold hover:from-red-700 hover:to-pink-700 transition-all shadow-lg disabled:opacity-50"
|
||||
>
|
||||
<FiSave /> {loading ? 'Wird erstellt...' : 'Equipment anlegen'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
230
app/dashboard/inventory/page.tsx
Normal file
230
app/dashboard/inventory/page.tsx
Normal file
@@ -0,0 +1,230 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import DashboardSidebar from '@/components/DashboardSidebar';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { FiPackage, FiAlertCircle, FiPlus } from 'react-icons/fi';
|
||||
|
||||
export default function InventoryPage() {
|
||||
const router = useRouter();
|
||||
const { data: session } = useSession();
|
||||
const [equipment, setEquipment] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [typeFilter, setTypeFilter] = useState('ALL');
|
||||
const [statusFilter, setStatusFilter] = useState('ALL');
|
||||
const [locationFilter, setLocationFilter] = useState('ALL');
|
||||
|
||||
useEffect(() => {
|
||||
fetchEquipment();
|
||||
}, []);
|
||||
|
||||
const fetchEquipment = async () => {
|
||||
try {
|
||||
const res = await fetch('/api/inventory');
|
||||
const data = await res.json();
|
||||
setEquipment(data.equipment || []);
|
||||
} catch (error) {
|
||||
console.error('Fetch error:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const filteredEquipment = equipment.filter((item) => {
|
||||
if (typeFilter !== 'ALL' && item.type !== typeFilter) return false;
|
||||
if (statusFilter !== 'ALL' && item.status !== statusFilter) return false;
|
||||
if (locationFilter !== 'ALL' && item.locationId !== locationFilter) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
const getTypeLabel = (type: string) => {
|
||||
const labels: Record<string, string> = {
|
||||
PRINTER: 'Drucker',
|
||||
CARPET: 'Roter Teppich',
|
||||
VIP_BARRIER: 'VIP-Absperrung',
|
||||
ACCESSORIES_KIT: 'Accessoires-Koffer',
|
||||
PRINTER_PAPER: 'Druckerpapier',
|
||||
TRIPOD: 'Stativ',
|
||||
OTHER: 'Sonstiges',
|
||||
};
|
||||
return labels[type] || type;
|
||||
};
|
||||
|
||||
const getStatusBadge = (status: string) => {
|
||||
const styles: Record<string, string> = {
|
||||
AVAILABLE: 'bg-green-500/20 text-green-400 border-green-500/50',
|
||||
IN_USE: 'bg-blue-500/20 text-blue-400 border-blue-500/50',
|
||||
MAINTENANCE: 'bg-yellow-500/20 text-yellow-400 border-yellow-500/50',
|
||||
DAMAGED: 'bg-red-500/20 text-red-400 border-red-500/50',
|
||||
RESERVED: 'bg-purple-500/20 text-purple-400 border-purple-500/50',
|
||||
};
|
||||
return styles[status] || 'bg-gray-500/20 text-gray-400 border-gray-500/50';
|
||||
};
|
||||
|
||||
const getStatusLabel = (status: string) => {
|
||||
const labels: Record<string, string> = {
|
||||
AVAILABLE: 'Verfügbar',
|
||||
IN_USE: 'Im Einsatz',
|
||||
MAINTENANCE: 'Wartung',
|
||||
DAMAGED: 'Defekt',
|
||||
RESERVED: 'Reserviert',
|
||||
};
|
||||
return labels[status] || status;
|
||||
};
|
||||
|
||||
const stats = {
|
||||
total: equipment.length,
|
||||
available: equipment.filter((e) => e.status === 'AVAILABLE').length,
|
||||
inUse: equipment.filter((e) => e.status === 'IN_USE').length,
|
||||
lowStock: equipment.filter((e) => e.currentStock && e.minStockLevel && e.currentStock < e.minStockLevel).length,
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
||||
<div className="flex">
|
||||
<DashboardSidebar user={session?.user} />
|
||||
<div className="flex-1 p-8">
|
||||
<p className="text-gray-300">Lädt...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
|
||||
<div className="flex">
|
||||
<DashboardSidebar user={session?.user} />
|
||||
<main className="flex-1 p-8">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
<div className="flex justify-between items-center mb-8">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold bg-gradient-to-r from-purple-400 to-pink-500 bg-clip-text text-transparent">
|
||||
Inventar
|
||||
</h1>
|
||||
<p className="text-gray-400 mt-1">Verwalten Sie Drucker, Zubehör & Verbrauchsmaterial</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => router.push('/dashboard/inventory/new')}
|
||||
className="px-6 py-3 bg-gradient-to-r from-purple-600 to-pink-600 text-white rounded-lg hover:from-purple-700 hover:to-pink-700 font-semibold shadow-lg flex items-center gap-2"
|
||||
>
|
||||
<FiPlus /> Neues Equipment
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 p-6 rounded-xl">
|
||||
<p className="text-sm text-gray-400">Gesamt</p>
|
||||
<p className="text-3xl font-bold text-white mt-2">{stats.total}</p>
|
||||
</div>
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 p-6 rounded-xl">
|
||||
<p className="text-sm text-gray-400">Verfügbar</p>
|
||||
<p className="text-3xl font-bold text-green-400 mt-2">{stats.available}</p>
|
||||
</div>
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 p-6 rounded-xl">
|
||||
<p className="text-sm text-gray-400">Im Einsatz</p>
|
||||
<p className="text-3xl font-bold text-blue-400 mt-2">{stats.inUse}</p>
|
||||
</div>
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 p-6 rounded-xl">
|
||||
<p className="text-sm text-gray-400">Niedriger Bestand</p>
|
||||
<p className="text-3xl font-bold text-yellow-400 mt-2">{stats.lowStock}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Filters */}
|
||||
<div className="bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 rounded-xl p-6 mb-6">
|
||||
<div className="flex gap-4">
|
||||
<select
|
||||
value={typeFilter}
|
||||
onChange={(e) => setTypeFilter(e.target.value)}
|
||||
className="px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-purple-500"
|
||||
>
|
||||
<option value="ALL">Alle Typen</option>
|
||||
<option value="PRINTER">Drucker</option>
|
||||
<option value="CARPET">Roter Teppich</option>
|
||||
<option value="VIP_BARRIER">VIP-Absperrung</option>
|
||||
<option value="ACCESSORIES_KIT">Accessoires-Koffer</option>
|
||||
<option value="PRINTER_PAPER">Druckerpapier</option>
|
||||
<option value="TRIPOD">Stativ</option>
|
||||
<option value="OTHER">Sonstiges</option>
|
||||
</select>
|
||||
|
||||
<select
|
||||
value={statusFilter}
|
||||
onChange={(e) => setStatusFilter(e.target.value)}
|
||||
className="px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-purple-500"
|
||||
>
|
||||
<option value="ALL">Alle Status</option>
|
||||
<option value="AVAILABLE">Verfügbar</option>
|
||||
<option value="IN_USE">Im Einsatz</option>
|
||||
<option value="MAINTENANCE">Wartung</option>
|
||||
<option value="DAMAGED">Defekt</option>
|
||||
<option value="RESERVED">Reserviert</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Equipment Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredEquipment.map((item) => (
|
||||
<div
|
||||
key={item.id}
|
||||
onClick={() => router.push(`/dashboard/inventory/${item.id}`)}
|
||||
className="bg-gradient-to-br from-gray-800 to-gray-900 rounded-lg shadow-xl p-6 hover:shadow-2xl transition-all cursor-pointer border border-gray-700 hover:border-purple-500"
|
||||
>
|
||||
<div className="flex justify-between items-start mb-4">
|
||||
<div>
|
||||
<h3 className="text-lg font-bold text-white">{item.name}</h3>
|
||||
<p className="text-sm text-gray-400">{getTypeLabel(item.type)}</p>
|
||||
{item.brand && item.model && (
|
||||
<p className="text-xs text-gray-500 mt-1">{item.brand} {item.model}</p>
|
||||
)}
|
||||
</div>
|
||||
<span className={`px-3 py-1 text-xs font-semibold rounded-full border ${getStatusBadge(item.status)}`}>
|
||||
{getStatusLabel(item.status)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="text-sm text-gray-400 space-y-2">
|
||||
{item.location && (
|
||||
<p><span className="font-medium text-gray-300">Standort:</span> {item.location.name}</p>
|
||||
)}
|
||||
{item.project && (
|
||||
<p><span className="font-medium text-gray-300">Projekt:</span> {item.project.name}</p>
|
||||
)}
|
||||
{item.quantity > 1 && (
|
||||
<p><span className="font-medium text-gray-300">Menge:</span> {item.quantity}x</p>
|
||||
)}
|
||||
{item.serialNumber && (
|
||||
<p><span className="font-medium text-gray-300">SN:</span> {item.serialNumber}</p>
|
||||
)}
|
||||
{item.currentStock !== null && item.minStockLevel !== null && (
|
||||
<div className="pt-2 border-t border-gray-700">
|
||||
<p className="font-medium text-gray-300 flex items-center gap-2">
|
||||
Bestand: {item.currentStock} / {item.minStockLevel}
|
||||
{item.currentStock < item.minStockLevel && (
|
||||
<FiAlertCircle className="text-yellow-400" />
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{filteredEquipment.length === 0 && (
|
||||
<div className="text-center py-12">
|
||||
<FiPackage className="text-6xl text-gray-600 mx-auto mb-4" />
|
||||
<p className="text-gray-400">Kein Equipment gefunden</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user