{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feedback-02",
  "description": "A diverging bar chart of negative and positive mentions for each topic, sorted by net sentiment, with the best and worst topic in a sentence.",
  "dependencies": [
    "recharts"
  ],
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/feedback.json",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/feedback/feedback-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateText,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  SentimentChart,\n  type SentimentTopic,\n  formatNetSentiment,\n  getNetSentiment,\n} from '@/registry/components/dashboardblocks/feedback'\nimport { formatNumber } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Feedback2Props extends BlockStateProps {\n  description: string\n  title: string\n  /** Leave out, or pass none, to show the empty state. */\n  topics?: SentimentTopic[]\n}\n\nconst exampleProps: Feedback2Props = {\n  description: 'Mentions in reviews and support tickets from the last 30 days.',\n  title: 'Sentiment by topic',\n  topics: [\n    { label: 'Ease of use', negative: 38, neutral: 71, positive: 412 },\n    { label: 'Support', negative: 64, neutral: 58, positive: 296 },\n    { label: 'Integrations', negative: 71, neutral: 92, positive: 188 },\n    { label: 'Performance', negative: 142, neutral: 61, positive: 174 },\n    { label: 'Pricing', negative: 203, neutral: 87, positive: 96 },\n  ],\n}\n\nconst Feedback2 = (props: Feedback2Props) => {\n  const { description, errorMessage, status, title, topics = [] } = props\n  const state = getBlockState(status, topics)\n  const sorted = [...topics].sort((a, b) => getNetSentiment(b) - getNetSentiment(a))\n  const mentions = topics.reduce(\n    (sum, topic) => sum + topic.negative + topic.neutral + topic.positive,\n    0,\n  )\n  const best = sorted[0]\n  const negative = sorted.filter((topic) => getNetSentiment(topic) < 0)\n  const worst = negative.at(-1)\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-4'>\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'>{description}</p>\n            </header>\n            {state && (\n              <div className='border-t pt-4'>\n                <BlockStateText className='text-sm' />\n              </div>\n            )}\n            {!state && best && (\n              <p className='border-t pt-4 text-sm text-pretty'>\n                People like{' '}\n                <span className='font-medium'>{best.label.toLowerCase()}</span> most, at{' '}\n                <span className='tabular-nums'>\n                  {formatNetSentiment(getNetSentiment(best))}\n                </span>\n                {worst &&\n                  (negative.length === 1 ? (\n                    <>\n                      , and{' '}\n                      <span className='font-medium'>{worst.label.toLowerCase()}</span> is\n                      the one topic with more complaints than praise\n                    </>\n                  ) : (\n                    <>\n                      , and <span className='tabular-nums'>{negative.length}</span> topics\n                      get more complaints than praise,{' '}\n                      <span className='font-medium'>{worst.label.toLowerCase()}</span>{' '}\n                      most\n                    </>\n                  ))}\n                .{' '}\n                <span className='text-muted-foreground'>\n                  From <span className='tabular-nums'>{formatNumber(mentions)}</span>{' '}\n                  mentions.\n                </span>\n              </p>\n            )}\n            <SentimentChart label={`${title}: ${description}`} topics={sorted} />\n            {state !== 'error' && state !== 'empty' && (\n              <p className='text-muted-foreground text-xs'>\n                Net is positive minus negative mentions, as a share of all mentions, from\n                −100 to +100.\n              </p>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Feedback2, exampleProps as feedback2ExampleProps, type Feedback2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/feedback/feedback-02.tsx"
    }
  ],
  "meta": {
    "shows": "A diverging bar chart of negative and positive mentions for each topic, sorted by net sentiment, with the best and worst topic in a sentence.",
    "size": "half",
    "usedWith": [
      "feedback-03",
      "feedback-01"
    ],
    "component": "Feedback2",
    "props": "{ description: string; title: string; topics?: { label: string; negative: number; neutral: number; positive: number }[]; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
