PageSourceSearch

https://nextrenewal.ai/assets/Requests-D3eqwkZh.js

js nextrenewal.ai collected 2026-10-05 13:12:38 UTC 15,999 bytes, 6 lines download raw bytes

1import{r as u,j as e}from"./index-D8EsB7hL.js";import{u as J}from"./sheet-kByO-_sg.js";import{u as Z}from"./tooltip-BKhDTKBX.js";import{T as ee,b as te,c as se,a as B}from"./tabs-1SUeY127.js";import{c as ae,b as ie,d as c}from"./queryClient-AUutHajs.js";import{P as ne}from"./PortalDashboardLayout-Cls_bk8b.js";import{p as _}from"./portalFetch-B2mDima8.js";import{C as F}from"./circle-check-big-BRzr5fWv.js";import{M as A}from"./message-square-uMhkB0yf.js";import{T as O}from"./triangle-alert-BEG9ybw7.js";import{F as K}from"./file-text-COaEOmBe.js";import{C as re}from"./chevron-up-Dmq17enE.js";import{C as le}from"./chevron-down-CJaArUWI.js";import{L as N}from"./loader-circle-0N5hnH5t.js";import{C as de}from"./clock-CyY1AEuS.js";import{P as oe}from"./paperclip-CF0U8X0L.js";import{S as ce}from"./send-oq81iJx0.js";import{C as me}from"./circle-x-B7wG68xW.js";import"./index-B6bmULLL.js";import"./index-BpHNDHsn.js";import"./index-CB0gBaHa.js";import"./logo_circle-CWJ_J4PL.js";import"./button-DvAEcrXz.js";import"./chevrons-up-down-5T4EhXkY.js";import"./layout-dashboard-BaH3ng7T.js";import"./ellipsis-dgMlM72M.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const xe=ae("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]),ue={w9:"W-9 Form",coi:"Certificate of Insurance",msa:"Master Service Agreement",nda:"Non-Disclosure Agreement",sow:"Statement of Work",invoice:"Invoice",financial_statements:"Financial Statements",business_license:"Business License",info_request:"Information Request",other:"Other"};function W(i){return i?ue[i]||i.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()):"Document Request"}function pe(i){if(!i)return{label:"No due date",color:"text-gray-400",urgent:!1};const l=Math.ceil((new Date(i).getTime()-Date.now())/864e5);return l<0?{label:`Overdue by ${Math.abs(l)}d`,color:"text-rose-600",urgent:!0}:l===0?{label:"Due today",color:"text-rose-600",urgent:!0}:l<=7?{label:`Due in ${l}d`,color:"text-amber-600",urgent:!0}:{label:`Due ${new Date(i).toLocaleDateString()}`,color:"text-gray-500",urgent:!1}}const D=["pending","viewed","in_progress","submitted","accepted"],V={pending:"New",viewed:"Viewed",in_progress:"In Progress",submitted:"Submitted",accepted:"Accepted",needs_revision:"Needs Revision",dismissed:"N/A",fulfilled:"Fulfilled"};function ge({status:i}){const l=D.indexOf(i),h=["needs_revision","dismissed","fulfilled"].includes(i);return e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[D.map((p,f)=>{const y=p===i,b=l>f&&!h;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:c("text-[10px] font-semibold px-2 py-0.5 rounded-full transition-all",y?"bg-indigo-600 text-white":b?"bg-emerald-100 text-emerald-700":"bg-gray-100 text-gray-400"),children:V[p]}),f<D.length-1&&e.jsx("div",{className:c("w-3 h-px",b?"bg-emerald-300":"bg-gray-200")})]},p)}),h&&e.jsx("span",{className:c("text-[10px] font-semibold px-2 py-0.5 rounded-full ml-1",i==="needs_revision"?"bg-amber-100 text-amber-700":i==="dismissed"?"bg-gray-100 text-gray-500":"bg-emerald-100 text-emerald-700"),children:V[i]})]})}function he({msg:i}){const l=i.sender_type==="vendor";return e.jsx("div",{className:c("flex mb-3",l?"justify-end":"justify-start"),children:e.jsxs("div",{className:c("max-w-[80%] rounded-2xl px-4 py-2.5",l?"bg-indigo-600 text-white rounded-br-none":"bg-gray-100 text-gray-800 rounded-bl-none"),children:[e.jsx("p",{className:c("text-[10px] font-semibold mb-1",l?"text-indigo-200":"text-gray-400"),children:l?"You":i.sender_name||"Client"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:i.body}),e.jsx("p",{className:c("text-[10px] mt-1",l?"text-indigo-300":"text-gray-400"),children:new Date(i.created_at).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})})}function fe({status:i}){return i==="accepted"?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-emerald-600 font-semibold",children:[e.jsx(F,{className:"h-3.5 w-3.5"}),"Accepted"]}
6):i==="dismissed"?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-500 font-semibold",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Marked N/A"]}):e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-emerald-600 font-semibold",children:[e.jsx(F,{className:"h-3.5 w-3.5"}),"Fulfilled"]})}function We(){const{toast:i}=ie(),l=Z(),h=u.useRef(null),p=u.useRef(null),[f,y]=u.useState(null),[b,L]=u.useState({}),[z,M]=u.useState({}),[v,R]=u.useState({}),[H,P]=u.useState({}),[Y,E]=u.useState({}),[q,I]=u.useState({}),{data:w,isLoading:j}=J({queryKey:["/portal-api/document-requests"]}),S=(w==null?void 0:w.requests)||[],g=S.filter(t=>!["fulfilled","accepted","dismissed"].includes(t.status)),C=S.filter(t=>["fulfilled","accepted","dismissed"].includes(t.status));async function $(t){const a=t.id;if(f===a){y(null);return}if(y(a),b[a]===void 0){M(s=>({...s,[a]:!0}));try{const{ok:s,data:r}=await _("GET",`/portal-api/document-requests/${a}/messages`);s&&(L(n=>({...n,[a]:r.messages||[]})),l.setQueryData(["/portal-api/document-requests"],n=>n!=null&&n.requests?{...n,requests:n.requests.map(o=>o.id===a&&o.status==="pending"?{...o,status:"viewed"}:o)}:n))}catch{}M(s=>({...s,[a]:!1}))}}async function k(t,a){const s=t.id,r=(v[s]||"").trim();if(!(!r&&!a)){P(n=>({...n,[s]:!0}));try{const{ok:n,data:o}=await _("POST",`/portal-api/document-requests/${s}/messages`,{body:r||"(Attached document)",...a?{attachmentId:a}:{}});n?(L(d=>({...d,[s]:[...d[s]||[],o.message]})),R(d=>({...d,[s]:""})),l.setQueryData(["/portal-api/document-requests"],d=>d!=null&&d.requests?{...d,requests:d.requests.map(x=>x.id===s&&!["accepted","dismissed","fulfilled"].includes(x.status)?{...x,status:"submitted"}:x)}:d),setTimeout(()=>{l.invalidateQueries({queryKey:["/portal-api/document-requests"]})},500)):i({title:"Failed to send message",variant:"destructive"})}catch{i({title:"Something went wrong",variant:"destructive"})}P(n=>({...n,[s]:!1}))}}async function T(t,a){const s=t.id;E(r=>({...r,[s]:!0}));try{const{ok:r}=await _("PATCH",`/portal-api/document-requests/${s}/status`,{status:a});r?(i({title:a==="dismissed"?"Marked as N/A":"Marked as In Progress"}),l.setQueryData(["/portal-api/document-requests"],n=>n!=null&&n.requests?{...n,requests:n.requests.map(o=>o.id===s?{...o,status:a}:o)}:n),l.invalidateQueries({queryKey:["/portal-api/document-requests"]})):i({title:"Failed to update status",variant:"destructive"})}catch{i({title:"Something went wrong",variant:"destructive"})}E(r=>({...r,[s]:!1}))}async function G(t){const a=p.current;if(!a)return;const s=S.find(r=>r.id===a);if(s){I(r=>({...r,[a]:!0}));try{const r=new FormData;r.append("file",t),r.append("documentType",s.document_type||"other"),r.append("displayName",t.name);const n=await fetch("/portal-api/documents",{method:"POST",body:r,credentials:"include"});if(!n.ok){i({title:"Upload failed",variant:"destructive"});return}const{document:o}=await n.json();await k(s,o.id),i({title:"File attached and sent!"})}catch{i({title:"Upload failed",variant:"destructive"})}I(r=>({...r,[a]:!1})),p.current=null}}return e.jsxs(ne,{children:[e.jsxs("div",{className:"max-w-4xl mx-auto space-y-5",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[22px] font-bold text-gray-900",children:"Requests"}),g.length>0&&e.jsxs("p",{className:"text-sm text-gray-500 mt-0.5",children:[e.jsx("span",{className:"text-rose-600 font-semibold",children:g.length})," ","pending ",g.length===1?"request":"requests"," ",g.length===1?"needs":"need"," your attention"]})]}),e.jsxs(ee,{defaultValue:"pending",children:[e.jsx(te,{className:"flex gap-1.5 h-auto bg-transparent p-0 mb-5",children:[["pending",`Pending (${j?"…":g.length})`],["completed",`Completed (${j?"…":C.length})`]].map(([t,a])=>e.jsx(se,{value:t,className:"rounded-full px-4 py-1.5 text-[13px] font-medium transition-all data-[state=active]:bg-gray-900 data-[state=active]:text-white data-[state=active]:shadow-sm",children:a},t))}),e.jsxs(B,{value:"pending",className:"space-y-4",children:[j&&e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-24 bg-gray-100 rounded-xl animate-pulse"},t))}),g.length===0&&!j&&e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"inline-flex items-center justify-center h-20 w-20 rounded-2xl bg-emerald-50 mb-5",children:e.jsx(F,{className:"h-10 w-10 text-emerald-400"})}),e.jsx("p",{className:"font-bold text-gray-800 text-lg",children:"All caught up!"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"No pending document requests."})]}),g.map(t=>{var U;const a=pe(t.due_date),s=t.document_type==="info_request",r=f===t.id,n=b[t.id]||[],o=z[t.id],d=H[t.id],x=Y[t.id],Q=q[t.id];return e.jsxs("div",{className:c("bg-white rounded-2xl shadow-sm border-l-4 overflow-hidden",a.urgent?"border-l-rose-500":s?"border-l-amber-400":"border-l-indigo-500"),children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:c("h-10 w-10 rounded-xl flex items-center justify-center flex-shrink-0",a.urgent?"bg-rose-500":s?"bg-amber-100":"bg-indigo-600"),children:s?e.jsx(A,{className:"h-5 w-5 text-amber-600"}):a.urgent?e.jsx(O,{className:"h-5 w-5 text-white"}):e.jsx(K,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:e.jsx("span",{className:c("text-xs font-bold px-2.5 py-0.5 rounded-full",a.urgent?"bg-rose-100 text-rose-700":s?"bg-amber-50 text-amber-700":"bg-indigo-50 text-indigo-700"),children:W(t.document_type)})}),t.subject&&e.jsx("p",{className:"text-[14px] font-semibold text-gray-900 mb-1",children:t.subject}),e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:a.urgent&&e.jsxs("span",{className:"text-xs text-rose-600 font-semibold flex items-center gap-1",children:[e.jsx(O,{className:"h-3 w-3"}),a.label]})}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.tenantName&&e.jsxs("p",{className:"text-xs text-gray-500",children:["From ",e.jsx("span",{className:"font-medium text-gray-700",children:t.tenantName})]}),t.created_at&&e.jsxs("p",{className:"text-xs text-gray-400",children:["· ",new Date(t.created_at).toLocaleDateString()]})]})]})]}),e.jsx("button",{onClick:()=>$(t),className:"shrink-0 flex items-center gap-1.5 text-xs font-semibold text-gray-500 hover:text-indigo-600 transition-colors px-2.5 py-1.5 rounded-lg hover:bg-indigo-50",children:r?e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Close"]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"h-3.5 w-3.5"}),"Reply",n.length>0?` (${n.length})`:""]})})]}),e.jsx("div",{className:"mb-3",children:e.jsx(ge,{status:t.status})}),t.note&&e.jsx("div",{className:c("rounded-xl p-3 border mb-3",s?"bg-amber-50 border-amber-100":"bg-gray-50 border-gray-100"),children:e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed",children:t.note})}),!r&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>$(t),className:c("font-semibold transition-colors flex items-center gap-2 px-4 h-9 rounded-xl text-sm text-white",s?"bg-amber-500 hover:bg-amber-600":"bg-indigo-600 hover:bg-indigo-700"),children:[e.jsx(A,{className:"h-3.5 w-3.5"}),s?"Reply / Upload":"Reply / Attach File"]}),["pending","viewed"].includes(t.status)&&e.jsxs("button",{onClick:()=>T(t,"in_progress"),disabled:x,className:"font-medium transition-colors flex items-center gap-1.5 px-4 h-9 rounded-xl text-sm border border-gray-200 text-gray-600 hover:bg-gray-50 disabled:opacity-50",children:[x?e.jsx(N,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(de,{className:"h-3.5 w-3.5"}),"Mark In Progress"]}),["pending","viewed","in_progress"].includes(t.status)&&e.jsx("button",{onClick:()=>T(t,"dismissed"),disabled:x,className:"font-medium transition-colors text-xs px-3 h-9 rounded-xl border border-gray-200 text-gray-400 hover:text-gray-600 hover:bg-gray-50 disabled:opacity-50",children:"Mark N/A"})]})]}),r&&e.jsxs("div",{className:"border-t border-gray-100",children:[e.jsx("div",{className:"px-5 py-4 min-h-[100px] max-h-[280px] overflow-y-auto bg-gray-50/60",children:o?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(N,{className:"h-5 w-5 animate-spin text-indigo-400"})}):n.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(A,{className:"h-7 w-7 text-gray-200 mb-2"}),e.jsx("p",{className:"text-xs text-gray-400",children:"No messages yet — start the conversation below."})]}):n.map(m=>e.jsx(he,{msg:m}
6,m.id))}),e.jsxs("div",{className:"px-5 py-4 bg-white border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{value:v[t.id]||"",onChange:m=>R(X=>({...X,[t.id]:m.target.value})),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),k(t))},placeholder:s?"Write your reply…":"Write a message or attach a file…",rows:2,className:"flex-1 resize-none border border-gray-200 rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:border-indigo-400 focus:ring-2 focus:ring-indigo-400/20 transition-all"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("button",{onClick:()=>{var m;p.current=t.id,(m=h.current)==null||m.click()},disabled:Q||d,className:"h-9 w-9 rounded-xl border border-gray-200 flex items-center justify-center text-gray-400 hover:text-indigo-600 hover:border-indigo-300 transition-colors disabled:opacity-50",title:"Attach file",children:Q?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(oe,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>k(t),disabled:d||!((U=v[t.id])!=null&&U.trim()),className:"h-9 w-9 rounded-xl bg-indigo-600 hover:bg-indigo-700 disabled:opacity-50 flex items-center justify-center text-white transition-colors",title:"Send (Enter)",children:d?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("p",{className:"text-[10px] text-gray-400",children:"Enter to send · Shift+Enter for new line"}),["pending","viewed","in_progress"].includes(t.status)&&e.jsx("button",{onClick:()=>T(t,"dismissed"),disabled:x,className:"text-[10px] font-medium text-gray-400 hover:text-gray-600 transition-colors disabled:opacity-50",children:"Mark N/A"})]})]})]})]},t.id)})]}),e.jsxs(B,{value:"completed",className:"space-y-3",children:[C.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"inline-flex items-center justify-center h-16 w-16 rounded-2xl bg-gray-100 mb-4",children:e.jsx(xe,{className:"h-8 w-8 text-gray-300"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No completed requests yet"})]}),C.map(t=>e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm p-4 flex items-center justify-between opacity-80",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg bg-gray-100 flex items-center justify-center",children:e.jsx(K,{className:"h-4 w-4 text-gray-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-700",children:W(t.document_type)}),t.tenantName&&e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:["From ",t.tenantName]})]})]}),e.jsx(fe,{status:t.status})]},t.id))]})]})]}),e.jsx("input",{ref:h,type:"file",className:"hidden",onChange:t=>{var s;const a=(s=t.target.files)==null?void 0:s[0];a&&(t.target.value="",G(a))}})]})}export{ue as DOC_TYPE_LABELS,We as default,W as getDocLabel};

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.