From 9d59024fed8c6e6cf9a8fce97c5d48c5f85e32d8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 19 Jan 2026 17:17:31 +0000 Subject: [PATCH] feat: Add edit button and modal for battery groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can now edit battery group counts and notes via an edit button on each battery card. The edit modal allows updating available count, charging count, and notes. Changes: - Create EditBatteryModal component - Add edit button (pencil icon) to BatteryCard - Uses existing PATCH /api/batteries/[id] endpoint 🤖 Generated with [Qoder][https://qoder.com] --- src/components/battery/BatteryCard.tsx | 19 ++- src/components/battery/EditBatteryModal.tsx | 137 ++++++++++++++++++++ 2 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 src/components/battery/EditBatteryModal.tsx diff --git a/src/components/battery/BatteryCard.tsx b/src/components/battery/BatteryCard.tsx index af3c2f2..effcc8d 100644 --- a/src/components/battery/BatteryCard.tsx +++ b/src/components/battery/BatteryCard.tsx @@ -9,7 +9,8 @@ import { Input } from '@/components/ui/Input'; import { Select } from '@/components/ui/Select'; import { useToast } from '@/components/ui/Toast'; import { useRouter } from 'next/navigation'; -import { Battery, BatteryCharging, Monitor, Trash2, ArrowRight } from 'lucide-react'; +import { Battery, BatteryCharging, Monitor, Trash2, ArrowRight, Pencil } from 'lucide-react'; +import { EditBatteryModal } from './EditBatteryModal'; interface Device { id: number; @@ -36,6 +37,7 @@ export function BatteryCard({ battery, devices }: BatteryCardProps) { const router = useRouter(); const { showToast } = useToast(); const [actionModal, setActionModal] = useState<'charge' | 'available' | 'assign' | 'delete' | null>(null); + const [showEditModal, setShowEditModal] = useState(false); const [count, setCount] = useState('1'); const [deviceId, setDeviceId] = useState(''); const [loading, setLoading] = useState(false); @@ -148,6 +150,14 @@ export function BatteryCard({ battery, devices }: BatteryCardProps) {

Total: {total} batteries

+ + + + } + > +
+
+

+ + {battery.brandName} {battery.typeName} ({battery.chemistryName}) + +

+ {battery.inUseCount > 0 && ( +

+ {battery.inUseCount} currently in use (managed via device assignments) +

+ )} +
+ +
+ setFormData({ ...formData, availableCount: e.target.value })} + /> + setFormData({ ...formData, chargingCount: e.target.value })} + /> +
+ + setFormData({ ...formData, notes: e.target.value })} + placeholder="Any additional notes..." + /> +
+ + ); +}