PageSourceSearch

https://myloanbot.ai/assets/AdminPrograms-DRHGi6Er.js

js myloanbot.ai collected 2026-10-05 15:02:25 UTC 13,749 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProgramDataHealth-3Ehfht-b.js","assets/main-C2rM9v8a.js","assets/main-B1M7xErQ.css","assets/badge-C2qhnPay.js","assets/triangle-alert-Cmt4eS2T.js","assets/circle-x-Cupnu3dw.js","assets/BulkUpdatePrograms-MCDbKV2x.js","assets/file-json-QzcFNJoJ.js","assets/circle-play-DldB8Y1t.js","assets/save-Cbrx7ood.js","assets/circle-alert-D9Ijb7s9.js"])))=>i.map(i=>d[i]);
2import{u as le,p as ne,q as ie,r as c,s as z,o as oe,j as e,v as ce,h as de,B as x,L as B,n as me,D as ue,P as xe,w as he,E as G,x as W,f as pe,t as b,b as h,y as ge,z as fe,F as je,G as ye,H as I,J as be,_ as X}from"./main-C2rM9v8a.js";import{C as we}from"./CopyableId-DVAGrn4x.js";import{T as Ne,a as ve,b as k,c as U}from"./tabs-BKEm4Xxv.js";import{S as q,a as M,b as V,c as J,d as o}from"./select-B7bx_0Qj.js";import{S as Se}from"./StatusBadge-B6vuWQGO.js";import{l as Q,r as Pe,a as De}from"./pagedLists-B1Gj1enB.js";import{u as Ce,a as ke,L as E,b as K,c as Ee}from"./ListLoading-iOv0ey7q.js";import{R as Ae}from"./refresh-cw-D4MlX-SV.js";import{T as Y}from"./trash-2-hlw3DPhz.js";import{H as Te}from"./hard-drive-BzZXkVnF.js";import{E as Fe}from"./ellipsis-BxKpAn9R.js";import{P as Le}from"./pencil-BlDWg7wc.js";import"./chevron-up-DG4nd5Ke.js";import"./skeleton-B_Vx4BUG.js";const He=c.lazy(()=>X(()=>import("./ProgramDataHealth-3Ehfht-b.js"),__vite__mapDeps([0,1,2,3,4,5]))),_e=c.lazy(()=>X(()=>import("./BulkUpdatePrograms-MCDbKV2x.js"),__vite__mapDeps([6,1,2,7,8,9,10,5]))),$e=["name","extractedFromDrive","googleDriveFileName","primaryCategory","programType","programStatus","loanPurpose"],Ie=["name","primaryCategory","programStatus","creditScoreRequirementType","universalCreditScore","dtiType","universalDtiPercent","ltvType","universalLtv","propertyTypes","occupancyTypes","availabilityStates"];function Ue({items:r,selected:f,onToggleOne:A,onToggleAll:D,onChanged:l}){const T=ge();async function w(a){const p=a.programStatus==="PUBLISHED"?"DRAFT":"PUBLISHED";try{await h.entities.Program.update(a.id,{programStatus:p}),await l()}catch(n){console.error("[AdminPrograms] Status update failed:",n),b.error("Could not update the program. Please retry.")}}async function F(a){if(window.confirm(`Delete "${a.name}"? This cannot be undone.`))try{await h.entities.Program.delete(a.id),await l()}catch(p){console.error("[AdminPrograms] Delete failed:",p),b.error("Could not delete the program. Please retry.")}}if(r.length===0)return e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:"No programs found"})});const j=r.length>0&&r.every(a=>f.has(a.id)),L=r.some(a=>f.has(a.id))&&!j;return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"min-w-[900px]",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"py-3 px-4 w-10",children:e.jsx("input",{type:"checkbox","aria-label":"Select loaded programs",className:"w-4 h-4 rounded border-border cursor-pointer accent-primary",checked:j,ref:a=>{a&&(a.indeterminate=L)},onChange:()=>D()})}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Category"}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Type"}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Purpose"}),e.jsx("th",{className:"text-left py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"ID"}),e.jsx("th",{className:"text-right py-3 px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Actions"})]})}),e.jsx("tbody",{children:r.map(a=>e.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"py-3 px-4 w-10",onClick:p=>p.stopPropagation(),children:e.jsx("input",{type:"checkbox","aria-label":`Select ${a.name}
2`,className:"w-4 h-4 rounded border-border cursor-pointer accent-primary",checked:f.has(a.id),onChange:()=>A(a.id)})}),e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{to:`/admin/programs/${a.id}/edit`,className:"font-medium text-sm hover:text-primary transition-colors",children:a.name}),a.extractedFromDrive&&e.jsx("span",{title:`Extracted from Google Drive · ${a.googleDriveFileName||""}`,children:e.jsx(Te,{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0"})})]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:a.primaryCategory||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:a.programType||"—"}),e.jsx("td",{className:"py-3 px-4",children:e.jsx(Se,{status:a.programStatus})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:a.loanPurpose||"—"}),e.jsx("td",{className:"py-3 px-4",children:e.jsx(we,{id:a.id})}),e.jsx("td",{className:"py-3 px-4 text-right",children:e.jsxs(fe,{children:[e.jsx(je,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Program options",children:e.jsx(Fe,{className:"w-4 h-4"})})}),e.jsxs(ye,{align:"end",className:"w-44",children:[e.jsxs(I,{onClick:()=>T(`/admin/programs/${a.id}/edit`),children:[e.jsx(Le,{className:"w-4 h-4 mr-2"})," Edit Program"]}),e.jsx(I,{onClick:()=>w(a),children:a.programStatus==="PUBLISHED"?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 mr-2"})," Unpublish"]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4 mr-2"})," Publish"]})}),e.jsx(be,{}),e.jsxs(I,{onClick:()=>F(a),className:"text-destructive focus:text-destructive",children:[e.jsx(Y,{className:"w-4 h-4 mr-2"})," Delete"]})]})]})})]},a.id))})]})})})}function Ze(){const{user:r}=le(),f=ne(),[A]=ie(),D=A.get("module"),[l,T]=c.useState(D==="ADD_ON"?"add-on":D==="HEALTH"?"data-health":"first-mortgage"),[w,F]=c.useState(""),[j,L]=c.useState("all"),[a,p]=c.useState("all"),[n,N]=c.useState(new Set),[v,C]=c.useState(!1),H=Ce(JSON.stringify({search:w,statusFilter:j,categoryFilter:a})),y=JSON.parse(H),S={};Q(y.search)&&(S.name={$regex:Q(y.search),$options:"i"}),y.statusFilter!=="all"&&(S.programStatus=y.statusFilter),y.categoryFilter!=="all"&&(S.primaryCategory=y.categoryFilter);const u=ke({queryKey:["adminProgramList",z(r),l,H],enabled:!!(r!=null&&r.id)&&["first-mortgage","add-on"].includes(l),loadPage:s=>Pe(h.entities.Program,{...s,query:{...S,programModule:l==="add-on"?"ADD_ON":{$ne:"ADD_ON"}},sort:"-updated_date",fields:$e})}),P=oe({queryKey:["adminProgramHealth",z(r),H],enabled:!!(r!=null&&r.id)&&l==="data-health",queryFn:({signal:s})=>De(h.entities.Program,{query:S,sort:"-id",fields:Ie,signal:s}),meta:{clearOnDenied:!0},staleTime:3e4}),O=l==="data-health"?P.isFetching:u.isFetching;c.useEffect(()=>{N(new Set)},[w,j,a,l]);async function _(){R(),await Promise.all([f.invalidateQueries({queryKey:["adminProgramList"]}),f.invalidateQueries({queryKey:["adminProgramHealth"]})])}function Z(s){N(d=>{const i=new Set(d);return i.has(s)?i.delete(s):i.add(s),i})}function ee(s){const d=s.map(t=>t.id),i=d.every(t=>n.has(t));N(i?t=>{const m=new Set(t);return d.forEach(g=>m.delete(g)),m}:t=>{const m=new Set(t);return d.forEach(g=>m.add(g)),m})}function R(){N(new Set)}async function ae(){await $(s=>h.entities.Program.update(s,{programStatus:"PUBLISHED"}),"Published")}async function se(){await $(s=>h.entities.Program.update(s,{programStatus:"DRAFT"}),"Unpublished")}async function $(s,d){if(n.size){C(!0);try{const i=await Promise.allSettled([...n].map(s)),t=i.filter(g=>g.status==="rejected");t.forEach(g=>console.error("[AdminPrograms] Bulk action failed:",g.reason));const m=i.length-t.length;m&&b.success(`${d} ${m} program${m===1?"":"s"}`),t.length&&b.error(`${t.length} program changes failed. Refresh and retry.`),await _()}finally{C(!1)}}}async function te(){C(!0);try{const s=await h.functions.invoke("exportPrograms",{}),d=new Blob([JSON.stringify(s.data,null,2)],{type:"application/json"}),i=URL.createObjectURL(d),t=document.createElement("a");t.href=i,t.download=`loanbot-programs-export-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(i),b.success(`Exported ${s.data.count} programs (${s.data.byStatus.PUBLISHED} Published / ${s.data.byStatus.DRAFT} Draft)`)}catch(s){console.error("[AdminPrograms] Export failed:",s),b.error("Program export failed. Check console for details.")}finally{C(!1)}}async function re(){n.size&&window.confirm(`Permanently delete ${n.size} program${n.size!==1?"s":""}? This cannot be undone.`)&&await $(s=>h.entities.Program.delete(s),"Deleted")}return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-0 sm:max-w-sm",children:[e.jsx(ce,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(de,{placeholder:"Search programs...",value:w,onChange:s=>F(s.target.value),className:"pl-9 h-9"})]}),e.jsxs(x,{variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:_,disabled:O,children:[e.jsx(Ae,{className:`w-4 h-4 ${O?"animate-spin":""}`}),"Refresh"]}),e.jsxs(q,{value:j,onValueChange:L,children:[e.jsx(M,{className:"w-full sm:w-36 h-9",children:e.jsx(V,{placeholder:"Status"})}),e.jsxs(J,{children:[e.jsx(o,{value:"all",children:"All Status"}),e.jsx(o,{value:"PUBLISHED",children:"Published"}),e.jsx(o,{value:"DRAFT",children:"Draft"})]})]}),e.jsxs(q,{value:a,onValueChange:p,children:[e.jsx(M,{className:"w-full sm:w-40 h-9",children:e.jsx(V,{placeholder:"Category"})}),e.jsxs(J,{children:[e.jsx(o,{value:"all",children:"All Categories"}),e.jsx(o,{value:"Conventional",children:"Conventional"}),e.jsx(o,{value:"FHA",children:"FHA"}),e.jsx(o,{value:"VA",children:"VA"}),e.jsx(o,{value:"USDA",children:"USDA"}),e.jsx(o,{value:"Jumbo",children:"Jumbo"}),e.jsx(o,{value:"Portfolio",children:"Portfolio"}),e.jsx(o,{value:"Hard Money Loan",children:"Hard Money"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 sm:ml-auto",children:[e.jsx(B,{to:"/admin/ai-extraction",children:e.jsxs(x,{variant:"outline",className:"gap-2 border-[#F5A800]/30 text-[#F5A800] hover:bg-[#F5A800]/5 w-full sm:w-auto",children:[e.jsx(me,{className:"w-4 h-4"}),"AI Extract from PDF"]})}),e.jsxs(x,{variant:"outline",onClick:te,disabled:v,className:"gap-2 w-full sm:w-auto",children:[e.jsx(ue,{className:"w-4 h-4"}),"Export Programs (JSON)"]}),e.jsx(B,{to:"/admin/programs/new",children:e.jsxs(x,{className:"gap-2 w-full sm:w-auto",children:[e.jsx(xe,{className:"w-4 h-4"}),"Add Program"]})})]})]})}),n.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 px-4 py-2.5 bg-primary/5 border border-primary/20 rounded-xl",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-primary flex items-center justify-center",children:e.jsx(he,{className:"w-3 h-3 text-white"})}),e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[n.size," program",n.size!==1?"s":""," selected"]}),e.jsx("button",{onClick:R,className:"text-xs text-muted-foreground hover:text-foreground ml-1 underline",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{size:"sm",variant:"outline",disabled:v,onClick:ae,className:"gap-1.5 h-8 text-xs border-emerald-300 text-emerald-700 hover:bg-emerald-50",children:[e.jsx(G,{className:"w-3.5 h-3.5"})," Publish Selected"]}),e.jsxs(x,{size:"sm",variant:"outline",disabled:v,onClick:se,className:"gap-1.5 h-8 text-xs",children:[e.jsx(W,{className:"w-3.5 h-3.5"})," Unpublish Selected"]}),e.jsxs(x,{size:"sm",variant:"outline",disabled:v,onClick:re,className:"gap-1.5 h-8 text-xs border-destructive/30 text-destructive hover:bg-destructive/5",children:[v?e.jsx(pe,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Y,{className:"w-3.5 h-3.5"}),"Delete Selected"]})]})]}),e.jsxs(Ne,{value:l,onValueChange:T,children:[e.jsxs(ve,{className:"overflow-x-auto flex w-full sm:w-auto",children:[e.jsx(k,{value:"first-mortgage",className:"whitespace-normal text-center leading-tight",children:"First Mortgage"}),e.jsx(k,{value:"add-on",className:"whitespace-normal text-center leading-tight",children:"Add-On Programs"}),e.jsx(k,{value:"data-health",className:"whitespace-normal text-center leading-tight",children:"Data Health"}),e.jsx(k,{value:"bulk-update",className:"whitespace-normal text-center leading-tight",children:"Bulk Update"})]}),["first-mortgage","add-on"].map(s=>e.jsx(U,{value:s,className:"bg-card rounded-xl border border-border mt-4",children:u.isPending?e.jsx(E,{}):u.isError&&!u.rows.length?e.jsx(K,{retry:u.refetch}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{items:u.rows,selected:n,onToggleOne:Z,onToggleAll:()=>ee(u.rows),onChanged:_}),e.jsx(Ee,{query:u})]})},s)),e.jsx(U,{value:"data-health",className:"mt-4",children:l==="data-health"&&(P.isPending?e.jsx(E,{}):P.isError?e.jsx(K,{retry:P.refetch}):e.jsx(c.Suspense,{fallback:e.jsx(E,{}),children:e.jsx(He,{programs:P.data})}))}),e.jsx(U,{value:"bulk-update",className:"mt-4",children:l==="bulk-update"&&e.jsx(c.Suspense,{fallback:e.jsx(E,{}),children:e.jsx(_e,{})})})]})]})}export{Ze 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.