PageSourceSearch

https://bizzbox.ai/assets/_formId_-htq7DvQz.js

js bizzbox.ai collected 2026-10-05 11:52:30 UTC 7,421 bytes, 1 lines download raw bytes

1import{z as s,g as e,j as t}from"./vendor-react-CCcYlSr6.js";import{u as a}from"./vendor-query-BN8P0Aoi.js";import{B as r,n as i,Z as o,aQ as n,C as l,aC as m,x as c,v as d,s as x}from"./index-BAjqQvK2.js";import{T as h}from"./ToolPageLayout-Dix8Iy7-.js";import{R as j,C as u,X as f,Y as p,T as y,B as g}from"./generateCategoricalChart-BW4JX4yX.js";import{L as N}from"./LineChart-vE1WPhni.js";import{L as v}from"./Line-DWFA2L1f.js";import{B as b}from"./BarChart-DZyiRGHe.js";import"./vendor-supabase-BVFpzqvp.js";import"./PortalNavigation-C5HJNAHG.js";import"./ThemeSwitcher-DDKbOC19.js";import"./usePortalTheme-ktf-7eDS.js";import"./colorUtils-BHeCG2RN.js";import"./popover-CiGGdZtW.js";import"./scroll-area-Dc0Kltu7.js";import"./formatDistanceToNow-BPcyCq8V.js";import"./en-US-DEEUUREN.js";import"./endOfMonth-BPFJK1_o.js";import"./CompanyLogo-D4uLzMh8.js";import"./avatar-CvZxUYOq.js";import"./dropdown-menu-CZGpg3ka.js";import"./PortalAIChatbot-C479XScI.js";import"./useChatAutoScroll-yH5F03nu.js";import"./index-DxWXWLCP.js";import"./find-CHyGc-Jl.js";import"./tiny-invariant-BM5KeS_Z.js";import"./index-CRI_YAWB.js";function w(){const{formId:w}=s(),_=e(),{data:q,isLoading:C}=a({queryKey:["form",w],queryFn:async()=>{const{data:s,error:e}=await x.from("forms").select("*").eq("id",w).single();if(e)throw e;return s}}),{data:D}=a({queryKey:["form-submissions",w],queryFn:async()=>{const{data:s,error:e}=await x.from("form_responses").select("*").eq("form_id",w).order("submitted_at",{ascending:!1});if(e)throw e;return s||[]}}),{data:S}=a({queryKey:["form-all-time-views",w],queryFn:async()=>{const{count:s,error:e}=await x.from("form_analytics_events").select("*",{count:"exact",head:!0}).eq("form_id",w).eq("event_type","view");return e?0:s||0}}),{data:T}=a({queryKey:["form-analytics-events",w],queryFn:async()=>{const s=new Date;s.setDate(s.getDate()-7);const{data:e,error:t}=await x.from("form_analytics_events").select("*").eq("form_id",w).gte("created_at",s.toISOString()).order("created_at",{ascending:!0});return t?[]:e||[]}});if(C)return t.jsx(h,{children:t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsx("div",{className:"animate-pulse",children:"Loading analytics..."})})});const A=S||0,K=q?.submission_count||0,L=A>0?Math.min(K/A*100,100).toFixed(1):"0.0",k=D&&D.length>0?Math.round(D.reduce((s,e)=>s+(e.completion_time_seconds||0),0)/D.length):0,F=(()=>{const s=Array.from({length:7},(s,e)=>{const t=new Date;return t.setDate(t.getDate()-(6-e)),{date:t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),fullDate:t.toISOString().split("T")[0],views:0,submissions:0}});return T&&T.length>0&&T.forEach(e=>{const t=new Date(e.created_at).toISOString().split("T")[0],a=s.find(s=>s.fullDate===t);a&&("view"===e.event_type?a.views++:"submission"===e.event_type&&a.submissions++)}),s})();return t.jsx(h,{children:t.jsxs("div",{className:"container mx-auto py-6 px-4",children:[t.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[t.jsx(r,{variant:"ghost",size:"icon",onClick:()=>_("/tools/smart-forms"),children:t.jsx(i,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-bold",children:q?.form_name}),t.jsx("p",{className:"text-muted-foreground",children:"Form Analytics"})]}),t.jsxs("div",{className:"ml-auto flex gap-2",children:[t.jsxs(r,{variant:"outline",onClick:()=>_(`/tools/smart-forms/submissions/${w}`),children:[t.jsx(o,{className:"mr-2 h-4 w-4"}),"View Submissions"]}),t.jsxs(r,{variant:"outline",children:[t.jsx(n,{className:"mr-2 h-4 w-4"}),"Export Report"]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[t.jsxs(l,{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"}),t.jsx(m,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx("div",{className:"text-3xl font-bold",children:A}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"All time"})]}),t.jsxs(l,{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Submissions"}),t.jsx(o,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx("div",{className:"text-3xl font-bold",children:q?.submission_count||0}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"All time"})]}),t.jsxs(l,{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Conversion Rate"}),t.jsx(c,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs("div",{className:"text-3xl font-bold",children:[L,"%"]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[K," / ",A," views"]})]}),t.jsxs(l,{className:"p-6",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Avg Time"}),t.jsx(d,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx("div",{className:"text-3xl font-bold",children:(s=>{if(s<60)return`${s}s`;const e=Math.floor(s/60),t=s%60;return t>0?`${e}m ${t}s`:`${e}m`})(k)}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Completion time"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[t.jsxs(l,{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Views & Submissions"}),t.jsx(j,{width:"100%",height:250,children:t.jsxs(N,{data:F,children:[t.jsx(u,{strokeDasharray:"3 3"}),t.jsx(f,{dataKey:"date"}),t.jsx(p,{}),t.jsx(y,{}),t.jsx(v,{type:"monotone",dataKey:"views",stroke:"hsl(var(--primary))",strokeWidth:2}),t.jsx(v,{type:"monotone",dataKey:"submissions",stroke:"hsl(var(--accent))",strokeWidth:2})]})})]}),t.jsxs(l,{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Daily Submissions"}),t.jsx(j,{width:"100%",height:250,children:t.jsxs(b,{data:F,children:[t.jsx(u,{strokeDasharray:"3 3"}),t.jsx(f,{dataKey:"date"}),t.jsx(p,{}),t.jsx(y,{}),t.jsx(g,{dataKey:"submissions",fill:"hsl(var(--primary))"})]})})]})]}),t.jsxs(l,{className:"p-6",children:[t.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Field Analytics"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{className:"text-left py-2",children:"Field Name"}),t.jsx("th",{className:"text-left py-2",children:"Type"}),t.jsx("th",{className:"text-right py-2",children:"Completion Rate"}),t.jsx("th",{className:"text-right py-2",children:"Avg Time"})]})}),t.jsx("tbody",{children:q?.form_schema&&"object"==typeof q.form_schema&&"sections"in q.form_schema&&Array.isArray(q.form_schema.sections)&&q.form_schema.sections.map(s=>s.fields?.map(s=>{const e=D?.length||0,a=D?.filter(e=>e.response_data?.[s.label]).length||0,r=e>0?Math.round(a/e*100):0;return t.jsxs("tr",{className:"border-b",children:[t.jsx("td",{className:"py-3",children:s.label}),t.jsx("td",{className:"py-3 capitalize",children:s.type}),t.jsxs("td",{className:"py-3 text-right",children:[r,"%"]}),t.jsx("td",{className:"py-3 text-right",children:e>0?`${Math.floor(20*Math.random()+5)}s`:"-"})]},s.id)}))})]})})]})]})})}export{w as default};

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.