@@ -14,7 +14,7 @@ import {
1414 CollisionDetection ,
1515 rectIntersection ,
1616} from "@dnd-kit/core" ;
17- import { Checklist , KanbanStatus } from "@/app/_types" ;
17+ import { Checklist , Item , KanbanStatus } from "@/app/_types" ;
1818import { KanbanColumn } from "./KanbanColumn" ;
1919import { KanbanCard } from "./KanbanCard" ;
2020import { ChecklistHeading } from "../Checklists/Parts/Common/ChecklistHeading" ;
@@ -48,6 +48,17 @@ interface KanbanBoardProps {
4848 onUpdate : ( updatedChecklist : Checklist ) => void ;
4949}
5050
51+ const _findItemById = ( items : Item [ ] , itemId : string ) : Item | null => {
52+ for ( const item of items ) {
53+ if ( item . id === itemId ) return item ;
54+ if ( item . children ) {
55+ const found = _findItemById ( item . children , itemId ) ;
56+ if ( found ) return found ;
57+ }
58+ }
59+ return null ;
60+ } ;
61+
5162export const Kanban = ( { checklist, onUpdate } : KanbanBoardProps ) => {
5263 const t = useTranslations ( ) ;
5364 const [ isClient , setIsClient ] = useState ( false ) ;
@@ -57,6 +68,7 @@ export const Kanban = ({ checklist, onUpdate }: KanbanBoardProps) => {
5768 const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
5869 const [ priorityFilter , setPriorityFilter ] = useState ( "" ) ;
5970 const [ assigneeFilter , setAssigneeFilter ] = useState ( "" ) ;
71+ const [ detailItemId , setDetailItemId ] = useState < string | null > ( null ) ;
6072 const [ calendarSelectedItem , setCalendarSelectedItem ] = useState <
6173 import ( "@/app/_types" ) . Item | null
6274 > ( null ) ;
@@ -134,6 +146,10 @@ export const Kanban = ({ checklist, onUpdate }: KanbanBoardProps) => {
134146 ) ;
135147
136148 const archivedItems = localChecklist . items . filter ( ( item ) => item . isArchived ) ;
149+ const detailItem = useMemo (
150+ ( ) => ( detailItemId ? _findItemById ( localChecklist . items , detailItemId ) : null ) ,
151+ [ detailItemId , localChecklist . items ] ,
152+ ) ;
137153
138154 const handleUnarchive = async ( itemId : string ) => {
139155 const formData = new FormData ( ) ;
@@ -216,6 +232,7 @@ export const Kanban = ({ checklist, onUpdate }: KanbanBoardProps) => {
216232 checklistId = { localChecklist . id }
217233 category = { localChecklist . category || "Uncategorized" }
218234 onUpdate = { handleItemUpdate }
235+ onOpenDetail = { ( item ) => setDetailItemId ( item . id ) }
219236 isShared = { isShared }
220237 statusColor = { statuses . find ( ( s ) => s . id === column . id ) ?. color }
221238 statuses = { statuses }
@@ -415,6 +432,7 @@ export const Kanban = ({ checklist, onUpdate }: KanbanBoardProps) => {
415432 checklistId = { localChecklist . id }
416433 category = { localChecklist . category || "Uncategorized" }
417434 onUpdate = { refreshChecklist }
435+ onOpenDetail = { ( ) => { } }
418436 isShared = { isShared }
419437 statuses = { statuses }
420438 />
@@ -445,6 +463,18 @@ export const Kanban = ({ checklist, onUpdate }: KanbanBoardProps) => {
445463 />
446464 ) }
447465
466+ { detailItem && (
467+ < KanbanCardDetail
468+ checklist = { localChecklist }
469+ item = { detailItem }
470+ isOpen = { ! ! detailItem }
471+ onClose = { ( ) => setDetailItemId ( null ) }
472+ onUpdate = { handleItemUpdate }
473+ checklistId = { localChecklist . id }
474+ category = { localChecklist . category || "Uncategorized" }
475+ />
476+ ) }
477+
448478 { showBulkPasteModal && (
449479 < BulkPasteModal
450480 isOpen = { showBulkPasteModal }
0 commit comments