1import{ab as y,u as N,M as c,j as e,n,o as i,Q as m,R as x,k as u,h as p,a1 as h,aq as v,s as d}from"./index-CyCBd4px.js";import{C as _}from"./ContractLifecycleLayout-DMRYjWRB.js";import{D as C,A as b}from"./AuditReassurance-CuSeOF_H.js";import"./alert-gEo2fo9L.js";import{C as q}from"./clock-CxyfPBmY.js";import{F as w}from"./file-text-DBDmLy66.js";import{C as f}from"./calendar-BZ_eE7FB.js";import"./lifecycleTransition-BIIvkRvH.js";import"./lifecycleDebug-DPHCQ-Uy.js";import"./alert-dialog-Cj34e275.js";import"./inbox-t9HxFdFJ.js";import"./file-pen-BPpqDhoP.js";import"./scale-kJbD1mqu.js";import"./pen-tool-C428Wt5l.js";import"./triangle-alert-Bhfo5Tdb.js";import"./ContractRefBadge-C4Fpa3qy.js";import"./hash-CRX6cvRd.js";import"./ImmutableRecordBadge-ZKKdklMl.js";import"./lock-BWei1ANb.js";import"./circle-check-big-D5_bUOBn.js";function J(){const{contractId:t}=y();N();const{data:s,isLoading:j}=c({queryKey:["contract-expired",t],queryFn:async()=>{const{data:a,error:r}=await d.from("contracts").select("*").eq("id",t).single();if(r)throw r;return a},enabled:!!t}),{data:o}=c({queryKey:["contract-decisions-expired",t],queryFn:async()=>{const{data:a,error:r}=await d.from("canonical_decisions").select("*").eq("contract_id",t).order("created_at",{ascending:!1});return r?[]:a||[]},enabled:!!t}),{data:g}=c({queryKey:["contract-approvals-expired",t],queryFn:async()=>{const{data:a,error:r}=await d.from("canonical_approvals").select("*").eq("contract_id",t).order("approved_at",{ascending:!1});return r?[]:a||[]},enabled:!!t}),{data:l}=c({queryKey:["contract-history",t],queryFn:async()=>{const{data:a,error:r}=await d.from("contract_state_history").select("*").eq("contract_id",t).order("transitioned_at",{ascending:!1});return r?[]:a||[]},enabled:!!t});return j?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})}):s?e.jsx(_,{contractId:t,title:s.title,contractRef:s.contract_ref,lifecycleState:s.lifecycle_state||"CLOSED",ownerName:"You",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(n,{className:"border-muted bg-muted/30",children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:"h-6 w-6 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-muted-foreground",children:"Contract Expired"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This contract has reached its end date or has been closed."})]})]})})}),e.jsxs(n,{children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(w,{className:"h-5 w-5"}),"Contract Summary"]})}),e.jsx(i,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.counterparty_name&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Counterparty"}),e.jsx("p",{className:"font-medium",children:s.counterparty_name})]}),s.contract_type&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Type"}),e.jsx(u,{variant:"outline",children:s.contract_type})]}),s.start_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start Date"}),e.jsxs("p",{className:"font-medium flex items-center gap-1",children:[e.jsx(f,{className:"h-4 w-4"}),p(s.start_date)]})]}),s.end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"End Date"}),e.jsxs("p",{className:"font-medium flex items-center gap-1",children:[e.jsx(f,{className:"h-4 w-4"}),p(s.end_date)]})]})]})})]}),o&&o.length>0&&e.jsxs(n,{children:[e.jsxs(m,{children:[e.jsx(x,{className:"text-lg",children:"Decision Record"}),e.jsx(h,{children:"The governance record for this contract."})]}),e.jsxs(i,{children:[e.jsx(C,{decisions:o,approvals:g||[]}),e.jsx(b,{className:"mt-4"})]})]}),e.jsxs(n,{children:[e.jsxs(m,{children:[e.jsx(x,{className:"text-lg",children:"Lifecycle History"}),e.jsx(h,{children:"Complete history of state transitions for this contract."})]}),e.jsx(i,{children:l&&l.length>0?e.jsx("div",{className:"space-y-2",children:l.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/30 rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{variant:"outline",children:a.from_state}),e.jsx("span",{className:"text-muted-foreground",children:"â"}),e.jsx(u,{variant:"outline",children:a.to_state})]}),e.jsx("span",{className:"text-muted-foreground",children:v(a.transitioned_at)})]},a.id))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No state history available."})})]})]})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("p",{className:"text-destructive",children:"Contract not found"})})}
1export{J 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.