1import{d4 as ke,dI as ve,I as Ce,ey as we,di as ye,d7 as Ae,d9 as Se,r as o,j as e,b6 as w,J as Le,S as De,Y as J,ap as m,v as Me,b4 as Ie,L as Te,K as Ee,k as p,ao as O,d as Pe,D as $e,b as Fe,as as B,bf as X,a as Z,b7 as ee,bT as ze,bv as te,bw as se,by as ae,bz as re,b9 as Oe,bB as de,bx as Be,cf as H,cg as V,ch as R,ci as U,cj as u,ar as y,aI as h}from"./index-CpeGhXo5.js";import{e as A,b as _,d as He}from"./expenseDraft-DqR0Jp71.js";import{m as Ve}from"./financeMappers-CUv1G2pV.js";import{L as le}from"./lock-open-Cmtyk41m.js";function Ge(){const ne=ke(),{isFinanceHead:oe,isExecutiveBoard:ie,activeRole:ce}=ve(),xe=oe||ie,l=Ce(t=>t.auth?.user),{data:M}=we(),{data:S}=ye({limit:500,status:"Active"}),{data:K,isLoading:me,refetch:ue}=Ae({limit:500}),[he]=Se(),[b,L]=o.useState(()=>A()),[g,I]=o.useState("all"),[T,Re]=o.useState(""),[pe,f]=o.useState(!1),[N,k]=o.useState(null),D=o.useMemo(()=>(M?.items??[]).map(s=>{const r=s.bankName||s.bank||"Bank",a=s.accountNumber?.slice(-4)||s.accountNo?.slice(-4)||"â¢â¢â¢â¢",i=s.accountType||s.type||"Current";return`${r} â¢â¢ ${a} (${i})`}),[M]),E=o.useMemo(()=>{const s=(S?.items||(Array.isArray(S)?S:[])).map(a=>{const i=`${a.firstName||""} ${a.lastName||""}`.trim()||a.name||"Staff",c=a.designation||a.jobTitle?` (${a.designation||a.jobTitle})`:"";return`${i}${c}`});if(s.length>0)return s;const r=l?.fullName||l?.name;return r?[r]:[]}
1,[S,l]),[d,x]=o.useState({bankAccount:"",cardNickname:"",cardHolderName:"",last4:"",cardNetwork:"Visa",cardType:"Corporate Credit Card",expiryDate:"",monthlyLimit:"500000",custodianName:""}),P=()=>{k(null),x({bankAccount:D[0]||"",cardNickname:"",cardHolderName:l?.fullName||l?.name||"",last4:"",cardNetwork:"Visa",cardType:"Corporate Credit Card",expiryDate:"",monthlyLimit:"500000",custodianName:E[0]||l?.fullName||l?.name||""}),f(!0)},Q=t=>{k(t.id),x({bankAccount:t.bankAccountName||D[0]||"Corporate Bank Account",cardNickname:t.cardNickname,cardHolderName:t.cardHolderName,last4:t.last4,cardNetwork:t.cardNetwork,cardType:t.cardType,expiryDate:t.expiryDate,monthlyLimit:t.monthlyLimit.toString(),custodianName:t.custodianName}),f(!0)},be=t=>{t.preventDefault();const s=d.last4.replace(/\D/g,"");if(s.length!==4){h.error("Please enter a valid 4-digit card ending");return}const r=(M?.items??[]).find(a=>{const i=a.bankName||a.bank||"Bank",c=a.accountNumber?.slice(-4)||a.accountNo?.slice(-4)||"â¢â¢â¢â¢",F=a.accountType||a.type||"Current";return`${i} â¢â¢ ${c} (${F})`===d.bankAccount});if(N){const a=b.find(c=>c.id===N),i={id:N,bankAccountId:r?.id||a?.bankAccountId,bankAccountName:d.bankAccount,cardNickname:d.cardNickname.trim()||`Corporate ${d.cardNetwork} Card`,cardHolderName:d.cardHolderName.trim()||"Company Custodian",last4:s,cardNetwork:d.cardNetwork,cardType:d.cardType,expiryDate:d.expiryDate.trim()||"12/28",monthlyLimit:parseFloat(d.monthlyLimit)||5e5,currentSpend:a?.currentSpend||0,status:a?.status||"Active",custodianName:d.custodianName};_(i),L(A()),f(!1),k(null),h.success(`Corporate Card (â¢â¢${s}) updated successfully!`)}else{const a={id:`card-${Date.now()}`,bankAccountId:r?.id,bankAccountName:d.bankAccount,cardNickname:d.cardNickname.trim()||`Corporate ${d.cardNetwork} Card`,cardHolderName:d.cardHolderName.trim()||"Company Custodian",last4:s,cardNetwork:d.cardNetwork,cardType:d.cardType,expiryDate:d.expiryDate.trim()||"12/28",monthlyLimit:parseFloat(d.monthlyLimit)||5e5,currentSpend:0,status:"Active",custodianName:d.custodianName};_(a),L(A()),f(!1),h.success(`Corporate Card (â¢â¢${s}) issued and linked successfully!`)}x({bankAccount:D[0]||"",cardNickname:"",cardHolderName:l?.fullName||l?.name||"",last4:"",cardNetwork:"Visa",cardType:"Corporate Credit Card",expiryDate:"12/28",monthlyLimit:"500000",custodianName:E[0]||l?.fullName||l?.name||""})},G=t=>{const s=t.status==="Active"?"Suspended":"Active",r={...t,status:s};_(r),L(A()),h.success(`Card â¢â¢${t.last4} is now ${s}`)},ge=t=>{He(t),L(A()),h.success("Card removed from corporate portfolio")},v=o.useMemo(()=>(K?.items??[]).map(Ve).filter(s=>{const r=(s.paymentMethod||"").toLowerCase(),a=(s.description||"").toLowerCase(),i=r.includes("card")||r.includes("pos"),c=a.includes("corporate card")||a.includes("credit card")||a.includes("debit card")||a.includes("pos ");return i||c}).map(s=>{const r=b.find(C=>C.last4&&(s.description.includes(C.last4)||s.voucherNo.includes(C.last4))||C.cardNickname&&s.description.toLowerCase().includes(C.cardNickname.toLowerCase()))||b[0],a=r?.last4||"â¢â¢â¢â¢",i=r?.cardNickname||s.paymentMethod||"Corporate Card",c=r?.cardNetwork||"Corporate",F=r?.id||"unassigned";let z="Pending_Audit";return s.status==="Approved"||s.status==="Paid"?z="CFO_Approved":s.attachmentUrl&&(z="AI_Verified"),{id:s.id,date:s.date?new Date(s.date).toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"}):"â",cardId:F,cardName:i,last4:a,network:c,merchant:s.vendor||s.description||"Merchant POS",category:s.category||"General Expense",amount:Number(s.net||s.gross||0),custodian:s.employee||s.approver||l?.fullName||l?.name||"Finance Staff",status:z,rawExpense:s}}),[K,b,l]),n=o.useMemo(()=>b.map(t=>{const s=v.filter(r=>r.cardId===t.id||r.last4===t.last4).reduce((r,a)=>r+a.amount,0);return{...t,currentSpend:s}}),[b,v]),$=o.useMemo(()=>n.reduce((t,s)=>t+(s.monthlyLimit||0),0),[n]),W=o.useMemo(()=>n.reduce((t,s)=>t+(s.currentSpend||0),0),[n]),Y=$>0?Math.round(W/$*100):0,[fe,j]=o.useState(!1),Ne=async t=>{const s=v.find(r=>r.id===t);if(s?.rawExpense?.id)try{await he({id:s.rawExpense.id,body:{status:"Approved"}}).unwrap(),h.success(`Transaction for "${s.merchant}" approved & posted to Expense Ledger!`),ue()}catch(r){h.error(r?.data?.message||"Failed to approve transaction in ledger")}else h.success("Transaction approved!")},q=o.useMemo(()=>v.filter(t=>{if(g!=="all"&&t.cardId!==g)return!1;if(T.trim()){const s=T.toLowerCase().trim();return t.merchant.toLowerCase().includes(s)||t.cardName.toLowerCase().includes(s)||t.custodian.toLowerCase().includes(s)||t.last4.includes(s)||t.category.toLowerCase().includes(s)}return!0}),[v,g,T]),je=o.useMemo(()=>[{key:"date",id:"date",header:"Date & Time",label:"Date & Time",accessorKey:"date",sortable:!0,render:t=>e.jsx("span",{className:"text-xs text-slate-700 dark:text-slate-300 font-medium whitespace-nowrap",children:t.date})},{key:"card",id:"card",header:"Card Used",label:"Card Used",render:t=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-8 h-5 rounded bg-slate-900 text-white font-mono text-[9px] font-bold flex items-center justify-center shrink-0",children:["â¢â¢",t.last4]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-xs text-foreground",children:t.cardName}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[t.network," Corporate"]})]})]})},{key:"merchant",id:"merchant",header:"Merchant & Narration",label:"Merchant & Narration",minWidth:200,render:t=>e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-xs text-foreground",children:t.merchant}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:t.category})]})},{key:"custodian",id:"custodian",header:"Custodian / Staff",label:"Custodian / Staff",render:t=>e.jsx("span",{className:"text-xs font-medium text-slate-700 dark:text-slate-300",children:t.custodian})},{key:"amount",id:"amount",header:"Amount (â¹)",label:"Amount (â¹)",align:"right",render:t=>e.jsxs("span",{className:"text-xs font-bold text-slate-900 dark:text-slate-100",children:["â¹",t.amount.toLocaleStr
1ing("en-IN")]})},{key:"status",id:"status",header:"Audit & Verification Status",label:"Audit & Verification Status",width:"180px",align:"center",render:t=>t.status==="CFO_Approved"?e.jsxs(w,{variant:"outline",className:"bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300 border-emerald-200 dark:border-emerald-800 gap-1 py-0.5 text-[10px] font-semibold",children:[e.jsx(Le,{className:"w-3 h-3 text-emerald-600"})," CFO Approved & Booked"]}):t.status==="AI_Verified"?e.jsxs(w,{variant:"outline",className:"bg-indigo-50 text-indigo-700 dark:bg-indigo-950 dark:text-indigo-300 border-indigo-200 dark:border-indigo-800 gap-1 py-0.5 text-[10px] font-semibold",children:[e.jsx(De,{className:"w-3 h-3 text-indigo-600"})," AI Matched (Receipt Linked)"]}):e.jsxs(w,{variant:"outline",className:"bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300 border-amber-200 dark:border-amber-800 gap-1 py-0.5 text-[10px] font-semibold",children:[e.jsx(J,{className:"w-3 h-3 text-amber-600"})," Pending Audit"]})},{key:"action",id:"action",header:"Action",label:"Action",width:"130px",align:"right",fixed:"right",render:t=>t.status==="CFO_Approved"?e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium italic",children:"In Expenses"}):e.jsxs(m,{size:"sm",onClick:()=>Ne(t.id),className:"h-7 px-2.5 bg-blue-600 hover:bg-blue-700 text-white font-semibold text-xs gap-1 shadow-2xs cursor-pointer",children:[e.jsx(Me,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Approve Entry"})]})}],[]);return e.jsxs("div",{className:"flex flex-col flex-1 h-full min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar bg-slate-50/50 dark:bg-slate-950/50",children:[e.jsx(Ie,{title:"Corporate Cards & Banking Plastics",subtitle:"Manage corporate credit facilities, connected debit cards, and automated POS expense tracking",accentVar:"--mod-finance",showMonthYearFilter:!1,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Te,{to:`${ne}/bank-accounts`,className:"h-8 px-3 rounded-md border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-semibold text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors shadow-2xs cursor-pointer",children:[e.jsx(Ee,{className:"w-3.5 h-3.5"})," Back to Bank Accounts"]}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>j(!0),className:"h-8 px-3 rounded-md border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 hover:bg-slate-50 dark:hover:bg-slate-800 text-xs font-semibold text-slate-700 dark:text-slate-200 inline-flex items-center gap-1.5 transition-colors shadow-2xs cursor-pointer",children:[e.jsx(p,{className:"w-3.5 h-3.5 text-blue-600"})," All Cards (",n.length,")"]}),e.jsxs(m,{size:"sm",onClick:P,className:"h-8 px-3.5 rounded-md bg-blue-600 hover:bg-blue-700 text-white font-semibold text-xs inline-flex items-center gap-1.5 shadow-2xs transition-colors cursor-pointer",children:[e.jsx(O,{className:"w-3.5 h-3.5"})," Issue / Connect Card"]})]})}),e.jsxs("div",{className:"p-3.5 pb-16 space-y-3.5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"p-3.5 rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-xs flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-blue-50 dark:bg-blue-950/50 border border-blue-200 dark:border-blue-800 flex items-center justify-center text-blue-600 shrink-0",children:e.jsx(p,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground",children:"Active Plastics"}),e.jsxs("p",{className:"text-base font-bold text-foreground",children:[n.filter(t=>t.status==="Active").length," Active Cards"]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[n.length," Total Issued in ERP"]})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-xs flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-emerald-50 dark:bg-emerald-950/50 border border-emerald-200 dark:border-emerald-800 flex items-center justify-center text-emerald-600 shrink-0",children:e.jsx(Pe,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground",children:"Monthly Credit Pool"}),e.jsxs("p",{className:"text-base font-bold text-foreground",children:["â¹",$.toLocaleStr
1ing("en-IN")]}),e.jsxs("span",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 font-medium",children:["Across ",n.length," corporate facilities"]})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-xs flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-indigo-50 dark:bg-indigo-950/50 border border-indigo-200 dark:border-indigo-800 flex items-center justify-center text-indigo-600 shrink-0",children:e.jsx($e,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground",children:"Current Utilization"}),e.jsxs("p",{className:"text-base font-bold text-foreground",children:["â¹",W.toLocaleString("en-IN")]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-slate-100 dark:bg-slate-800 overflow-hidden",children:e.jsx("div",{className:"h-full bg-indigo-600 rounded-full",style:{width:`${Math.min(100,Y)}%`}})}),e.jsxs("span",{className:"text-[10px] font-semibold text-indigo-600 dark:text-indigo-400",children:[Y,"% limit used"]})]})]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-xs flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-purple-50 dark:bg-purple-950/50 border border-purple-200 dark:border-purple-800 flex items-center justify-center text-purple-600 shrink-0",children:e.jsx(Fe,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground",children:"CFO Controller"}),e.jsx("p",{className:"text-xs font-bold text-foreground truncate max-w-[160px]",children:l?.fullName||l?.name||"Finance Head"}),e.jsx("span",{className:"text-[10px] text-purple-600 dark:text-purple-400 font-medium",children:`${ce} Oversight`})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl p-3.5 shadow-xs space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{className:"w-4 h-4 text-blue-600"}),e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-slate-800 dark:text-slate-200",children:["Corporate Cards Portfolio (",n.length,")"]}),e.jsx("span",{className:"text-[11px] text-muted-foreground hidden sm:inline",children:"⢠Click card to filter ledger below"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g!=="all"&&e.jsx("button",{type:"button",onClick:()=>I("all"),className:"text-xs text-blue-600 dark:text-blue-400 font-semibold hover:underline cursor-pointer",children:"Clear Filter"}),e.jsx(m,{variant:"outline",size:"sm",onClick:()=>j(!0),className:"h-7 px-2.5 text-xs font-semibold border-slate-200 dark:border-slate-800 hover:bg-slate-50 dark:hover:bg-slate-800 cursor-pointer shadow-2xs",children:"Manage All Cards in Modal"})]})]}),n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center border border-dashed border-slate-200 dark:border-slate-800 rounded-xl bg-slate-50/50 dark:bg-slate-900/30",children:[e.jsx(p,{className:"w-8 h-8 text-muted-foreground/40 mb-2"}),e.jsx("h4",{className:"text-xs font-bold text-foreground",children:"No Corporate Plastics Linked"}),e.jsx("p",{className:"text-[11px] text-muted-foreground max-w-sm mt-0.5",children:"Issue or connect corporate credit cards and business debit plastics to track real-time POS settlements and employee spend limits."}),e.jsxs(m,{size:"sm",onClick:P,className:"mt-3 h-7 px-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold text-xs gap-1.5 shadow-2xs cursor-pointer",children:[e.jsx(O,{className:"w-3.5 h-3.5"})," Issue / Connect Card"]})]}):e.jsx("div",{className:"flex items-center gap-3 overflow-x-auto pb-1.5 custom-scrollbar",children:n.map(t=>{const s=g===t.id,r=t.currentSpend||0,a=t.monthlyLimit||5e5,i=Math.round(r/a*100);return e.jsxs("div",{onClick:()=>I(s?"all":t.id),className:B("shrink-0 w-72 rounded-xl p-3 border transition-all cursor-pointer select-none flex flex-col justify-between h-36 relative overflow-hidden",t.cardNetwork==="Visa"?"bg-gradient-to-tr from-slate-900 via-slate-800 to-blue-950 text-white border-blue-500/30":t.cardNetwork==="Mastercard"?"bg-gradient-to-tr from-slate-950 via-slate-900 to-rose-950 text-white border-rose-500/30":t.cardNetwork==="Amex"?"bg-gradient-to-tr from-slate-950 via-slate-900 to-cyan-950 text-white border-cyan-500/30":"bg-gradient-to-tr from-slate-950 via-slate-900 to-emerald-950 text-white border-emerald-500/30",s&&"ring-2 ring-blue-500 shadow-md scale-[1.01]",t.status==="Suspended"&&"opacity-60 saturate-50"),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-bold truncate max-w-[170px]",children:t.cardNickname}),e.jsxs("span",{className:"text-[10px] text-white/70 block truncate max-w-[170px]",children:[t.custodianName.split(" ")[0]," ⢠",t.cardType]})]}),e.jsx("span",{className:"text-[10px] font-bold font-mono uppercase bg-white/10 px-1.5 py-0.5 rounded",children:t.cardNetwork})]}),e.jsxs("div",{className:"font-mono text-sm tracking-wider font-bold text-white/90",children:["â¢â¢â¢â¢ â¢â¢â¢â¢ â¢â¢â¢â¢ ",t.last4]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-[9px] text-white/70",children:[e.jsxs("span",{children:["â¹",r.toLocaleStr
1ing("en-IN")," / â¹",a.toLocaleString("en-IN")]}),e.jsxs("span",{children:[i,"% used"]})]}),e.jsx("div",{className:"w-full bg-white/20 h-1 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-400 rounded-full",style:{width:`${Math.min(100,i)}%`}})}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-white/10",children:[e.jsx("span",{className:B("text-[9px] font-bold px-1.5 py-0.2 rounded",t.status==="Active"?"text-emerald-300 bg-emerald-950/60":"text-amber-300 bg-amber-950/60"),children:t.status}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),Q(t)},className:"px-2 py-0.5 rounded bg-white/20 hover:bg-blue-600 text-white text-[10px] font-semibold transition-colors cursor-pointer flex items-center gap-1",title:"Edit Card Details",children:[e.jsx(X,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:"Edit"})]}),e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),G(t)},className:"p-1 rounded bg-white/20 hover:bg-white/30 text-white text-[10px] transition-colors cursor-pointer",title:t.status==="Active"?"Freeze Card":"Unfreeze Card",children:t.status==="Active"?e.jsx(Z,{className:"w-2.5 h-2.5"}):e.jsx(le,{className:"w-2.5 h-2.5 text-emerald-300"})})]})]})]})]},t.id)})})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-xl shadow-xs overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-border flex flex-col md:flex-row md:items-center justify-between gap-3 bg-slate-50/50 dark:bg-slate-900/50",children:[e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-blue-50 dark:bg-blue-950/60 border border-blue-200 dark:border-blue-800 text-blue-600 flex items-center justify-center shrink-0",children:e.jsx(J,{className:"w-3.5 h-3.5"})}),e.jsx("div",{children:e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider text-slate-800 dark:text-slate-200",children:"Card Transactions & POS Audit Trail"})}),e.jsxs("span",{className:"text-[11px] text-muted-foreground font-semibold",children:["(",q.length," entries)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300 shrink-0",children:"Filter by Card:"}),e.jsx("div",{className:"w-64",children:e.jsx(ee,{value:g,onChange:I,options:[{value:"all",label:"All Corporate Cards"},...n.map(t=>({value:t.id,label:`${t.cardNickname} (â¢â¢${t.last4}) - ${t.custodianName}`}))],placeholder:"Filter by Corporate Card",searchPlaceholder:"Search card or custodian...",triggerClassName:"h-8 text-xs font-semibold",enableEditDeleteAdd:!1})})]})]}),e.jsx("div",{className:"w-full",children:e.jsx(ze,{rows:q,rowKey:t=>t.id,columns:je,searchKeys:["merchant","cardName","custodian","category","last4"],searchPlaceholder:"Search card transactions by merchant, custodian, or last 4â¦",storageKey:"corporate-cards-tx-table",initialPageSize:10,fetching:me,emptyMessage:"No corporate card transactions recorded yet. Card POS transactions and expenses paid via corporate credit or debit cards will appear here."})})]})]}),e.jsx(te,{open:fe,onOpenChange:j,children:e.jsxs(se,{className:"max-w-3xl p-0 gap-0 overflow-hidden rounded-2xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-2xl",children:[e.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between bg-slate-50/70 dark:bg-slate-800/40",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-50 dark:bg-blue-950/60 border border-blue-200 dark:border-blue-800 text-blue-600 flex items-center justify-center shrink-0",children:e.jsx(p,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs(ae,{className:"text-sm font-bold text-foreground",children:["Corporate Cards Portfolio (",n.length,")"]}),e.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Manage issued corporate plastics, edit limits, freeze access, or delete cards."})]})]}),e.jsxs(m,{size:"sm",onClick:()=>{j(!1),P()},className:"h-8 px-3 bg-blue-600 hover:bg-blue-700 text-white text-xs font-semibold gap-1 shadow-2xs cursor-pointer",children:[e.jsx(O,{className:"w-3.5 h-3.5"})," Issue New Card"]})]}),e.jsx("div",{className:"p-4 max-h-[60vh] overflow-y-auto space-y-2.5 custom-scrollbar",children:n.length===0?e.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[e.jsx(p,{className:"w-10 h-10 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"No corporate cards in portfolio"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:'Click "Issue New Card" to link a corporate credit or debit plastic to your bank accounts.'})]}):n.map(t=>{const s=t.currentSpend||0,r=t.monthlyLimit||5e5,a=Math.round(s/r*100);return e.jsxs("div",{className:"p-3 rounded-xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-800/50 flex flex-col sm:flex-row sm:items-center justify-between gap-3 shadow-2xs hover:border-blue-500/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("div",{className:"w-10 h-7 rounded bg-slate-900 text-white font-mono text-[10px] font-bold flex items-center justify-center shrink-0",children:["â¢â¢",t.last4]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-xs font-bold text-foreground truncate",children:t.cardNickname}),e.jsx(w,{variant:"outline",className:"text-[9px] py-0 px-1 font-semibold",children:t.cardNetwork}),e.jsx(w,{variant:"outline",className:B("text-[9px] py-0 px-1 font-semibold",t.status==="Active"?"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950 dark:text-emerald-300":"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950 dar
1k:text-amber-300"),children:t.status})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground truncate",children:["Custodian: ",e.jsx("span",{className:"font-semibold text-foreground",children:t.custodianName})," ⢠A/C: ",t.bankAccountName||"Primary Current"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between sm:justify-end gap-3 shrink-0",children:[e.jsxs("div",{className:"text-right text-xs",children:[e.jsxs("div",{className:"font-bold text-foreground",children:["â¹",s.toLocaleString("en-IN")," ",e.jsxs("span",{className:"text-muted-foreground font-normal text-[10px]",children:["/ â¹",r.toLocaleString("en-IN")]})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[a,"% utilized"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>{j(!1),Q(t)},className:"h-7 px-2.5 text-xs font-semibold border-slate-200 dark:border-slate-700 hover:bg-slate-100 dark:hover:bg-slate-800 gap-1 cursor-pointer",children:[e.jsx(X,{className:"w-3 h-3 text-blue-600"})," Edit"]}),e.jsx(m,{size:"sm",variant:"outline",onClick:()=>G(t),className:"h-7 px-2 border-slate-200 dark:border-slate-700 hover:bg-slate-100 dark:hover:bg-slate-800 cursor-pointer",title:t.status==="Active"?"Freeze Card":"Unfreeze Card",children:t.status==="Active"?e.jsx(Z,{className:"w-3 h-3"}):e.jsx(le,{className:"w-3 h-3 text-emerald-600"})}),xe&&e.jsx(m,{size:"sm",variant:"outline",onClick:()=>ge(t.id),className:"h-7 px-2 border-rose-200 dark:border-rose-900 text-rose-600 hover:bg-rose-50 dark:hover:bg-rose-950/50 cursor-pointer",title:"Delete Card",children:e.jsx(Oe,{className:"w-3 h-3"})})]})]})]},t.id)})}),e.jsx(de,{className:"p-3 border-t border-border bg-slate-50/50 dark:bg-slate-900/50 flex justify-end",children:e.jsx(m,{variant:"outline",size:"sm",onClick:()=>j(!1),className:"h-8 px-3 text-xs font-semibold cursor-pointer",children:"Close"})})]})}),e.jsx(te,{open:pe,onOpenChange:t=>{f(t),t||k(null)},children:e.jsxs(se,{className:"max-w-lg p-5 bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 shadow-xl rounded-xl",children:[e.jsxs(Be,{children:[e.jsxs(ae,{className:"text-base font-bold text-foreground flex items-center gap-2",children:[e.jsx(p,{className:"w-5 h-5 text-primary"}),N?"Edit Corporate Card Details":"Issue / Connect Corporate Card"]}),e.jsx(re,{className:"text-xs text-muted-foreground",children:N?"Update spending limits, cardholder name, network classification, or HRMS custodian.":"Link a new corporate credit or business debit card to an active company bank account."})]}),e.jsxs("form",{onSubmit:be,className:"space-y-3.5 my-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Parent Bank Account *"}),e.jsxs(H,{value:d.bankAccount,onValueChange:t=>x(s=>({...s,bankAccount:t})),children:[e.jsx(V,{className:"h-9 text-xs",children:e.jsx(R,{})}),e.jsx(U,{children:D.map(t=>e.jsx(u,{value:t,children:t},t))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Card Network *"}),e.jsxs(H,{value:d.cardNetwork,onValueChange:t=>x(s=>({...s,cardNetwork:t})),children:[e.jsx(V,{className:"h-9 text-xs",children:e.jsx(R,{})}),e.jsxs(U,{children:[e.jsx(u,{value:"Visa",children:"Visa Commercial"}),e.jsx(u,{value:"Mastercard",children:"Mastercard Business"}),e.jsx(u,{value:"RuPay",children:"RuPay Corporate"}),e.jsx(u,{value:"Amex",children:"American Express"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Card Type *"}),e.jsxs(H,{value:d.cardType,onValueChange:t=>x(s=>({...s,cardType:t})),children:[e.jsx(V,{className:"h-9 text-xs",children:e.jsx(R,{})}),e.jsxs(U,{children:[e.jsx(u,{value:"Corporate Credit Card",children:"Corporate Credit Card"}),e.jsx(u,{value:"Business Debit Card",children:"Business Debit Card"}),e.jsx(u,{value:"Virtual Card",children:"Virtual SaaS Card"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Card Nickname *"}),e.jsx(y,{value:d.cardNickname,onChange:t=>x(s=>({...s,cardNickname:t.target.value})),placeholder:"e.g. Travel & Entertainment",className:"h-9 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Last 4 Digits *"}),e.jsx(y,{maxLength:4,value:d.last4,onChange:t=>x(s=>({...s,last4:t.target.value.replace(/\D/g,"")})),placeholder:"4521",className:"h-9 text-xs font-mono font-bold tracking-widest text-center"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Cardholder Name *"}),e.jsx(y,{value:d.cardHolderName,onChange:t=>x(s=>({...s,cardHolderName:t.target.value})),placeholder:l?.fullName||l?.name||"Authorized Cardholder",className:"h-9 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Monthly Limit (â¹) *"}),e.jsx(y,{type:"number",value:d.monthlyLimit,onChange:t=>x(s=>({...s,monthlyLimit:t.target.value})),placeholder:"500000",className:"h-9 text-xs font-mono"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Staff Custodian (HRMS) *"}),e.jsx(ee,{value:d.custodianName,onChange:t=>x(s=>({...s,custodianName:t})),options:E.map(t=>({value:t,label:t})),placeholder:"Select Staff...",searchPlaceholder:"Search staff...",triggerClassName:"h-9 text-xs",enableEditDeleteAdd:!1})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:"Expiry Date *"}),e.jsx(y,{maxLength:5,value:d.expiryDate,onChange:t=>x(s=>({...s,expiryDate:t.target.value})),placeholder:"12/28",className:"h-9 text-xs font-mono text-center"})]})]}),e.jsxs(de,{className:"pt-3",children:[e.jsx(m,{type:"button",variant:"ghost",size:"sm",onClick:()=>{f(!1),k(null)},children:"Cancel"}),e.jsx(m,{type:"submit",size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white font-bold text-xs cursor-pointer",children:N?"Update Card":"Save & Link Card"})]})]})]})})]})}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.