harshapitla/stackoverflow
0
1"use strict";(self.webpackChunkreact_template=self.webpackChunkreact_template||[]).push([[103],{3103:(e,r,t)=>{t.r(r),t.d(r,{default:()=>x});var s=t(5043),a=t(1180),l=t(3626),o=t(7734),c=t(2185),i=t(6026),n=t(3670),d=t(3675),u=t(579);function f(e){let{title:r,subtitle:t,children:s,actions:a,footer:l}=e;return(0,u.jsxs)("section",{className:"card chart-card",children:[(r||t||a)&&(0,u.jsxs)("div",{className:"chart-card-header",children:[(0,u.jsxs)("div",{children:[r&&(0,u.jsx)("h3",{className:"chart-card-title",children:r}),t&&(0,u.jsx)("p",{className:"chart-card-subtitle",children:t})]}),a&&(0,u.jsx)("div",{className:"chart-card-actions",children:a})]}),(0,u.jsx)("div",{className:"chart-card-body",children:s}),l&&(0,u.jsx)("div",{className:"chart-card-footer",children:l})]})}function h(e){if(null===e||void 0===e)return 0;if("number"===typeof e)return e;if("string"===typeof e){const r=e.replace(/,/g,"").trim(),t=Number(r);return isNaN(t)?0:t}return 0}function p(e){let{active:r,payload:t,label:s}=e;return r&&t&&t.length?(0,u.jsxs)("div",{style:{background:"#ffffff",padding:"8px 12px",borderRadius:6,border:"1px solid #cbd5e1"},children:[(0,u.jsx)("strong",{children:s}),(0,u.jsxs)("div",{style:{marginTop:4},children:[t[0].dataKey,": ",t[0].value.toLocaleString()]})]}):null}function x(e){let{rows:r=[]}=e;const[t,x]=(0,s.useState)("followers"),b=(0,s.useMemo)(()=>Array.isArray(r)?r.map(e=>{const r=h(e.followers_count),s=h(e.reviews_count),a=h(e.used_by_count);return{title:e.title,value:"followers"===t?r:"reviews"===t?s:a}}).filter(e=>e.title&&e.value>0).sort((e,r)=>r.value-e.value).slice(0,10):[],[r,t]);if(!b.length)return(0,u.jsx)(f,{title:"Top Product Hunt Products",subtitle:"Based on followers, reviews, or usage",children:(0,u.jsx)("p",{className:"small",children:"No valid data available."})});return(0,u.jsxs)(f,{title:(()=>{switch(t){case"followers":return"Top Products by Followers";case"reviews":return"Top Products by Reviews";case"usage":return"Products by Usage Count";default:return"Top Product Hunt Products"}})(),subtitle:(()=>{switch(t){case"followers":return"Identify most followed products";case"reviews":return"Measure active user engagement";case"usage":return"Measure real adoption";default:return""}})(),children:[(0,u.jsxs)("div",{style:{marginBottom:16,display:"flex",gap:"8px"},children:[(0,u.jsx)("button",{onClick:()=>x("followers"),style:{padding:"10px 16px",borderRadius:"8px",background:"followers"===t?"#007acc":"#f0f0f0",color:"followers"===t?"white":"black",border:"none",cursor:"pointer"},children:"\ud83d\udc65 Followers"}),(0,u.jsx)("button",{onClick:()=>x("reviews"),style:{padding:"10px 16px",borderRadius:"8px",background:"reviews"===t?"#007acc":"#f0f0f0",color:"reviews"===t?"white":"black",border:"none",cursor:"pointer"},children:"\ud83d\udcdd Reviews"}),(0,u.jsx)("button",{onClick:()=>x("usage"),style:{padding:"10px 16px",borderRadius:"8px",background:"usage"===t?"#007acc":"#f0f0f0",color:"usage"===t?"white":"black",border:"none",cursor:"pointer"},children:"\ud83d\udc65 Usage"})]}),(0,u.jsx)(a.u,{width:"100%",height:300,children:(0,u.jsxs)(l.E,{data:b,children:[(0,u.jsx)(o.d,{strokeDasharray:"3 3"}),(0,u.jsx)(c.W,{dataKey:"title",angle:-45,textAnchor:"end",interval:0}),(0,u.jsx)(i.h,{}),(0,u.jsx)(n.m,{content:(0,u.jsx)(p,{})}),(0,u.jsx)(d.y,{dataKey:"value",fill:"#8884d8"})]})})]})}}}]);2//# sourceMappingURL=103.34050452.chunk.js.map