PageSourceSearch

https://cliqs.me/assets/Dashboard-BeomOCvc.js

js cliqs.me collected 2026-10-02 00:38:08 UTC 12,233 bytes, 16 lines download raw bytes

1import{c as j,r as m,j as e,C as G,L as Y,A as J,s as i}from"./index-CMO3mc9n.js";import{g as K}from"./supabaseShopUtils-BuBigHtp.js";import{U as Q}from"./user-round-trTFRRha.js";import{S as X}from"./share-2-BtLTjgtw.js";import{P as Z}from"./package-C3-lvB3J.js";import{W as T}from"./wallet-cards-CKFmZMPn.js";import{E as ee}from"./eye-DbdoZ04X.js";import{L as se}from"./link-CtXR3cFp.js";import{R as U}from"./refresh-cw-D-xkbMHJ.js";/**
2 * @license lucide-react v0.454.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const te=j("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
7 * @license lucide-react v0.454.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const re=j("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/**
12 * @license lucide-react v0.454.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ae=j("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]),le=new Set(["paid","fulfilled"]),ie=new Set(["paid","succeeded"]),ne=s=>ie.has(String(s?.payment_status||"").toLowerCase())||le.has(String(s?.status||"").toLowerCase()),l=(s=0)=>new Intl.NumberFormat("en-US").format(Number(s)||0),b=(s=0,c="usd")=>new Intl.NumberFormat("en-US",{style:"currency",currency:String(c||"usd").toUpperCase()}).format(Number(s)||0),g=(s=[])=>s.find(c=>c.currency==="usd")||s[0]||{amount:0,currency:"usd"},$=()=>{const s=new Date;return s.setDate(s.getDate()-30),s.setHours(0,0,0,0),s},oe={userProfile:null,profile:null,shop:null,products:[],socialLinks:[],analytics:{views:0,uniqueViews:0,clicks:0,uniqueClicks:0,clickRate:0},income:null};function ge(){const[s,c]=m.useState(oe),[z,y]=m.useState(!0),[w,_]=m.useState(""),v=async()=>{try{y(!0),_("");const{data:{user:t},error:r}=await i.auth.getUser();if(r)throw r;if(!t)throw new Error("Authentication required");const{data:n,error:P}=await i.from("user_profiles").select("id, username, created_at").eq("user_id",t.id).eq("is_primary",!0).single();if(P)throw P;const[u,o,h,x]=await Promise.all([i.from("profiles").select("name, bio, profile_image_url").eq("user_profile_id",n.id).maybeSingle(),i.from("shops").select("id, store_enabled, store_checkout_enabled, stripe_connected_account_id, stripe_charges_enabled, stripe_payouts_enabled, stripe_account_status").eq("user_profile_id",n.id).maybeSingle(),i.from("social_links").select("id, type, click_count").eq("user_profile_id",n.id),i.from("analytics_events").select("event_type, visitor_id, created_at").eq("user_id",t.id).gte("created_at",$().toISOString())]);if(u.error&&u.error.code!=="PGRST116")throw u.error;if(o.error&&o.error.code!=="PGRST116")throw o.error;if(h.error)throw h.error;if(x.error)throw x.error;let q=[];if(o.data?.id){const{data:a,error:I}=await i.from("products").select("id, title, is_live, checkout_enabled, status, purchase_count, total_revenue, click_count").eq("shop_id",o.data.id);if(I)throw I;q=a||[]}let E=null;try{E=await K()}catch(a){console.warn("Dashboard income unavailable:",a)}const R=x.data||[],D=R.filter(a=>a.event_type==="view"),L=R.filter(a=>a.event_type==="click"),f=new Set(D.map(a=>a.visitor_id).filter(Boolean)),A=new Set(L.map(a=>a.visitor_id).filter(Boolean));c({userProfile:n,profile:u.data||null,shop:o.data||null,products:q,socialLinks:h.data||[],analytics:{views:D.length,uniqueViews:f.size,clicks:L.length,uniqueClicks:A.size,clickRate:f.size?Math.min(A.size/f.size*100,100):0},income:E})}catch(t){console.error("Error loading dashboard:",t),_(t.message||"Unable to load dashboard.")}finally{y(!1)}};m.useEffect(()=>{v()},[]);const d=m.useMemo(()=>{const t=s.profile||{},r=s.shop||{};return[{label:"Add profile image, name and bio",description:"Complete the basics people see first on your public profile.",href:"/design",icon:Q,complete:!!(t.profile_image_url&&t.name?.trim()&&t.bio?.trim())}
16,{label:"Add social links",description:"Connect the channels where followers already know you.",href:"/social",icon:X,complete:s.socialLinks.length>0},{label:"Add a product",description:"Publish at least one offer, download, course, service, or product link.",href:"/shop",icon:Z,complete:s.products.length>0},{label:"Set up Stripe Connect",description:"Enable payouts so paid products can send earnings to you.",href:"/income",icon:T,complete:!!(r.stripe_connected_account_id&&(r.stripe_charges_enabled||r.stripe_payouts_enabled))}]},[s]),N=d.filter(t=>!t.complete),k=d.length-N.length,F=(s.income?.orders||[]).filter(ne),M=$(),p=F.filter(t=>new Date(t.completed_at||t.created_at)>=M),O=p.reduce((t,r)=>t+Number(r.total_amount||0),0),V=p[0]?.currency||g(s.income?.summary?.allTimeRevenue).currency||"usd",S=g(s.income?.summary?.availableForCashout),C=g(s.income?.summary?.availableSoon),B=s.products.filter(t=>t.is_live||t.status==="published").length,H=s.products.reduce((t,r)=>t+Number(r.click_count||0),0),W=[{label:"Views in 30 days",value:l(s.analytics.views),detail:`${l(s.analytics.uniqueViews)} unique visitors`,icon:ee},{label:"Clicks in 30 days",value:l(s.analytics.clicks),detail:`${s.analytics.clickRate.toFixed(1)}% unique click rate`,icon:se},{label:"Income in 30 days",value:b(O,V),detail:`${l(p.length)} paid orders`,icon:ae},{label:"Available for cashout",value:b(S.amount,S.currency),detail:`${b(C.amount,C.currency)} pending`,icon:T}];return z?e.jsx("div",{className:"flex min-h-[70vh] items-center justify-center",children:e.jsx(U,{className:"h-8 w-8 animate-spin text-purple-600"})}):e.jsx("div",{className:"min-h-screen bg-[#f7f8fb] px-4 py-6 text-[#211b4f] sm:px-6 lg:px-8",children:e.jsxs("div",{className:"mx-auto max-w-6xl",children:[e.jsxs("header",{className:"mb-8 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold uppercase tracking-[0.12em] text-purple-600",children:"Creator dashboard"}),e.jsxs("h1",{className:"mt-2 text-3xl font-black tracking-tight sm:text-4xl",children:["Welcome",s.profile?.name?`, ${s.profile.name}`:""]}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm font-medium text-[#687391] sm:text-base",children:"Your setup progress and the creator metrics that matter first when you log in."})]}),e.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center justify-center gap-2 rounded-full border border-[#dfe3ef] bg-white px-4 py-2 text-sm font-bold text-[#211b4f] shadow-sm transition hover:border-purple-300",children:[e.jsx(U,{className:"h-4 w-4"}),"Refresh"]})]}),w&&e.jsx("div",{className:"mb-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm font-semibold text-red-700",children:w}),N.length>0&&e.jsxs("section",{className:"mb-8 rounded-lg border border-[#e4e8f1] bg-white p-4 shadow-[0_18px_44px_rgba(18,31,84,0.06)] sm:p-6",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-black",children:"Finish setting up your creator account"}),e.jsxs("p",{className:"mt-1 text-sm font-medium text-[#687391]",children:[k," of ",d.length," completed. This checklist disappears after everything is done."]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-[#eef0f5] sm:w-48",children:e.jsx("div",{className:"h-full rounded-full bg-purple-600 transition-all",style:{width:`${k/d.length*100}%`}})})]}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:d.map(t=>{const r=t.icon,n=t.complete?G:te;return e.jsxs(Y,{to:t.href,className:["group flex min-w-0 items-start gap-3 rounded-lg border p-4 transition",t.complete?"border-emerald-100 bg-emerald-50/60 text-emerald-900":"border-[#e4e8f1] bg-white hover:border-purple-300 hover:shadow-sm"].join(" "),children:[e.jsx("div",{className:"rounded-lg bg-[#f4f1ff] p-2 text-purple-700",children:e.jsx(r,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h3",{className:"font-black leading-snug",children:t.label}),e.jsx(n,{className:t.complete?"h-5 w-5 shrink-0 text-emerald-600":"h-5 w-5 shrink-0 text-[#a0a8ba]"})]}),e.jsx("p",{className:"mt-1 text-sm font-medium text-[#687391]",children:t.description})]}),!t.complete&&e.jsx(J,{className:"mt-1 h-4 w-4 shrink-0 text-purple-600 transition group-hover:translate-x-0.5"})]},t.label)})})]}),e.jsx("section",{className:"mb-8 grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:W.map(t=>{const r=t.icon;return e.jsxs("div",{className:"rounded-lg border border-[#e4e8f1] bg-white p-5 shadow-[0_18px_44px_rgba(18,31,84,0.05)]",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm font-black text-[#687391]",children:t.label}),e.jsx("span",{className:"rounded-lg bg-[#f4f1ff] p-2 text-purple-700",children:e.jsx(r,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"text-2xl font-black tracking-tight",children:t.value}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-[#7b849e]",children:t.detail})]},t.label)})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg border border-[#e4e8f1] bg-white p-5 shadow-[0_18px_44px_rgba(18,31,84,0.05)]",children:[e.jsx("h2",{className:"text-lg font-black",children:"Store snapshot"}),e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Products"}),e.jsx("strong",{children:l(s.products.length)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Live products"}),e.jsx("strong",{children:l(B)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Product clicks"}),e.jsx("strong",{children:l(H)})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-[#e4e8f1] bg-white p-5 shadow-[0_18px_44px_rgba(18,31,84,0.05)]",children:[e.jsx("h2",{className:"text-lg font-black",children:"Audience actions"}),e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Social links"}),e.jsx("strong",{children:l(s.socialLinks.length)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Unique clickers"}),e.jsx("strong",{children:l(s.analytics.uniqueClicks)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Total profile views"}),e.jsx("strong",{children:l(s.analytics.views)})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-[#e4e8f1] bg-white p-5 shadow-[0_18px_44px_rgba(18,31,84,0.05)]",children:[e.jsx("h2",{className:"text-lg font-black",children:"Payout readiness"}),e.jsxs("div",{className:"mt-5 grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Stripe account"}),e.jsx("strong",{children:s.shop?.stripe_connected_account_id?"Connected":"Not connected"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"font-bold text-[#687391]",children:"Charges"}),e.jsx("strong",{children:s.shop?.stripe_charges_enabled?"Enabled":"Pending"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 font-bold text-[#687391]",children:[e.jsx(re,{className:"h-4 w-4"}),"Payouts"]}),e.jsx("strong",{children:s.shop?.stripe_payouts_enabled?"Enabled":"Pending"})]})]})]})]})]})})}export{ge 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.