CentercodeDitto
DittoPorygonAPI

InsightList

Collaborative forum view for insights

Overview

InsightList provides a forum-style view for browsing and interacting with insights. Designed for participants to vote, add themselves as affected users, and engage with the community. Includes filtering, sorting, and pagination.

Features

  • Card-based layout optimized for browsing
  • Voting with optimistic updates
  • "This affects me too" action for adding submitters
  • Filter by type, status, and search
  • Sort by impact score, activity, date, or submitter count
  • Submitter avatar stack with tooltips
  • Responsive design (stacks on mobile)
  • Pagination controls

Layout Structure

┌─────────────────────────────────────────────────┐
│ [Search...] [Type ▼] [Status ▼] [Sort ▼]       │
├─────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────┐ │
│ │ [▲]  Bug Report | Open                      │ │
│ │ 42   Login crashes on iOS                   │ │
│ │ [▼]  Summary text here...                   │ │
│ │      💬 12  👥 ○○○+5  2 hours ago           │ │
│ │      [This affects me] [View →]             │ │
│ └─────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────┐ │
│ │ ...                                         │ │
│ └─────────────────────────────────────────────┘ │
│ [< 1 2 3 ... 10 >]                             │
└─────────────────────────────────────────────────┘

Examples

Vote Buttons

Upvote/downvote with optimistic updates

Vertical (default)

+42

Neutral

0

Downvoted

-5

Horizontal

+12

Small

+8

Disabled

+15

Submitter Badges

Avatar stack with overflow count

Single submitter

AC

Three submitters

AC
BS
CD

With overflow (+2)

AC
BS
CD
+2

maxDisplay=4

AC
BS
CD
DL
+1

Hover over avatars to see user names and original submitter designation.

Two Views Pattern

The Insights page has two modes based on user role:

┌─────────────────────────────────────────────┐
│  [Management] [Collaborate]  ← Toggle       │
└─────────────────────────────────────────────┘

Management (InsightManagementTable):
- For Owners/Builders
- Table view with bulk actions
- Status management, merging

Collaborate (InsightList):
- For all project members
- Forum-style card view
- Voting, "This affects me"
- Participants ONLY see this view

Props Reference

InsightList Props

PropTypeDefaultDescription
projectIdstring-Project ID for API calls
projectSlugstring-Project slug for links
programSlugstring-Program slug for links
insightsInsight[]-Array of insights to display
totalnumber-Total count for pagination
insightTypesInsightTypeOption[]-Available types for filtering
currentUserIdstring-Current user's ID
isAdminbooleanfalseWhether user is Owner/Builder
pageSizenumber10Items per page
userVotesRecord<string, 1 | -1>-Map of user's votes by insight ID

InsightVoteButtons Props

PropTypeDefaultDescription
voteScorenumber-Current vote score
userVote1 | -1 | null-User's current vote
onVote(value: 1 | -1) => Promise<void>-Vote callback
verticalbooleantrueVertical or horizontal layout
size"sm" | "md""md"Size variant
disabledbooleanfalseDisable voting

InsightSubmitterBadges Props

PropTypeDefaultDescription
submittersInsightSubmitter[]-Array of submitter objects with user info
maxDisplaynumber3Max avatars to show before +N overflow

Usage

import { InsightList } from '@/features/insights';

// Forum-style view for participants
<InsightList
  projectId={projectId}
  projectSlug={projectSlug}
  programSlug={programSlug}
  insights={insights}
  total={total}
  insightTypes={insightTypes}
  currentUserId={userId}
  isAdmin={false}
  pageSize={10}
  userVotes={userVotes}
/>

// Sub-components can be used independently:

// Vote buttons with optimistic updates
<InsightVoteButtons
  voteScore={42}
  userVote={1}
  onVote={(value) => handleVote(value)}
  vertical
  size="md"
/>

// Submitter avatar stack
<InsightSubmitterBadges
  submitters={insight.submitters}
  maxDisplay={3}
/>