From c495d29313da18bcac7eebd30df2079594669b79 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Thu, 30 Apr 2026 17:27:27 +0200 Subject: [PATCH] feat(backlog): migrate StoryPanel to store-driven + selectStory on click Removes storiesByPbi prop; reads from useBacklogStore. Card click now dispatches selectStory(id) + shows isSelected highlight. Edit moved to inline pencil button. page.tsx drops pbis/storiesByPbi props. Co-Authored-By: Claude Sonnet 4.6 --- app/(app)/products/[id]/page.tsx | 2 -- components/backlog/story-panel.tsx | 34 ++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/(app)/products/[id]/page.tsx b/app/(app)/products/[id]/page.tsx index e0db775..569fe81 100644 --- a/app/(app)/products/[id]/page.tsx +++ b/app/(app)/products/[id]/page.tsx @@ -137,13 +137,11 @@ export default async function ProductBacklogPage({ params, searchParams }: Props ({ id: p.id, code: p.code, title: p.title, priority: p.priority, description: p.description, created_at: p.created_at, status: pbiStatusToApi(p.status) }))} isDemo={isDemo} />, , isDemo: boolean } // --- Sortable story block --- function SortableStoryBlock({ story, - onClick, + isSelected, + onSelect, + onEdit, }: { story: Story - onClick: () => void + isSelected: boolean + onSelect: () => void + onEdit: () => void }) { const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: story.id, @@ -92,19 +96,33 @@ function SortableStoryBlock({ code={story.code} priority={story.priority} isDragging={isDragging} - onClick={onClick} + isSelected={isSelected} + onClick={onSelect} badge={ {STATUS_LABELS[story.status] ?? story.status} } + actions={ + + } /> ) } // --- Main component --- -export function StoryPanel({ productId, storiesByPbi, isDemo }: StoryPanelProps) { - const { selectedPbiId } = useSelectionStore() +export function StoryPanel({ productId, isDemo }: StoryPanelProps) { + const { selectedPbiId, selectedStoryId, selectStory } = useSelectionStore() + const storiesByPbi = useBacklogStore((s) => s.storiesByPbi) const { storyOrder, initStories, reorderStories, rollbackStories } = usePlannerStore() const [filterStatus, setFilterStatus] = useState(null) const [filterPriority, setFilterPriority] = useState(null) @@ -263,7 +281,9 @@ export function StoryPanel({ productId, storiesByPbi, isDemo }: StoryPanelProps) setStoryDialogState({ mode: 'edit', story, productId })} + isSelected={selectedStoryId === story.id} + onSelect={() => selectStory(story.id)} + onEdit={() => setStoryDialogState({ mode: 'edit', story, productId })} /> ))}