PageSourceSearch

https://backr.lovable.app/assets/BusinessDashboard-BdPpb-fE.js

js backr.lovable.app collected 2026-10-03 03:23:35 UTC 14,676 bytes, 16 lines download raw bytes

1import{c as $,l as Y,r as y,j as e,P as z,v as H,u as K,a as Q,A as L,S,m as x,L as j}from"./index-fC6qzyQq.js";import{u as J,a as Z,b as ee,c as se}from"./useBusinessProfile-CAaMOAla.js";import{u as ae}from"./useUserRole-iLEKIkT8.js";import{B as te}from"./BusinessBottomNav-BeHJK0G9.js";import{B as d}from"./button-CN7syaaY.js";import{C as v,b as A,c as B,a as N}from"./card-DlgbtDug.js";import{a as u,c as D}from"./formatters-D5RJcbR6.js";import{B as re}from"./building-2-BbxxUw2K.js";import{U as ne}from"./user-D9d0PfJq.js";import{L as ie}from"./log-out-DDJQ47vH.js";import{T}from"./trending-up-E1e1a6tB.js";import{S as le}from"./store-BfqsNiYa.js";import{C as oe}from"./circle-dollar-sign-F9rkkaTW.js";import{P as ce}from"./piggy-bank-Do_4vpTa.js";import{R as de}from"./refresh-cw-BL7VZqdQ.js";import{R as me,A as xe,X as ue,Y as he,T as pe,a as fe}from"./AreaChart-DeN6orvc.js";import{U as ge}from"./users-7vxxHrxP.js";import{W as je}from"./wallet-BLHWzy33.js";import{P as ve}from"./plus-CTVHmKFT.js";import"./credit-card-BKRMx26k.js";/**
2 * @license lucide-react v0.462.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 Ne=$("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/**
7 * @license lucide-react v0.462.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 ye=$("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);var _="Progress",P=100,[be,Ke]=Y(_),[we,_e]=be(_),O=y.forwardRef((s,r)=>{const{__scopeProgress:m,value:n=null,max:t,getValueLabel:f=Pe,...g}=s;(t||t===0)&&!I(t)&&console.error(Re(`${t}`,"Progress"));const o=I(t)?t:P;n!==null&&!M(n,o)&&console.error(ke(`${n}`,"Progress"));const i=M(n,o)?n:null,w=b(i)?f(i,o):void 0;return e.jsx(we,{scope:m,value:i,max:o,children:e.jsx(z.div,{"aria-valuemax":o,"aria-valuemin":0,"aria-valuenow":b(i)?i:void 0,"aria-valuetext":w,role:"progressbar","data-state":V(i,o),"data-value":i??void 0,"data-max":o,...g,ref:r})})});O.displayName=_;var E="ProgressIndicator",U=y.forwardRef((s,r)=>{const{__scopeProgress:m,...n}=s,t=_e(E,m);return e.jsx(z.div,{"data-state":V(t.value,t.max),"data-value":t.value??void 0,"data-max":t.max,...n,ref:r})});U.displayName=E;function Pe(s,r){return`${Math.round(s/r*100)}%`}function V(s,r){return s==null?"indeterminate":s===r?"complete":"loading"}function b(s){return typeof s=="number"}function I(s){return b(s)&&!isNaN(s)&&s>0}function M(s,r){return b(s)&&!isNaN(s)&&s<=r&&s>=0}function Re(s,r){return`Invalid prop \`max\` of value \`${s}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${P}\`.`}function ke(s,r){return`Invalid prop \`value\` of value \`${s}\` supplied to \`${r}\`. The \`value\` prop must be:
12  - a positive number
13  - less than the value passed to \`max\` (or ${P} if no \`max\` prop is set)
14  - \`null\` or \`undefined\` if the progress is indeterminate.
15
16Defaulting to \`null\`.`}var q=O,Ce=U;const G=y.forwardRef(({className:s,value:r,...m},n)=>e.jsx(q,{ref:n,className:H("relative h-4 w-full overflow-hidden rounded-full bg-secondary",s),...m,children:e.jsx(Ce,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})}));G.displayName=q.displayName;function Qe(){const s=K(),{user:r,signOut:m,loading:n}=Q(),{profile:t,loading:f}=J(),{primaryRole:g,loading:o}=ae(),{loans:i,loading:w}=Z();ee();const{revenue:h}=se();y.useEffect(()=>{if(localStorage.getItem("preferred_role")==="investor"){s("/discover");return}!o&&g!=="business"&&g!=="admin"&&s("/discover")},[g,o,s]),y.useEffect(()=>{if(!n&&!r){s("/auth");return}if(!f&&!t){s("/business-onboarding");return}t&&!t.is_onboarded&&s("/business-onboarding")},[n,f,r,t,s]);const F=async()=>{await m(),s("/")},l=i.find(a=>["active","repaying"].includes(a.status)),R=i.filter(a=>a.status==="pending_approval"),X=i.reduce((a,c)=>a+c.raised_amount,0),W=i.reduce((a,c)=>a+c.backer_count,0),p=h.find(a=>a.revenue_date===new Date().toISOString().split("T")[0]),k=h.slice(0,7).reduce((a,c)=>a+c.gross_revenue,0);h.reduce((a,c)=>a+c.deduction_amount,0);const C=[...h].reverse().slice(-14).map(a=>({date:new Date(a.revenue_date).toLocaleDateString("fr-FR",{day:"2-digit",month:"short"}),revenue:a.gross_revenue,deduction:a.deduction_amount}));return n||f||w||o?e.jsxs("div",{className:"min-h-screen flex items-center justify-center",children:[e.jsx(L,{}),e.jsxs("div",{className:"space-y-4 text-center relative z-10",children:[e.jsx(S,{className:"w-16 h-16 rounded-2xl mx-auto bg-muted/30"}),e.jsx(S,{className:"w-32 h-4 mx-auto bg-muted/30"})]})]}):e.jsxs("div",{className:"min-h-screen pb-28 relative",children:[e.jsx(L,{}),e.jsx("header",{className:"sticky top-0 z-50 glass-nav px-5 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(re,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold text-sm",children:t==null?void 0:t.business_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t==null?void 0:t.sector})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{variant:"ghost",size:"icon",className:"rounded-full overflow-hidden",onClick:()=>s("/business-profile"),children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/10 flex items-center justify-center border border-accent/20",children:e.jsx(ne,{className:"w-5 h-5 text-accent"})})}),e.jsx(d,{variant:"ghost",size:"icon",className:"rounded-xl",onClick:F,children:e.jsx(ie,{className:"w-5 h-5"})})]})]})}),e.jsxs("main",{className:"px-5 pt-6 space-y-6 relative z-10",children:[e.jsxs(x.div,{initial:{opacity:0,y:10}
16,animate:{opacity:1,y:0},transition:{delay:.2},className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:"Quick Actions"}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(j,{to:"/business-dashboard/new-loan",children:e.jsxs(d,{variant:"outline",className:"w-full h-auto flex-col gap-3 p-4 glass-card hover:bg-accent/5 border-border/50 shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center transition-colors group-hover:bg-primary/20",children:e.jsx(T,{className:"w-5 h-5 text-primary"})}),e.jsx("span",{className:"text-xs font-medium",children:"New Loan"})]})}),e.jsx(j,{to:"/business-dashboard/scan",children:e.jsxs(d,{variant:"outline",className:"w-full h-auto flex-col gap-3 p-4 glass-card hover:bg-accent/5 border-border/50 shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-accent/10 flex items-center justify-center transition-colors group-hover:bg-accent/20",children:e.jsx(ye,{className:"w-5 h-5 text-accent"})}),e.jsx("span",{className:"text-xs font-medium",children:"Scan QR"})]})}),e.jsx(j,{to:"/business-dashboard/pos",children:e.jsxs(d,{variant:"outline",className:"w-full h-auto flex-col gap-3 p-4 glass-card hover:bg-accent/5 border-border/50 shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/20 flex items-center justify-center transition-colors group-hover:bg-muted/30",children:e.jsx(le,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-xs font-medium",children:"Connect POS"})]})}),e.jsx(j,{to:"/business-dashboard/revenue",children:e.jsxs(d,{variant:"outline",className:"w-full h-auto flex-col gap-3 p-4 glass-card hover:bg-accent/5 border-border/50 shadow-sm",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/20 flex items-center justify-center transition-colors group-hover:bg-muted/30",children:e.jsx(Ne,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-xs font-medium",children:"Revenue"})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(x.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"glass-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{className:"w-4 h-4 text-accent"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Today's Revenue"})]}),e.jsx("p",{className:"text-xl font-semibold",children:u((p==null?void 0:p.gross_revenue)||0)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[(p==null?void 0:p.transaction_count)||0," transactions"]})]}),e.jsxs(x.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.05},className:"glass-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(T,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"7-Day Revenue"})]}),e.jsx("p",{className:"text-xl font-semibold",children:u(k)}),e.jsx("p",{className:"text-xs text-accent mt-1",children:h.length>7&&`+${D((k/(h.slice(7,14).reduce((a,c)=>a+c.gross_revenue,0)||1)-1)*100)} vs prev`})]})]}),l&&e.jsx(x.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1},children:e.jsxs(v,{className:"glass-card-elevated border-0 overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/5 to-accent/5"}),e.jsx(A,{className:"relative pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{className:"text-base flex items-center gap-2",children:[e.jsx(ce,{className:"w-5 h-5 text-accent"}),"Active Loan"]}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-accent/20 text-accent",children:l.status==="repaying"?"Repaying":"Active"})]})}),e.jsxs(N,{className:"relative space-y-4",children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Amount Raised"}),e.jsx("p",{className:"text-2xl font-bold",children:u(l.raised_amount)})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Remaining"}),e.jsx("p",{className:"text-lg font-semibold text-accent",children:u((l.total_to_repay||0)-l.amount_repaid)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repayment Progress"}),e.jsx("span",{className:"font-medium",children:D(l.amount_repaid/(l.total_to_repay||1)*100)})]}),e.jsx(G,{value:l.amount_repaid/(l.total_to_repay||1)*100,className:"h-2"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 pt-2",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold",children:l.backer_count}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Backers"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-lg font-semibold",children:[l.daily_deduction_pct,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Daily Rate"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-lg font-semibold",children:[l.duration_months,"mo"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Duration"})]})]})]})]})}),C.length>0&&e.jsx(x.div,{initial:{opacity:0,y:10}
16,animate:{opacity:1,y:0},transition:{delay:.15},children:e.jsxs(v,{className:"glass-card border-0",children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(B,{className:"text-base",children:"Revenue Trend"}),e.jsxs(d,{variant:"ghost",size:"sm",className:"text-xs gap-1",children:[e.jsx(de,{className:"w-3 h-3"}),"Sync"]})]})}),e.jsx(N,{children:e.jsx("div",{className:"h-40",children:e.jsx(me,{width:"100%",height:"100%",children:e.jsxs(xe,{data:C,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"revenueGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--accent))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--accent))",stopOpacity:0})]})}),e.jsx(ue,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fontSize:10,fill:"hsl(var(--muted-foreground))"}}),e.jsx(he,{hide:!0}),e.jsx(pe,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:a=>[u(a),"Revenue"]}),e.jsx(fe,{type:"monotone",dataKey:"revenue",stroke:"hsl(var(--accent))",strokeWidth:2,fill:"url(#revenueGradient)"})]})})})})]})}),R.length>0&&e.jsxs(x.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.25},className:"space-y-3",children:[e.jsx("h2",{className:"text-sm font-medium text-muted-foreground",children:"Pending Requests"}),R.map(a=>e.jsx(v,{className:"glass-card border-0",children:e.jsx(N,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:u(a.requested_amount)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.duration_months," months"]})]}),e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/20 text-yellow-400",children:"Under Review"})]})})},a.id))]}),e.jsxs(x.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3},className:"grid grid-cols-2 gap-3",children:[e.jsx(v,{className:"glass-card border-0",children:e.jsxs(N,{className:"p-4 text-center",children:[e.jsx(ge,{className:"w-5 h-5 text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold",children:W}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Backers"})]})}),e.jsx(v,{className:"glass-card border-0",children:e.jsxs(N,{className:"p-4 text-center",children:[e.jsx(je,{className:"w-5 h-5 text-accent mx-auto mb-2"}),e.jsx("p",{className:"text-2xl font-bold",children:u(X)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Raised"})]})})]})]}),!l&&i.length===0&&e.jsx("div",{className:"fixed bottom-24 left-0 right-0 p-5 glass-nav",children:e.jsx(j,{to:"/business-dashboard/new-loan",children:e.jsxs(d,{className:"w-full h-12 gradient-primary rounded-xl font-medium",children:[e.jsx(ve,{className:"w-5 h-5 mr-2"}),"Request Your First Funding"]})})}),e.jsx(te,{})]})}export{Qe 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.