From 97010a35f6f6d7be464f8856e03508fa1ea496bc Mon Sep 17 00:00:00 2001 From: Jurgis Sakalauskas Date: Sat, 18 Oct 2025 10:49:23 +0300 Subject: [PATCH] Add item status modal with note editing --- .../project-detail/item-status-modal.tsx | 133 ++++++++++++++++++ .../project-detail/project-detail-page.tsx | 63 ++++++++- .../project-items-desktop-table.tsx | 20 ++- .../project-items-mobile-list.tsx | 26 +++- .../project-detail/project-items-section.tsx | 4 + 5 files changed, 236 insertions(+), 10 deletions(-) create mode 100644 client/src/pages/project-detail/item-status-modal.tsx diff --git a/client/src/pages/project-detail/item-status-modal.tsx b/client/src/pages/project-detail/item-status-modal.tsx new file mode 100644 index 0000000..6112e80 --- /dev/null +++ b/client/src/pages/project-detail/item-status-modal.tsx @@ -0,0 +1,133 @@ +import { useEffect, useState } from 'react'; +import type { Item, ItemStatus } from '@shared/models/item'; + +interface ItemStatusModalProps { + isOpen: boolean; + item: Item | null; + onClose: () => void; + onSubmit: (payload: { status: ItemStatus; note: string | null }) => Promise; + isSubmitting: boolean; + errorMessage: string | null; +} + +export function ItemStatusModal({ + isOpen, + item, + onClose, + onSubmit, + isSubmitting, + errorMessage +}: ItemStatusModalProps) { + const [status, setStatus] = useState('active'); + const [note, setNote] = useState(''); + + useEffect(() => { + if (!isOpen || !item) { + return; + } + setStatus(item.status); + setNote(item.note ?? ''); + }, [isOpen, item]); + + if (!isOpen || !item) { + return null; + } + + const handleSubmit = async () => { + await onSubmit({ status, note: note.trim().length ? note : null }); + }; + + const isActive = status === 'active'; + + return ( +
{ + if (!isSubmitting) { + onClose(); + } + }} + > +
event.stopPropagation()} + > + + +
+
+

Item Status & Note

+

+ Update the activity state and note for {item.manufacturer ? `${item.manufacturer} ${item.model}` : item.model}. +

+
+ +
+ + +