PageSourceSearch

https://app.lucideld.com/assets/D0CXcR8i.js

js lucideld.com collected 2026-10-02 00:32:24 UTC 10,567 bytes, 1 lines download raw bytes

1import{bg as e,ct as s,W as a,ar as t,ay as i,K as n,F as r,fD as l,dn as c,eG as o,fE as d,fF as m,c4 as u,b7 as p}from"./B7N87Dgv.js";import{L as x,a1 as h,h as j,i as g,j as _,k as v,l as y,W as f,B as b,o as N,n as w,X as k,f as C,O as S,c as A,a4 as P,cQ as B,a as T,a2 as I}from"./C8tXTfP_.js";import{a as U}from"./xJ3G7Gft.js";import{S as M}from"./DlC5d5Az.js";import{T as E,a as L,b as O}from"./DKqV88rE.js";import{T as F}from"./SmFzU6mE.js";import{c as D,e as G}from"./sjZp5jap.js";import{H as K,a as V,b as W}from"./IcBk4aGI.js";import{M as Y,C as z}from"./B9f7NGt4.js";import{c as R,d as q}from"./BrRsu7Cv.js";import{C as Q}from"./BSWA7h9H.js";import{D as $}from"./BjgiXnWf.js";import"./wXrpDM_j.js";import"./CG36M057.js";import"./C7jUpZHm.js";import"./CF5ksRBl.js";import"./sFv2CZYC.js";import"./D-tJx9wo.js";import"./xuWk2BOl.js";import"./CUwkehC0.js";import"./CEFRArLM.js";import"./COem9oOj.js";import"./DrJNOjFZ.js";import"./D76sM27c.js";import"./BS7xc076.js";import"./Dn58UZrz.js";import"./VCg4fHUe.js";import"./21rcAoiV.js";import"./BImpqNev.js";import"./D4aovl_3.js";import"./BfaNJGL-.js";function H(){const n=e(),r=s({from:"/_protected/system/revenue/subscriptions"}),l=(e,s)=>{n({to:".",search:a=>({...a,[e]:s,page:1})})},c=Boolean(r.company_name||"active"!==r.status||r.is_blocked||r.allow_without_subscription||r.recurring_cycle),o=r.is_blocked||r.allow_without_subscription||r.status;return a.jsxs("div",{className:"w-table flex flex-wrap items-end gap-2",children:[a.jsxs("div",{className:"grid gap-2",children:[a.jsx(x,{children:"Filter by Status"}),a.jsx(E,{value:o,onValueChange:e=>{n("blocked"!==e?"free"!==e?{to:".",search:s=>({...s,status:e,is_blocked:"",allow_without_subscription:"",page:1})}:{to:".",search:s=>({...s,is_blocked:"",status:"",allow_without_subscription:e,page:1})}:{to:".",search:s=>({...s,is_blocked:e,status:"",allow_without_subscription:"",page:1})})},children:a.jsxs(L,{children:[a.jsx(O,{value:"active",children:"Active"}),a.jsx(O,{value:"canceled",children:"Inactive"}),a.jsx(O,{value:"past_due",children:"Past Due"}),a.jsx(O,{value:"blocked",children:"Blocked"}),a.jsx(O,{value:"free",children:"Free"})]})})]}),a.jsx(h,{label:"Search company",value:r.company_name,onChange:e=>l("company_name",e),className:"w-full sm:max-w-sm"}),a.jsxs("div",{className:"grid flex-1 shrink-0 basis-40 gap-2 sm:flex-0 sm:basis-52",children:[a.jsx(x,{children:"Billing Cycle"}),a.jsxs(j,{value:r.recurring_cycle,onValueChange:e=>l("recurring_cycle",e),children:[a.jsx(g,{className:"w-full",children:a.jsx(_,{placeholder:"Billing Cycle"})}),a.jsxs(v,{children:[a.jsx(y,{value:"month",children:"Monthly"}),a.jsx(y,{value:"year",children:"Yearly"})]})]})]}),a.jsx(f,{queryKeys:"system-subscriptions-list"}),c&&a.jsxs(b,{variant:"ghost",className:"px-2 lg:px-3",onClick:()=>{n({to:".",search:e=>({...e,company_name:"",status:"active",is_blocked:"",allow_without_subscription:"",recurring_cycle:"",page:1})})},children:["Reset",a.jsx(t,{icon:i})]})]})}const X=(e,s)=>{if(e){const[s,t]=e.split(":");return t?a.jsxs(a.Fragment,{children:[t.trim()," - ",a.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:s.trim()})]}):e}return s??"Plan"},J=({item:s})=>{var i;const n=N.getState().hasPermission,p=n("BILLING_PLAN_UPDATE"),x=n("SUBSCRIPTION_CANCEL"),h=n("BLOCK_COMPANY"),j=n("VIEW_SYSTEM_BILLING_MANAGEMENT"),g=n("UPDATE_COMPANY"),[_,v]=r.useState(null),y=s.is_blocked,f="active"===s.status,b=e(),w=null==(i=s.metadata)?void 0:i.company_id,{mutate:k,isPending:C}=R(),{mutate:S,isPending:B}=q(),T=C||B;return a.jsxs(a.Fragment,{children:[a.jsxs(F,{className:"items-end",children:[p&&a.jsxs(D,{onSelect:()=>v("manage"),children:[a.jsx(t,{icon:l}),"Manage Subscriptions"]}),j&&a.jsxs(D,{onSelect:()=>b({to:"/system/revenue/invoices",search:{page:1,limit:20,status:"",search:"",company_id:s.company_id,tenant_group:"all",company_group:"all"}}),children:[a.jsx(t,{icon:c}),"Invoices"]}),g&&a.jsxs(D,{onSelect:()=>v("edit"),children:[a.jsx(t,{icon:o}),"Edit Company"]}),a.jsx(G,{}),h&&a.jsxs(D,{variant:"destructive",onSelect:()=>v("block"),disabled:!w,children:[a.jsx(t,{icon:y?d:m,strokeWidth:2}),y?"Unblock Company":"Block Company"]}),x&&a.jsxs(D,{variant:"destructive",onSelect:()=>v("cancel"),disabled:!f,children:[a.jsx(t,{icon:u}),"Cancel Subscription"]})]}),p&&a.jsx(Y,{item:s,open:"manage"===_,onOpenChange:e=>!e&&v(null)}),x&&a.jsx(z,{item:s,open:"cancel"===_,onOpenChange:e=>!e&&v(null)}),h&&a.jsx(P,{isOpen:"block"===_,isLoading:T,setOpenChange:e=>!e&&v(null),title:y?"Unblock company?":"Block company?",description:y?"Are you sure you want to unblock this company? ":"Are you sure you want to block this company?",confirmButtonText:y?"Unblock":"Block",confirmButtonVariant:y?"default":"destructive",onConfirm:()=>{w&&(y?S:k)({company_id:w},{onSuccess:()=>v(null)})},dialogHeader:a.jsx("div",{className:A("mb-3 flex size-10 items-center justify-center rounded-full",y?"bg-green-100 text-green-500 dark:bg-green-900/50 dark:text-green-400":"bg-red-100 text-red-500 dark:bg-red-900/50 dark:text-red-400"),children:a.jsx(t,{icon:y?d:m,size:20,strokeWidth:2})})}
1),g&&a.jsx(Q,{company_id:s.company_id,open:"edit"===_,onOpenChange:e=>!e&&v(null)})]})};function Z(){var e,s,t;const i=p(),{limit:l,company_name:c,status:o,is_blocked:d,recurring_cycle:m,allow_without_subscription:u}=B.useSearch(),[x,h]=r.useState(1),[j,g]=r.useState(void 0),[_,v]=r.useState([]),y=(({showStatistics:e=!0,status:s,is_blocked:t})=>{const i=(0,N.getState().hasPermission)("GET_COMPANY_QUICK_STATS");return[{header:"Sub-Status",cell:({row:e})=>{const s="active"===e.original.status;return a.jsx(w,{variant:s?"success-secondary":(e.original.status,"destructive-secondary"),children:s?"Active":"past_due"===e.original.status?"Past Due":"Inactive"})}},{header:"Company",cell:({row:e})=>{var s,t;const i=e.original.is_blocked,n=e.original.allow_without_subscription;return a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"font-medium",children:(null==(t=null==(s=e.original)?void 0:s.metadata)?void 0:t.company_name)??"No Company"}),i?a.jsx("div",{className:"text-xs text-destructive",children:"Blocked"}):null,n?a.jsx("div",{className:"text-xs text-green-500",children:"Free"}):null]})}},...s||t?[{header:"Plan",cell:({row:e})=>{const s=e.original.subscription_items??[];return 0===s.length?"N/A":a.jsxs(K,{openDelay:200,children:[a.jsx(V,{asChild:!0,children:a.jsx("div",{className:"cursor-default space-y-1 text-sm text-muted-foreground",children:s.filter(e=>"assets"!==e.product_type).map(e=>a.jsxs("div",{children:[a.jsxs("span",{className:"font-medium",children:[k(e.price_per_unit??0)," - "]}),X(e.product_name??e.name,e.product_type)]},e.price_id))})}),a.jsx(W,{align:"start",side:"right",className:"w-72 p-3",children:a.jsx("div",{className:"space-y-1 text-xs",children:s.map(e=>{const s=(e=>e&&0!==e.length?e.map(e=>{const s=Number(e.unit_amount??e.UnitAmount??0),a=e.up_to??e.UpTo??null,t=Boolean(e.up_to_inf??e.UpToInf??0===a);return{unitAmount:s,upTo:"number"==typeof a?a:null===a?null:Number(a),upToInf:t}}):[])(e.tiers),t=X(e.product_name??e.name,e.product_type),i=s.length>0,n=(e.price_per_unit??0)>0;return i||n?a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"text-sm font-medium text-foreground",children:t}),a.jsxs("div",{className:"space-y-2",children:[n?a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground",children:"Flat"}),a.jsx("span",{className:"font-medium",children:k(e.price_per_unit)})]}):null,s.map((s,t)=>{return a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground",children:(i=s.upTo,n=s.upToInf,n||0===i||null===i?"Unlimited":`Up to ${i}`)}),a.jsx("span",{className:"font-medium",children:k(s.unitAmount)})]},`${e.price_id}-${t}`);var i,n})]})]},e.price_id):a.jsxs("div",{className:"space-y-1",children:[a.jsx("div",{className:"text-sm font-medium text-foreground",children:t}),a.jsx("div",{className:"text-muted-foreground",children:"No pricing"})]},e.price_id)})})})]})}},{header:"Next Renewal",cell:({row:e})=>a.jsxs(a.Fragment,{children:[n(C(e.original.next_cycle),"PPp")," ",S(C(e.original.next_cycle))]})},{header:"Recurring Amount",cell:({row:e})=>k(e.original.recurring_amount??0)}]:[],{header:"Last invoice",cell:({row:e})=>{const s=e.original.last_payment;if(!s)return"N/A";const t=(s.status??"").toLowerCase(),i="paid"===t?"bg-green-500":"pending"===t?"bg-orange-500":"failed"===t?"bg-red-500":"bg-muted-foreground",r=t.charAt(0).toUpperCase()+t.slice(1),l="paid"===t?"Due":"Issued",c=n(C(s.created),"MMM d, yyyy");return a.jsxs("div",{className:"space-y-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:A("size-2 rounded-full",i)}),a.jsx("span",{className:"font-medium",children:r||"Unknown"})]}),a.jsx("div",{children:k(s.amount??0)}),a.jsxs("div",{className:"text-muted-foreground",children:[l," ",c]})]})}},...e&&i?[{header:"Vehicles",cell:({row:e})=>a.jsxs("div",{className:"flex items-end gap-1 leading-none",children:[a.jsx("span",{className:"flex font-medium",children:e.original.active_vehicle}),"/",a.jsx("span",{className:"text-xs leading-none text-gray-500",children:e.original.total_vehicle})]})},{header:"Camera",cell:({row:e})=>a.jsxs("div",{className:"flex items-end gap-1 leading-none",children:[a.jsx("span",{className:"flex font-medium",children:e.original.active_camera}),"/",a.jsx("span",{className:"text-xs leading-none text-gray-500",children:e.original.total_camera})]})}
1]:[],{header:"Actions",size:10,cell:({row:e})=>a.jsx(J,{item:e.original})}]})({showStatistics:T(e=>e.showStatistics),status:o,is_blocked:d});r.useEffect(()=>{h(1),g(void 0),v([])},[c,o,d,m,u,l]);const{data:f,isPending:b}=U({page:x,limit:l,company_name:c,status:o,is_blocked:d,recurring_cycle:m,allow_without_subscription:u,page_token:j}),P=_.length>0&&x>1,E=null==(s=null==(e=null==f?void 0:f.data)?void 0:e.paging)?void 0:s.nextPageToken,L=Boolean(E);return a.jsxs("div",{className:"space-y-4",children:[a.jsx(M,{}),a.jsx(H,{}),a.jsx(I,{isLoading:b,columns:y,data:(null==(t=null==f?void 0:f.data)?void 0:t.items)??[],hidePagination:!0}),a.jsx($,{page:x,isPending:b,canPrev:P,canNext:L,onFirst:()=>{P&&(h(1),v([]),g(void 0),i.invalidateQueries({predicate:e=>"system-subscriptions-list"===e.queryKey[0]}))},onPrev:()=>{P&&(h(e=>Math.max(1,e-1)),g(()=>{const e=[..._],s=e.pop();return v(e),s}))},onNext:()=>{L&&(v(e=>[...e,j??""]),g(E),h(e=>e+1))}})]})}export{Z as component};

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.