PageSourceSearch

https://www.intellicontract.ai/assets/LawyerPortal-DBGxH13r.js

js intellicontract.ai collected 2026-10-05 12:12:03 UTC 15,818 bytes, 1 lines download raw bytes

1import{f as De,u as Ae,r as i,s as l,aE as c,j as e,a3 as I,O as ke,n as p,o as j,D as ee,a as se,b as te,d as ae,e as re,L as d,k as h,U as Ee,B as m,ao as Re,ap as ne,I as ie,az as le,W as ce,Y as oe,Z as de,$ as me,a0 as u,h as qe,aD as Pe}from"./index-CyCBd4px.js";import{T as Le,a as Fe,b as L,c as F}from"./tabs-CRirZm4W.js";import{S as he}from"./scroll-area-IFfX1SmM.js";import{S as xe}from"./separator-DBleBGLK.js";import{S as Te}from"./scale-kJbD1mqu.js";import{C as O}from"./clock-CxyfPBmY.js";import{P as U}from"./play-CKJjzcva.js";import{C as k}from"./circle-check-big-D5_bUOBn.js";import{F as ue}from"./file-text-DBDmLy66.js";import{S as Ie}from"./send-BZgEhdL3.js";import{T as Oe}from"./triangle-alert-Bhfo5Tdb.js";import{I as Ue}from"./indian-rupee-kNBsqwCb.js";import{C as Ve}from"./calendar-BZ_eE7FB.js";const es=()=>{var Z,G,J;const{user:a}=De(),f=Ae(),[E,v]=i.useState(!0),[R,q]=i.useState(!1),[g,y]=i.useState([]),[t,N]=i.useState(null),[V,pe]=i.useState([]),[je,b]=i.useState(!1),[ge,_]=i.useState(!1),[n,w]=i.useState({content:"",type:"comment",priority:"normal",section:""}),[$,z]=i.useState(""),[fe,Y]=i.useState(!1),[we,B]=i.useState(!1),[M,H]=i.useState(!1);i.useEffect(()=>{a&&ve()},[a]);const ve=async()=>{try{const{data:s,error:r}=await l.rpc("is_lawyer",{_user_id:a.id});if(r)throw r;if(!s){c({variant:"destructive",title:"Access Denied",description:"You don't have lawyer access. Please contact admin."}),f("/dashboard");return}q(!0),C()}catch(s){console.error("Error checking lawyer role:",s),f("/dashboard")}},C=async()=>{try{const{data:s,error:r}=await l.from("lawyer_review_requests").select("*").order("created_at",{ascending:!1});if(r)throw r;const x=await Promise.all((s||[]).map(async o=>{if(o.contract_id){const{data:K}=await l.from("contracts").select("title, document_content, counterparty_name").eq("id",o.contract_id).maybeSingle();return{...o,contracts:K||void 0}}return o}));y(x)}catch(s){console.error("Error fetching reviews:",s),c({variant:"destructive",title:"Error",description:"Failed to fetch review requests."})}finally{v(!1)}},W=async s=>{try{const{data:r,error:x}=await l.from("lawyer_review_annotations").select("*").eq("review_request_id",s).order("created_at",{ascending:!1});if(x)throw x;pe(r||[])}catch(r){console.error("Error fetching annotations:",r)}},ye=async s=>{B(!0);try{const{error:r}=await l.from("lawyer_review_requests").update({lawyer_id:a.id,status:"in_progress",updated_at:new Date().toISOString()}).eq("id",s.id).is("lawyer_id",null);if(r)throw r;c({title:"Review Claimed",description:"You've been assigned to this review request."}),C()}catch(r){console.error("Error claiming review:",r),c({variant:"destructive",title:"Error",description:"Failed to claim review. It may have been claimed by another lawyer."})}finally{B(!1)}},P=s=>{N(s),z(s.lawyer_notes||""),W(s.id),b(!0)},Ne=async()=>{if(!(!t||!n.content.trim()))try{const{error:s}=await l.from("lawyer_review_annotations").insert({review_request_id:t.id,lawyer_id:a.id,annotation_type:n.type,content:n.content,section_reference:n.section||null,priority:n.priority,workspace_id:"00000000-0000-0000-0000-000000000001"});if(s)throw s;c({title:"Annotation Added",description:"Your annotation has been saved."}),w({content:"",type:"comment",priority:"normal",section:""}),_(!1),W(t.id)}catch(s){console.error("Error adding annotation:",s),c({variant:"destructive",title:"Error",description:"Failed to add annotation."})}},be=async()=>{if(t)try{const{error:s}=await l.from("lawyer_review_requests").update({lawyer_notes:$,updated_at:new Date().toISOString()}).eq("id",t.id);if(s)throw s;c({title:"Notes Saved",description:"Your notes have been saved."})}catch(s){console.error("Error saving notes:",s),c({variant:"destructive",title:"Error",description:"Failed to save notes."})}},_e=async s=>{var x;if(!t||!((x=s.target.files)!=null&&x[0]))return;const r=s.target.files[0];Y(!0);try{const o=`reviewed_${t.id}_${Date.now()}_${r.name}`,{data:K,error:Q}=await l.storage.from("documents").upload(`lawyer-reviews/${o}`,r);if(Q)throw Q;const{data:Se}=l.storage.from("documents").getPublicUrl(`lawyer-reviews/${o}`),{error:X}=await l.from("lawyer_review_requests").update({reviewed_document_url:Se.publicUrl,updated_at:new Date().toISOString()}).eq("id",t.id);if(X)throw X;c({title:"Document Uploaded",description:"Reviewed document has been uploaded successfully."}),C()}catch(o){console.error("Error uploading document:",o),c({variant:"destructive",title:"Upload Failed",description:"Failed to upload document."})}finally{Y(!1)}},Ce=async()=>
1{if(t){H(!0);try{const{error:s}=await l.from("lawyer_review_requests").update({status:"completed",completed_at:new Date().toISOString(),updated_at:new Date().toISOString()}).eq("id",t.id);if(s)throw s;try{await l.functions.invoke("send-review-completion-email",{body:{review_id:t.id,base_url:window.location.origin}})}catch(r){console.error("Failed to send completion email:",r)}c({title:"Review Completed",description:"The review has been marked as complete. The client has been notified via email."}),b(!1),C()}catch(s){console.error("Error completing review:",s),c({variant:"destructive",title:"Error",description:"Failed to mark review as complete."})}finally{H(!1)}}},S=g.filter(s=>s.status==="pending"&&!s.lawyer_id),D=g.filter(s=>s.lawyer_id===(a==null?void 0:a.id)&&s.status==="in_progress"),A=g.filter(s=>s.lawyer_id===(a==null?void 0:a.id)&&s.status==="completed");return E?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(I,{className:"h-8 w-8 animate-spin text-primary"})}):R?e.jsxs(e.Fragment,{children:[e.jsxs(ke,{children:[e.jsx("title",{children:"Lawyer Portal | IntelliContract"}),e.jsx("meta",{name:"description",content:"Lawyer review portal for managing contract reviews"})]}),e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Te,{className:"h-8 w-8 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold",children:"Lawyer Portal"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and review contract review requests"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx(p,{children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pending Reviews"}),e.jsx("p",{className:"text-3xl font-bold",children:S.length})]}),e.jsx(O,{className:"h-8 w-8 text-yellow-500"})]})})}),e.jsx(p,{children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"My Active Reviews"}),e.jsx("p",{className:"text-3xl font-bold",children:D.length})]}),e.jsx(U,{className:"h-8 w-8 text-blue-500"})]})})}),e.jsx(p,{children:e.jsx(j,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),e.jsx("p",{className:"text-3xl font-bold",children:A.length})]}),e.jsx(k,{className:"h-8 w-8 text-green-500"})]})})})]}),e.jsxs(Le,{defaultValue:"pending",className:"space-y-6",children:[e.jsxs(Fe,{children:[e.jsxs(L,{value:"pending",children:["Pending (",S.length,")"]}),e.jsxs(L,{value:"assigned",children:["My Reviews (",D.length,")"]}),e.jsxs(L,{value:"completed",children:["Completed (",A.length,")"]})]}),e.jsx(F,{value:"pending",className:"space-y-4",children:S.length===0?e.jsx(p,{children:e.jsxs(j,{className:"py-12 text-center",children:[e.jsx(O,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No Pending Reviews"}),e.jsx("p",{className:"text-muted-foreground",children:"All review requests have been claimed."})]})}):S.map(s=>e.jsx(T,{review:s,onClaim:()=>ye(s),onView:()=>P(s),claiming:we,showClaim:!0},s.id))}),e.jsx(F,{value:"assigned",className:"space-y-4",children:D.length===0?e.jsx(p,{children:e.jsxs(j,{className:"py-12 text-center",children:[e.jsx(ue,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No Active Reviews"}),e.jsx("p",{className:"text-muted-foreground",children:"Claim a pending review to get started."})]})}):D.map(s=>e.jsx(T,{review:s,onView:()=>P(s)},s.id))}),e.jsx(F,{value:"completed",className:"space-y-4",children:A.length===0?e.jsx(p,{children:e.jsxs(j,{className:"py-12 text-center",children:[e.jsx(k,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No Completed Reviews"}),e.jsx("p",{className:"text-muted-foreground",children:"Complete reviews will appear here."})]})}):A.map(s=>e.jsx(T,{review:s,onView:()=>P(s)},s.id))})]})]})}),e.jsx(ee,{open:je,onOpenChange:b,children:e.jsxs(se,{className:"max-w-4xl max-h-[90vh]",children:[e.jsxs(te,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),((Z=t==null?void 0:t.contracts)==null?void 0:Z.title)||"Contract Review"]}),e.jsx(re,{children:"Review and annotate this contract"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 max-h-[60vh]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{className:"text-base font-medium",children:"Contract Content"}),((G=t==null?void 0:t.contracts)==null?void 0:G.counterparty_name)&&e.jsxs(h,{variant:"outline",children:[e.jsx(Ee,{className:"h-3 w-3 mr-1"}),t.contracts.counterparty_name]})]}),e.jsx(he,{className:"h-[400px] border rounded-lg p-4 bg-muted/30",children:e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-mono",children:((J=t==null?void 0:t.contracts)==null?void 0:J.document_content)||"No contract content available."})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(d,{className:"text-base font-medium",children:"Annotations"}),e.jsxs(m,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[e.jsx(Re,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx(he,{className:"h-[200px] border rounded-lg p-4",children:V.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No annotations yet. Add your first one."}):e.jsx("div",{className:"space-y-3",children:V.map(s=>e.jsxs("div",{className:"border-l-2 border-primary pl-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(h,{variant:"outline",className:"text-xs",children:s.annotation_type}),s.priority==="high"&&e.jsx(h,{variant:"destructive",className:"text-xs",children:"High Priority"})]}),s.section_reference&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Section: ",s.section_reference]}),e.jsx("p",{className:"text-sm",children:s.content})]},s.id))})}),e.jsx(xe,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Lawyer Notes"}),e.jsx(ne,{placeholder:"Add your overall notes for this review...",value:$,onChange:s=>
1z(s.target.value),rows:4}),e.jsx(m,{size:"sm",variant:"outline",onClick:be,children:"Save Notes"})]}),e.jsx(xe,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Upload Reviewed Document"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(ie,{type:"file",accept:".pdf,.doc,.docx",onChange:_e,disabled:fe})}),(t==null?void 0:t.reviewed_document_url)&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ Reviewed document uploaded"})]})]})]}),e.jsxs(le,{children:[e.jsx(m,{variant:"outline",onClick:()=>b(!1),children:"Close"}),(t==null?void 0:t.status)==="in_progress"&&e.jsx(m,{onClick:Ce,disabled:M,children:M?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"h-4 w-4 mr-2 animate-spin"}),"Completing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Mark as Complete"]})})]})]})}),e.jsx(ee,{open:ge,onOpenChange:_,children:e.jsxs(se,{children:[e.jsxs(te,{children:[e.jsx(ae,{children:"Add Annotation"}),e.jsx(re,{children:"Add a comment or suggestion for this contract"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Type"}),e.jsxs(ce,{value:n.type,onValueChange:s=>w({...n,type:s}),children:[e.jsx(oe,{children:e.jsx(de,{})}),e.jsxs(me,{children:[e.jsx(u,{value:"comment",children:"Comment"}),e.jsx(u,{value:"suggestion",children:"Suggestion"}),e.jsx(u,{value:"warning",children:"Warning"}),e.jsx(u,{value:"risk",children:"Risk"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Priority"}),e.jsxs(ce,{value:n.priority,onValueChange:s=>w({...n,priority:s}),children:[e.jsx(oe,{children:e.jsx(de,{})}),e.jsxs(me,{children:[e.jsx(u,{value:"low",children:"Low"}),e.jsx(u,{value:"normal",children:"Normal"}),e.jsx(u,{value:"high",children:"High"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Section Reference (Optional)"}),e.jsx(ie,{placeholder:"e.g., Clause 5.2, Paragraph 3",value:n.section,onChange:s=>w({...n,section:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Content"}),e.jsx(ne,{placeholder:"Your annotation...",value:n.content,onChange:s=>w({...n,content:s.target.value}),rows:4})]})]}),e.jsxs(le,{children:[e.jsx(m,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(m,{onClick:Ne,disabled:!n.content.trim(),children:[e.jsx(Ie,{className:"h-4 w-4 mr-2"}),"Add Annotation"]})]})]})})]}):null},T=({review:a,onClaim:f,onView:E,claiming:v=!1,showClaim:R=!1})=>{var g,y,t;const q=N=>{switch(N){case"pending":return e.jsxs(h,{variant:"secondary",children:[e.jsx(O,{className:"h-3 w-3 mr-1"}),"Pending"]});case"in_progress":return e.jsxs(h,{className:"bg-blue-500",children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),"In Progress"]});case"completed":return e.jsxs(h,{className:"bg-green-500",children:[e.jsx(k,{className:"h-3 w-3 mr-1"}),"Completed"]});default:return e.jsx(h,{variant:"outline",children:N})}};return e.jsx(p,{children:e.jsx(j,{className:"p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:((g=a.contracts)==null?void 0:g.title)||`Review #${a.id.slice(0,8)}`}),q(a.status),(a.priority==="urgent"||a.pricing_tier==="express")&&e.jsxs(h,{variant:"destructive",children:[e.jsx(Oe,{className:"h-3 w-3 mr-1"}),"Express"]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsx("span",{className:"capitalize",children:(y=a.contract_type)==null?void 0:y.replace(/_/g," ")}),e.jsx("span",{children:"•"}),e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ue,{className:"h-3 w-3"}),(t=a.amount)==null?void 0:t.toLocaleString()]}),e.jsx("span",{children:"•"}),e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ve,{className:"h-3 w-3 mr-1"}),qe(a.created_at)]})]}),a.notes&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:a.notes})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(m,{variant:"outline",size:"sm",onClick:E,children:[e.jsx(Pe,{className:"h-4 w-4 mr-1"}),"View"]}
1),R&&f&&e.jsx(m,{size:"sm",onClick:f,disabled:v,children:v?e.jsx(I,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"h-4 w-4 mr-1"}),"Claim"]})})]})]})})})};export{es 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.