1import{bT as A,b8 as e,bV as E,bm as v,bU as y,bR as N,by as x,O as f,y as o,m as O}from"./index-D8Qj6vox.js";import{o as S}from"./offerHistory-D6CTVm8F.js";import{R as w}from"./Reveal-CjoXeEKn.js";import{b as $,u as L,r as R,i as T}from"./offers-BZGSe552.js";import{L as _}from"./loader-circle-CuWznbJE.js";import{A as M}from"./arrow-left-DVzTP3pD.js";import{C as P}from"./circle-x-CF3LrC8i.js";import"./motion-CgmXA0LE.js";import"./pathId-hu7rQsiV.js";const u=10;function b(t,s){return t instanceof Error&&t.message?t.message:s}function C(t){if(!t.base_salary)return"â";const s=Number(t.base_salary).toLocaleString();return`${t.currency??""} ${s}${t.pay_period?` / ${t.pay_period}`:""}`.trim()}function D(t){if(!t)return"";const s=Math.floor((Date.now()-new Date(t).getTime())/864e5);return Number.isNaN(s)?"":s<=0?"Submitted today":s===1?"Waiting 1 day":`Waiting ${s} days`}function F(){const t=y({queryKey:["admin","offer-approvals"],queryFn:R});return e.jsxs("div",{className:"mx-auto w-full max-w-[860px] px-4 py-8",children:[e.jsxs(w,{children:[e.jsx("h1",{className:"text-[22px] font-semibold text-foreground",children:"Offer approvals"}),e.jsx("p",{className:"mt-1 text-[13px] text-muted-foreground",children:"Offers your HR managers have submitted, waiting on your decision before they can be sent. Oldest request first."})]}),t.isLoading?e.jsxs("p",{className:"mt-6 flex items-center gap-2 text-[13px] text-muted-foreground",children:[e.jsx(_,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Loadingâ¦"]}):t.isError?e.jsx("p",{className:"mt-6 text-[13px] text-[var(--ui-danger)]",children:"Could not load the offer approval queue."}):(t.data??[]).length===0?e.jsxs(o,{className:"mt-6 p-6 text-center",children:[e.jsx("p",{className:"text-[13.5px] text-foreground",children:"Nothing is waiting on you."}),e.jsx("p",{className:"mt-1 text-[12.5px] text-muted-foreground",children:"An offer your HR managers submit for approval appears here."})]}):e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:(t.data??[]).map(s=>e.jsxs(o,{className:"p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(f,{to:`/superadmin/offer-approvals/${s.id}`,className:"text-[15px] font-semibold text-foreground hover:underline",children:[s.candidate_name," · ",s.job_title]}),e.jsx("p",{className:"mt-0.5 text-[12.5px] text-muted-foreground",children:C(s)})]}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:D(s.submitted_at)})]}),e.jsx(f,{to:`/superadmin/offer-approvals/${s.id}`,className:"mt-3 inline-flex items-center gap-1.5 text-[12.5px] text-[var(--accent)] hover:underline",children:"Review this offer"})]},s.id))})]})}function Q({offerId:t}){var j;const s=E(),[d,l]=v.useState(""),[n,i]=v.useState(null),c=y({queryKey:["admin","offer-approvals",t],queryFn:()=>T(t)}),h=()=>{s.invalidateQueries({queryKey:["admin","offer-approvals",t]}),s.invalidateQueries({queryKey:["admin","offer-approvals"]})},p=N({mutationFn:()=>$(t,d),onSuccess:()=>{i(null),l(""),h(),x.success("Approved â HR can send it now")},onError:a=>x.error(b(a,"Could not approve this offer"))}),m=N({mutationFn:()=>L(t,d),onSuccess:()=>{i(null),l(""),h(),x.success("Sent back with your note")},onError:a=>x.error(b(a,"Could not send this back"))});if(c.isLoading)return e.jsx("div",{className:"mx-auto w-full max-w-[780px] px-4 py-16",children:e.jsxs("p",{className:"flex items-center gap-2 text-[13px] text-muted-foreground",children:[e.jsx(_,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),"Loadingâ¦"]})});if(c.isError||!c.data)return e.jsx("div",{className:"mx-auto w-full max-w-[780px] px-4 py-16",children:e.jsx("p",{className:"text-[13px] text-[var(--ui-danger)]",children:"Could not load this offer."})});const r=c.data,k=r.status==="pending_approval",g=d.trim().length>=u;return e.jsxs("div",{className:"mx-auto w-full max-w-[780px] px-4 py-8",children:[e.jsxs(w,{children:[e.jsxs(f,{to:"/superadmin/offer-approvals",className:"mb-2 inline-flex items-center gap-1.5 text-[12.5px] text-muted-foreground hover:text-foreground",children:[e.jsx(M,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Offer approvals"]}
1),e.jsxs("h1",{className:"text-[22px] font-semibold tracking-[-0.5px] text-foreground",children:[r.candidate_name," · ",r.job_title]}),e.jsx("p",{className:"mt-1.5 text-[13px] text-muted-foreground",children:C(r)})]}),e.jsxs("div",{className:"mt-6 grid gap-5",children:[e.jsxs(o,{className:"p-5",children:[e.jsx("h2",{className:"mb-3 text-[14px] font-semibold text-foreground",children:"Employment terms"}),e.jsxs("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-[12.5px]",children:[e.jsx("dt",{className:"text-muted-foreground",children:"Employment type"}),e.jsx("dd",{className:"text-foreground",children:((j=r.employment_type)==null?void 0:j.replace("_"," "))??"â"}),e.jsx("dt",{className:"text-muted-foreground",children:"Start date"}),e.jsx("dd",{className:"text-foreground",children:r.start_date??"â"}),e.jsx("dt",{className:"text-muted-foreground",children:"Location"}),e.jsx("dd",{className:"text-foreground",children:r.location??"â"}),e.jsx("dt",{className:"text-muted-foreground",children:"Probation"}),e.jsx("dd",{className:"text-foreground",children:r.probation_months!=null?`${r.probation_months} months`:"â"}),e.jsx("dt",{className:"text-muted-foreground",children:"Notice period"}),e.jsx("dd",{className:"text-foreground",children:r.notice_period_days!=null?`${r.notice_period_days} days`:"â"}),e.jsx("dt",{className:"text-muted-foreground",children:"Offer window"}),e.jsx("dd",{className:"text-foreground",children:r.valid_days?`${r.valid_days} days`:"â"})]}),r.bonus?e.jsxs("p",{className:"mt-3 text-[12.5px] text-[var(--ui-soft)]",children:["Bonus: ",r.bonus]}):null,r.equity?e.jsxs("p",{className:"mt-1 text-[12.5px] text-[var(--ui-soft)]",children:["Equity: ",r.equity]}):null,r.benefits?e.jsxs("p",{className:"mt-1 text-[12.5px] text-[var(--ui-soft)]",children:["Benefits: ",r.benefits]}):null,r.terms?e.jsxs("p",{className:"mt-1 text-[12.5px] text-[var(--ui-soft)]",children:["Terms: ",r.terms]}):null]}),e.jsxs(o,{className:"p-5",children:[e.jsx("h2",{className:"mb-3 text-[14px] font-semibold text-foreground",children:"History"}),r.history.length===0?e.jsx("p",{className:"text-[12.5px] text-muted-foreground",children:"No activity recorded yet."}):e.jsx("ol",{className:"flex flex-col gap-1.5 border-l border-border pl-3",children:r.history.map((a,q)=>e.jsxs("li",{className:"text-[12.5px] text-[var(--ui-soft)]",children:[S(a.action),a.actor_name?` â ${a.actor_name}`:"",e.jsx("span",{className:"ml-1.5 text-[11px] text-[var(--ui-faint)]",children:new Date(a.at).toLocaleString()})]},q))})]}),k?e.jsxs(o,{className:"p-5",children:[e.jsx("h2",{className:"mb-3 text-[14px] font-semibold text-foreground",children:"Your decision"}),n===null?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>i("approve"),className:"inline-flex items-center gap-1.5 rounded-[10px] border border-[var(--ui-ok)]/35 px-4 py-2 text-[13px] font-medium text-[var(--ui-ok)] hover:bg-[var(--ui-ok)]/10",children:[e.jsx(O,{className:"h-4 w-4","aria-hidden":"true"}),"Approve"]}),e.jsxs("button",{type:"button",onClick:()=>i("reject"),className:"inline-flex items-center gap-1.5 rounded-[10px] border border-[var(--ui-line-strong)] px-4 py-2 text-[13px] text-muted-foreground hover:border-[var(--ui-warn)]/40 hover:text-[var(--ui-warn)]",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),"Send back"]})]}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:"offer-decision-note",className:"text-[12px] font-medium text-[var(--ui-soft)]",children:n==="approve"?"Note (optional)":"What needs to change (required)"}),e.jsx("input",{id:"offer-decision-note",value:d,onChange:a=>l(a.target.value),placeholder:n==="reject"?`At least ${u} characters`:void 0,className:"rounded-[10px] border border-border bg-secondary px-3 py-2 text-[13px] text-foreground focus:border-[var(--accent)] focus:outline-none"}),n==="reject"&&!g?e.jsxs("p",{className:"text-[11.5px] text-[var(--ui-warn)]",children:["Write at least ",u," characters."]}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>n==="approve"?p.mutate():m.mutate(),disabled:(n==="approve"?p.isPending:m.isPending)||n==="reject"&&!g,className:"rounded-[10px] bg-primary px-4 py-2 text-[12.5px] font-medium text-primary-foreground disabled:opacity-40",children:n==="approve"?p.isPending?"Approvingâ¦":"Confirm approval":m.isPending?"Sendingâ¦":"Send back"}),e.jsx("button",{type:"button",onClick:()=>{i(null),l("")},className:"rounded-[10px] border border-[var(--ui-line-strong)] px-4 py-2 text-[12.5px] text-[var(--ui-soft)] hover:text-foreground",children:"Cancel"})]})]})]}):e.jsx(o,{className:"p-5",children:e.jsxs("p",{className:"text-[12.5px] text-muted-foreground",children:["This offer is ",r.status.replace("_"," ")," â nothing for you to decide right now."]})})]})]})}function Y(){const{offerId:t}=A();return t?e.jsx(Q,{offerId:t}):e.jsx(F,{})}export{Y 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.