PageSourceSearch

https://myechoboard.com/assets/BoardStatsModal-D9A9lbHU.js

js myechoboard.com collected 2026-09-24 13:50:45 UTC 5,589 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"./vendor-react-C9yDzYQD.js";import{D as s,a,b as r,c as o}from"./dialog-DHNNRuDw.js";import{D as l,a as i,b as n,c as d}from"./drawer-RVJlVdjE.js";import{u as c}from"./use-mobile-D5Xf5BKb.js";import{B as m}from"./button-CcIRk75H.js";import{supabase as x}from"./supabase-client-_h80EYw_.js";import{a as p}from"./runtime-utils-GN4cODRt.js";import{b as u}from"./image-utils-AdRSPECl.js";import{b as f}from"./echoTypePolicy-DA-PDKiE.js";import{L as j}from"./loader-circle-CWK_zhHB.js";import{E as h}from"./eye-Dkh28JiF.js";import{U as b}from"./users-DC2VReCB.js";import{H as g}from"./heart-DTG6gDEx.js";import{T as _}from"./trending-up-Bp5hVToW.js";import{C as w}from"./calendar-BcnXqNLJ.js";const v=e=>{if("object"!=typeof e||null===e||Array.isArray(e))return!1;const t=e;return f({id:t.memory_id,type:t.type,deleted_at:t.deleted_at})},y=({boardId:f,boardName:y,isOpen:N,onClose:S})=>{const D=c(),[k,O]=e.useState("week"),[T,I]=e.useState(null),[A,C]=e.useState([]),[$,q]=e.useState(!0);e.useEffect(()=>{N&&f&&(async()=>{q(!0),C([]);try{const{data:e,error:t}=await x.rpc("get_board_stats",{p_board_id:f,p_period:k});if(t)throw t;e&&e.length>0?I(e[0]):I({total_views:0,unique_visitors:0,total_reactions:0,follower_count:0,memory_count:0,period_start:(new Date).toISOString(),period_end:(new Date).toISOString()});let s="2020-01-01";const a=(new Date).toISOString().split("T")[0];if("today"===k)s=a;else if("week"===k){const e=new Date;e.setDate(e.getDate()-7),s=e.toISOString().split("T")[0]}else if("month"===k){const e=new Date;e.setDate(e.getDate()-30),s=e.toISOString().split("T")[0]}const{data:r,error:o}=await x.rpc("get_board_top_memories",{p_board_id:f,p_limit:5,p_start_date:s,p_end_date:a});if(o)throw o;C((r||[]).filter(v))}catch(e){C([]),I({total_views:0,unique_visitors:0,total_reactions:0,follower_count:0,memory_count:0,period_start:(new Date).toISOString(),period_end:(new Date).toISOString()})}finally{q(!1)}})()},[f,k,N]);const F=A.filter(v),L=({icon:e,label:s,value:a,color:r})=>{return t.jsxs("div",{className:"bg-card/50 backdrop-blur-xl border border-border/50 rounded-2xl p-6 shadow-soft",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("div",{className:p("p-2 rounded-xl",`bg-${r}-500/10`),children:t.jsx(e,{className:p("w-5 h-5",`text-${r}-500`)})}),t.jsx("span",{className:"text-3xl font-black text-foreground",children:(o=a,o>=1e6?`${(o/1e6).toFixed(1)}M`:o>=1e3?`${(o/1e3).toFixed(1)}K`:o.toString())})]}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:s})]});var o},U=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex items-center gap-2 my-4 flex-wrap",children:["today","week","month","all"].map(e=>t.jsx(m,{variant:k===e?"default":"outline",size:"sm",onClick:()=>O(e),className:"rounded-full capitalize",children:"all"===e?"All Time":"today"===e?"Today":`Past ${e}`},e))}),$?t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsx(j,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsx(L,{icon:h,label:"Total Views",value:(null==T?void 0:T.total_views)||0,color:"blue"}),t.jsx(L,{icon:b,label:"Unique Visitors",value:(null==T?void 0:T.unique_visitors)||0,color:"emerald"}),t.jsx(L,{icon:g,label:"Total Reactions",value:(null==T?void 0:T.total_reactions)||0,color:"pink"}),t.jsx(L,{icon:_,label:"Followers",value:(null==T?void 0:T.follower_count)||0,color:"purple"})]}),F.length>0&&t.jsxs("div",{className:"bg-card/50 backdrop-blur-xl border border-border/50 rounded-2xl p-6 shadow-soft",children:[t.jsxs("h3",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[t.jsx(g,{className:"w-5 h-5 text-pink-500"}),"Top Memories"]}),t.jsx("div",{className:"space-y-3",children:F.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-xl bg-background/50 hover:bg-background/80 transition-colors",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:t.jsxs("span",{className:"text-sm font-bold text-primary",children:["#",s+1]})}),e.image_url&&t.jsx("img",{src:u(e.image_url,"thumbnail")||e.image_url,alt:e.title||"Memory",className:"w-12 h-12 rounded-lg object-cover shrink-0",loading:"lazy",decoding:"async"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"font-medium text-sm truncate",children:e.title||"Untitled"}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.description})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(g,{className:"w-4 h-4 text-pink-500 fill-pink-500"}),t.jsx("span",{className:"text-sm font-bold",children:e.like_count})]})]},e.memory_id))})]}),T&&t.jsxs("div",{className:"text-center text-xs text-muted-foreground pb-2",children:[t.jsx(w,{className:"w-3 h-3 inline mr-1"}),"Data from ",new Date(T.period_start).toLocaleDateString()," to ",new Date(T.period_end).toLocaleDateString()]})]})]});return D?t.jsx(l,{open:N,onOpenChange:e=>!e&&S(),children:t.jsxs(i,{className:"px-4 pb-safe-inset max-h-[90dvh] overflow-y-auto",children:[t.jsx(n,{className:"px-0 pt-6 pb-0",children:t.jsxs(d,{className:"text-xl font-bold",children:[y," Analytics"]})}),U]})}):t.jsx(s,{open:N,onOpenChange:S,children:t.jsxs(a,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[t.jsx(r,{children:t.jsxs(o,{className:"text-2xl font-bold",children:[y," Analytics"]})}),U]})})};export{y as BoardStatsModal};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.