PageSourceSearch

https://saar-seva-app.saarbazaar.workers.dev/assets/AdminBuybackFeDebits-Boq09wWs.js

js saar-seva-app.saarbazaar.workers.dev collected 2026-10-03 08:10:45 UTC 6,181 bytes, 1 lines download raw bytes

1import{r as l,x as g,e as N,j as e,h as v}from"./index-BsRJbbzd.js";const w={waiting_fe:["Waiting for FE","bg-amber-100 text-amber-800"],disputed:["Disputed","bg-indigo-100 text-indigo-800"],accepted:["Accepted by FE","bg-rose-100 text-rose-700"],confirmed:["Confirmed","bg-rose-100 text-rose-700"],waived:["Waived","bg-slate-100 text-slate-600"],cancelled:["Handed in","bg-emerald-100 text-emerald-700"],reversed:["Reversed","bg-slate-100 text-slate-600"]},C=s=>`₹${Number(s||0).toLocaleString("en-IN")}`;function E({d:s,canDecide:h,onChanged:a}){const[n,d]=l.useState(null),[i,r]=l.useState(""),[b,u]=l.useState(null),[p,o]=l.useState(!1),[j,t]=w[s.status]||[s.status,"bg-slate-100"],x=async f=>{o(!0),u(null);try{await N.decideBuybackFeDebit(s.id,f,i),d(null),r(""),a()}catch(m){u((m==null?void 0:m.detail)||(m==null?void 0:m.message)||"Failed.")}finally{o(!1)}},c=s.needs_manager,y=s.status==="accepted"||s.status==="confirmed";return e.jsxs("tr",{className:"border-t border-slate-100 align-top",children:[e.jsxs("td",{className:"px-3 py-2",children:[e.jsx("div",{className:"font-medium text-slate-900",children:s.fe_name}),e.jsx("div",{className:"text-xs text-slate-500",children:v(s.created_at)})]}),e.jsxs("td",{className:"px-3 py-2",children:[e.jsx("div",{children:s.device_label||"Device"}),e.jsx("div",{className:"text-xs text-slate-500",children:s.source_ref})]}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:C(s.amount)}),e.jsxs("td",{className:"px-3 py-2",children:[e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] font-semibold ${t}`,children:j}),s.overdue&&e.jsx("div",{className:"mt-0.5 text-[11px] font-semibold text-rose-700",children:"No answer in 3 days — decide"}),s.fe_note&&e.jsxs("div",{className:"mt-0.5 text-xs text-slate-600",children:["FE: “",s.fe_note,"”"]}),s.decision_note&&e.jsxs("div",{className:"mt-0.5 text-xs text-slate-500",children:[s.decided_by,": ",s.decision_note]})]}),e.jsxs("td",{className:"px-3 py-2",children:[h&&(c||y)&&!n&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>d("confirm"),className:"text-xs font-semibold text-rose-700 underline",children:"Confirm"}),e.jsx("button",{type:"button",onClick:()=>d("waive"),className:"text-xs font-semibold text-slate-700 underline",children:"Waive"})]}),y&&e.jsx("button",{type:"button",onClick:()=>d("reverse"),className:"text-xs font-semibold text-slate-700 underline",children:"Reverse"})]}),n&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("input",{className:"input-base text-xs",placeholder:`Why ${n}? (required)`,value:i,onChange:f=>r(f.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",disabled:p||i.trim().length<3,onClick:()=>x(n),className:"rounded bg-slate-900 px-2 py-1 text-xs font-semibold text-white disabled:opacity-50",children:n[0].toUpperCase()+n.slice(1)}),e.jsx("button",{type:"button",onClick:()=>d(null),className:"text-xs underline",children:"Cancel"})]})]}),b&&e.jsx("div",{className:"text-xs text-rose-700",children:b})]})]})}function S(){const[s,h]=l.useState("open"),[a,n]=l.useState(null),[d,i]=l.useState(null),[r,b]=l.useState(g().slice(0,7)),[u,p]=l.useState(null),o=l.useCallback(()=>{n(null),N.buybackFeDebits(s).then(t=>{if(!t||!Array.isArray(t.debits))throw new Error("Unexpected response.");n(t),i(null)}).catch(t=>i((t==null?void 0:t.detail)||(t==null?void 0:t.message)||"Couldn't load debits."))},[s]);l.useEffect(()=>{o()},[o]);const j=async()=>{p(null);try{const t=await N.buybackFeDebitsCsv(r),x=URL.createObjectURL(t),c=document.createElement("a");c.href=x,c.download=`fe-debits-${r}.csv`,document.body.appendChild(c),c.click(),c.remove(),URL.revokeObjectURL(x)}catch(t){p((t==null?void 0:t.detail)||(t==null?void 0:t.message)||"Download failed.")}};return e.jsxs("div",{className:"mx-auto max-w-5xl space-y-3 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("h1",{className:"text-xl font-semibold text-slate-900",children:["FE debits",(a==null?void 0:a.needs_manager)>
10&&e.jsxs("span",{className:"ml-2 rounded-full bg-rose-600 px-2 py-0.5 text-xs text-white",children:[a.needs_manager," to decide"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"month",className:"input-base text-sm",value:r,onChange:t=>b(t.target.value),"aria-label":"Month"}),e.jsx("button",{type:"button",onClick:j,className:"rounded-lg border border-slate-300 px-3 py-1.5 text-xs font-semibold text-slate-700",children:"↓ HR deduction list"})]})]}),u&&e.jsx("div",{className:"text-xs text-rose-700",children:u}),e.jsx("p",{className:"text-xs text-slate-500",children:"Raised when the desk settles a device as not received. The FE has 3 days to hand it in, accept or dispute."}),e.jsx("div",{className:"flex gap-1 border-b border-slate-200",children:[["open","Open"],["charged","Charged"],["closed","Closed"]].map(([t,x])=>e.jsx("button",{type:"button",onClick:()=>h(t),className:`px-3 py-1.5 text-sm ${s===t?"border-b-2 border-slate-900 font-semibold":"text-slate-500"}`,children:x},t))}),d&&e.jsx("div",{className:"rounded border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-800",children:d}),!a&&!d&&e.jsx("div",{className:"text-sm text-slate-500",children:"Loading…"}),a&&a.debits.length===0&&e.jsxs("div",{className:"text-sm text-slate-500",children:["No ",s," debits."]}),a&&a.debits.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200 bg-white",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-left text-xs uppercase tracking-wide text-slate-500",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2",children:"FE"}),e.jsx("th",{className:"px-3 py-2",children:"Device"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Amount"}),e.jsx("th",{className:"px-3 py-2",children:"Status"}),e.jsx("th",{className:"px-3 py-2",children:"Action"})]})}),e.jsx("tbody",{children:a.debits.map(t=>e.jsx(E,{d:t,canDecide:a.can_decide,onChanged:o},t.id))})]})})]})}export{S 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.