{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feedback-03",
  "description": "The latest reviews with their rating and source, flagging low ratings still waiting for a reply.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/feedback.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/team.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/feedback/feedback-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { StarRating } from '@/registry/components/dashboardblocks/feedback'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport { PersonAvatar } from '@/registry/components/dashboardblocks/team'\nimport { formatRelativeTime } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Review {\n  author: string\n  avatar?: string\n  date: Date\n  id: string\n  rating: number\n  replied?: boolean\n  source: string\n  text: string\n}\n\ninterface Feedback3Props extends BlockStateProps {\n  description: string\n  /** Pass a fixed date, so the block renders the same on the server and in the browser. */\n  now: Date\n  /** Newest first. Leave out, or pass none, to show the empty state. */\n  reviews?: Review[]\n  title: string\n}\n\nconst NOW = new Date(Date.UTC(2026, 8, 26, 12))\nconst daysAgo = (days: number) => new Date(NOW.getTime() - days * 86_400_000)\n\nconst exampleProps: Feedback3Props = {\n  description: 'The latest from every source, newest first.',\n  now: NOW,\n  reviews: [\n    {\n      author: 'Priya Raman',\n      avatar: '/images/avatar-16.webp',\n      date: daysAgo(0.2),\n      id: 'r1',\n      rating: 5,\n      source: 'App Store',\n      text: 'The new dashboard is so much faster. Setting up reports took minutes, not an afternoon.',\n    },\n    {\n      author: 'Marcus Webb',\n      date: daysAgo(0.8),\n      id: 'r2',\n      rating: 2,\n      replied: false,\n      source: 'G2',\n      text: 'Pricing jumped at renewal with no warning. The product is fine but this felt sneaky.',\n    },\n    {\n      author: 'Lena Fischer',\n      date: daysAgo(1.6),\n      id: 'r3',\n      rating: 4,\n      source: 'Play Store',\n      text: 'Love the offline mode. Sync occasionally takes a while after reconnecting.',\n    },\n    {\n      author: 'Tomás Alvarez',\n      avatar: '/images/avatar-06.webp',\n      date: daysAgo(3),\n      id: 'r4',\n      rating: 1,\n      replied: true,\n      source: 'Support survey',\n      text: 'Export to CSV has been broken for a week and nobody has told us when it will be fixed.',\n    },\n  ],\n  title: 'Recent reviews',\n}\n\nconst Feedback3 = (props: Feedback3Props) => {\n  const { description, now, reviews = [], errorMessage, status, title } = props\n  const state = getBlockState(status, reviews)\n  const needsReply = reviews.filter(\n    (review) => review.rating <= 2 && !review.replied,\n  ).length\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-3'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>\n                {description}{' '}\n                <BlockReady>\n                  {needsReply === 0\n                    ? 'Every low rating has a reply.'\n                    : `${needsReply} low ${needsReply === 1 ? 'rating is' : 'ratings are'} waiting for a reply.`}\n                </BlockReady>\n              </p>\n            </header>\n            {state && (\n              <div className='border-t'>\n                <BlockStateRows rows={4} />\n              </div>\n            )}\n            {!state && (\n              <ul className='flex flex-col divide-y border-t'>\n                {reviews.map((review) => (\n                  <li key={review.id} className='flex gap-3 py-3 last:pb-0'>\n                    <PersonAvatar\n                      person={{ avatar: review.avatar, name: review.author }}\n                      size='sm'\n                    />\n                    <div className='flex min-w-0 flex-1 flex-col gap-1'>\n                      <div className='flex flex-wrap items-center gap-x-2 gap-y-0.5'>\n                        <span className='text-sm font-medium'>{review.author}</span>\n                        <StarRating className='[&_svg]:size-3.5' value={review.rating} />\n                        {review.rating <= 2 && (\n                          <StatusLabel\n                            className='text-xs'\n                            tone={review.replied ? 'neutral' : 'warning'}\n                          >\n                            {review.replied ? 'Replied' : 'Needs a reply'}\n                          </StatusLabel>\n                        )}\n                      </div>\n                      <p className='text-sm text-pretty'>{review.text}</p>\n                      <Details className='text-muted-foreground text-xs'>\n                        {review.source}\n                        <time dateTime={review.date.toISOString()}>\n                          {formatRelativeTime(review.date, now, { style: 'long' })}\n                        </time>\n                      </Details>\n                    </div>\n                  </li>\n                ))}\n              </ul>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport {\n  Feedback3,\n  exampleProps as feedback3ExampleProps,\n  type Feedback3Props,\n  type Review,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/feedback/feedback-03.tsx"
    }
  ],
  "meta": {
    "shows": "The latest reviews with their rating and source, flagging low ratings still waiting for a reply.",
    "size": "half",
    "usedWith": [
      "feedback-01",
      "feedback-02"
    ],
    "component": "Feedback3",
    "props": "{ description: string; now: Date; reviews?: { author: string; avatar?: string; date: Date; id: string; rating: number; replied?: boolean; source: string; text: string }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
