PageSourceSearch

https://tawrida.xyz/assets/Compliance-Bvbd61Nb.js

js tawrida.xyz collected 2026-10-09 04:47:01 UTC 29,473 bytes, 1 lines download raw bytes

1import{s as de,a3 as D,a as xe,n as be,b as Qe,r as o,j as e,C as se,f as te,g as ie,i as ne,y as ae,z as ce,E as p,F as x,H as re,I as l,t as le,ai as Ve,B as S,N as Ee,a5 as He,u as We}from"./index-CCt2ShGp.js";import{S as De,M as Ge}from"./MainLayout-Ch9e3TXB.js";import{T as Je,a as Xe,b as je,c as ve}from"./tabs-Dm5Iyh7z.js";import{I}from"./input-fPmjrrnt.js";import{L as h}from"./label-CMksTN8T.js";import{T as we}from"./textarea-Bq0eGoE8.js";import{C as Ye}from"./checkbox-DP_GoRdi.js";import{S as _e,a as ge,b as fe,c as Ne,d as ye}from"./select-Dk0TIuWV.js";import{D as Q,a as V,b as H,c as W,e as G,d as J}from"./dialog-Dkm-XMJX.js";import{S as oe}from"./skeleton-BHPs0qJY.js";import{P as E}from"./PermissionButton-B62SIWm5.js";import{u as A}from"./useMutation-xcc-40wd.js";import{p as z,c as Ze,b as N,d as Ae,f as Me,e as Oe,E as Se}from"./exportsApi-BRuD0mJj.js";import{u as es}from"./uploads-BfZrHJ7O.js";import{S as ss}from"./shield-alert-Do1Ruu2U.js";import{U as ts}from"./upload-D2sazISB.js";import{C as is}from"./CountryPicker-C7FZoUGY.js";import{P as Fe}from"./ProductPicker-DXia2QYG.js";import{u as ns}from"./useExportOrders-rUlB6H34.js";import{B as as}from"./badge-check-4JpiUfAQ.js";import"./TopNavbar-CQRsNqmG.js";import"./format-BpaU9Ea-.js";import"./image-DD_uRKCU.js";import"./useImageService-C-9_45Pk.js";import"./inbox-kLm_tfL2.js";import"./user-check-rL_voy2v.js";import"./chart-column-B1Ax6oEf.js";import"./building-CODeCiWt.js";import"./useCountries-B3sYQjLB.js";import"./masterData-B--OpMZm.js";import"./products-NRXYFJ8J.js";import"./chevrons-up-down-BtT5xpz6.js";function cs(t,s){return Ae(`${N(t)}/sanctions-screenings${Me(s)}`)}function rs(t,s){return z(`${N(t)}/sanctions-screenings`,s)}function ls(t,s,a){return z(`${N(t)}/sanctions-screenings/${s}/review`,a)}function os(t,s,a){return z(`${N(t)}/sanctions-screenings/${s}/clear`,a)}function ds(t,s){return Ae(`${N(t)}/screening-tasks${Me(s)}`)}function xs(t){return Oe(`${N(t)}/restricted-destinations`)}function ms(t,s){return z(`${N(t)}/restricted-destinations`,s)}function ps(t,s){return Ze(`${N(t)}/restricted-destinations/${s}`)}function us(t){return Oe(`${N(t)}/dual-use-licenses`)}function hs(t,s){return z(`${N(t)}/dual-use-licenses`,s)}function js(t,s,a){return z(`${N(t)}/dual-use-licenses/${s}/approve`,a)}const me=3e4,pe={tasks:(t,s)=>["exports","compliance","tasks",t,s],screenings:(t,s)=>["exports","compliance","screenings",t,s],restricted:t=>["exports","compliance","restricted",t],licenses:t=>["exports","compliance","licenses",t]};function M(t){t.invalidateQueries({queryKey:["exports","compliance"]}),t.invalidateQueries({queryKey:["exports","buyers"]}),t.invalidateQueries({queryKey:["exports","suppliers"]})}function vs(t,s){return de({queryKey:pe.tasks(t??"",s),queryFn:()=>ds(t,s),enabled:!!t,staleTime:me})}function _s(t,s){return de({queryKey:pe.screenings(t??"",s),queryFn:()=>cs(t,s),enabled:!!t,staleTime:me})}function gs(t){const s=D();return A({mutationFn:a=>rs(t,a),onSuccess:()=>M(s)})}function fs(t){const s=D();return A({mutationFn:({screeningId:a,body:c})=>ls(t,a,c),onSuccess:()=>M(s)})}function Ns(t){const s=D();return A({mutationFn:({screeningId:a,notes:c})=>os(t,a,c?{notes:c}:void 0),onSuccess:()=>M(s)})}function ys(t){return de({queryKey:pe.restricted(t??""),queryFn:()=>xs(t),enabled:!!t,staleTime:me})}function bs(t){const s=D();return A({mutationFn:a=>ms(t,a),onSuccess:()=>M(s)})}function ws(t){const s=D();return A({mutationFn:({restrictionId:a})=>ps(t,a),onSuccess:()=>M(s)})}function Ss(t){return de({queryKey:pe.licenses(t??""),queryFn:()=>us(t),enabled:!!t,staleTime:me})}function Cs(t){const s=D();return A({mutationFn:a=>hs(t,a),onSuccess:()=>M(s)})}function $s(t){const s=D();return A({mutationFn:({licenseId:a,body:c})=>js(t,a,c),onSuccess:()=>M(s)})}const Pe=["ofac_sdn","eu_consolidated","un_sc","uk_hmt"],ks=["clear","match_found","needs_review"],Ts=["false_positive","confirmed","escalated"],qs={clear:"default",match_found:"destructive",needs_review:"secondary"};function Ps({orgId:t}){const{t:s,isRTL:a}=xe(),{toast:c}=be(),L=Qe(),{data:f,isLoading:u}=vs(t,{status:"open",limit:50}),{data:C,isLoading:$}=_s(t,{limit:50}),j=(f==null?void 0:f.data)??[],v=(C==null?void 0:C.data)??[],k=gs(t),_=fs(t),T=Ns(t),[d,y]=o.useState(null),[b,P]=o.useState("clear"),[R,w]=o.useState([]),[r,g]=o.useState(""),[q,U]=o.useState([]),[B,X]=o.useState(""),[ue,n]=o.useState(!1),[K,Y]=o.useState(null),[Ce,$e]=o.useState("false_positive"),[ke,he]=o.useState("");o.useEffect(()=>{d&&(P("clear"),w((d.suggested_lists??[]).filter(i=>Pe.includes(i))),g(""),U([]),X(""))},[d]);const Te=b==="match_found"||b==="needs_review",O=k.isPending||ue,ze=i=>w(m=>m.includes(i)?m.filter(F=>F!==i):[...m,i]),Ue=async i=>{var F;const m=(F=i.target.files)==null?void 0:F[0];if(!(!m||!t)){n(!0);try{const Z=await es(t,m,"sanctions-evidence");U([Z.key]),X(Z.fileName||m.name)}catch(Z){c({variant:"destructive",title:s("exports.compliance.evidence_upload_failed"),description:ee(Z)})}finally{n(!1)}}},Be=async()=>
1{if(d){if(R.length===0){c({variant:"destructive",title:s("exports.compliance.lists_required")});return}if(Te&&q.length===0){c({variant:"destructive",title:s("exports.compliance.evidence_required")});return}try{await k.mutateAsync({task_id:d.id,entity_type:d.entity_type,entity_id:d.entity_id,related_order_id:d.related_order_id??void 0,related_shipment_id:d.related_shipment_id??void 0,related_lc_id:d.related_lc_id??void 0,lists_checked:R,result:b,external_provider_used:r.trim()||void 0,evidence_attachment_s3_keys:q.length?q:void 0}),c({title:s("exports.compliance.screening_recorded")}),y(null)}catch(i){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:ee(i)})}}},Ke=async()=>{if(K)try{await _.mutateAsync({screeningId:K.id,body:{decision:Ce,notes:ke.trim()||void 0}}),c({title:s("exports.compliance.review_saved")}),Y(null),he("")}catch(i){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:ee(i)})}},Ie=async i=>{try{await T.mutateAsync({screeningId:i.id}),c({title:s("exports.compliance.cleared_toast")})}catch(m){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:ee(m)})}},qe=o.useMemo(()=>v.filter(i=>(i.result==="match_found"||i.result==="needs_review")&&!i.review_decision),[v]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(se,{children:[e.jsxs(te,{className:"pb-3",children:[e.jsxs(ie,{className:"text-base flex items-center gap-2",children:[e.jsx(ss,{className:"h-4 w-4 text-amber-600","aria-hidden":!0}),s("exports.compliance.open_tasks_title")]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("exports.compliance.open_tasks_hint")})]}),e.jsx(ne,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ae,{className:"min-w-[820px]",children:[e.jsx(ce,{children:e.jsxs(p,{children:[e.jsx(x,{className:"text-start",children:s("exports.compliance.col_entity")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_trigger")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_suggested_lists")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_related")}),e.jsx(x,{className:"text-end",children:s("exports.compliance.col_actions")})]})}),e.jsxs(re,{children:[u&&Array.from({length:3}).map((i,m)=>e.jsx(p,{children:e.jsx(l,{colSpan:5,children:e.jsx(oe,{className:"h-8 w-full"})})},`tsk-sk-${m}`)),!u&&j.length===0&&e.jsx(p,{children:e.jsx(l,{colSpan:5,className:"text-center text-muted-foreground py-8","data-testid":"screening-tasks-empty",children:s("exports.compliance.no_open_tasks")})}),!u&&j.map(i=>e.jsxs(p,{"data-testid":`screening-task-${i.id}`,children:[e.jsxs(l,{className:"text-sm",children:[e.jsx("div",{children:s(`exports.compliance.entity_${i.entity_type}`)}),e.jsx("div",{className:"font-mono text-[10px] text-muted-foreground truncate max-w-[140px]",children:i.entity_id})]}),e.jsx(l,{className:"text-sm",children:s(`exports.compliance.trigger_${i.trigger_reason}`)}),e.jsx(l,{className:"text-xs",children:(i.suggested_lists??[]).map(m=>s(`exports.compliance.list_${m}`)).join(", ")||"—"}),e.jsx(l,{className:"text-sm",children:i.related_order_id?e.jsx("button",{className:"text-xs hover:underline text-primary",onClick:()=>L(`/exports/orders/${i.related_order_id}`),children:s("exports.compliance.related_order")}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(l,{className:"text-end",children:e.jsxs(E,{module:"exports.compliance",action:"create",scope:"all",variant:"outline",size:"sm",onClick:()=>y(i),"data-testid":`screening-record-${i.id}`,children:[e.jsx(De,{className:`h-3.5 w-3.5 ${a?"ml-1.5":"mr-1.5"}`,"aria-hidden":!0}),s("exports.compliance.action_record")]})})]},i.id))]})]})})})]}),e.jsxs(se,{children:[e.jsxs(te,{className:"pb-3",children:[e.jsx(ie,{className:"text-base",children:s("exports.compliance.screenings_title")}),qe.length>0&&e.jsx("p",{className:"text-sm text-amber-600",children:s("exports.compliance.unreviewed_hint").replace("{n}",String(qe.length))})]}),e.jsx(ne,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ae,{className:"min-w-[820px]",children:[e.jsx(ce,{children:e.jsxs(p,{children:[e.jsx(x,{className:"text-start",children:s("exports.compliance.col_entity")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_result")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_lists")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_review")}),e.jsx(x,{className:"text-end",children:s("exports.compliance.col_actions")})]})}),e.jsxs(re,{children:[$&&Array.from({length:3}).map((i,m)=>e.jsx(p,{children:e.jsx(l,{colSpan:5,children:e.jsx(oe,{className:"h-8 w-full"})})},`scr-sk-${m}`)),!$&&v.length===0&&e.jsx(p,{children:e.jsx(l,{colSpan:5,className:"text-center text-muted-foreground py-8","data-testid":"screenings-empty",children:s("exports.compliance.no_screenings")})}),!$&&v.map(i=>{const m=(i.result==="match_found"||i.result==="needs_review")&&!i.review_decision;return e.jsxs(p,{"data-testid":`screening-${i.id}`,children:[e.jsxs(l,{className:"text-sm",children:[e.jsx("div",{children:s(`exports.compliance.entity_${i.entity_type}`)}),e.jsx("div",{className:"font-mono text-[10px] text-muted-foreground truncate max-w-[140px]",children:i.entity_id})]}),e.jsx(l,{children:e.jsx(le,{variant:qs[i.result],"data-testid":`screening-${i.id}-result-${i.result}`,children:s(`exports.compliance.result_${i.result}`)})}),e.jsx(l,{className:"text-xs",children:(i.lists_checked??[]).map(F=>s(`exports.compliance.list_${F}`)).join(", ")||"—"}),e.jsx(l,{className:"text-xs",children:i.review_decision?e.jsx(le,{variant:"outline",children:s(`exports.compliance.decision_${i.review_decision}`)}):m?e.jsx("span",{className:"text-amber-600",children:s("exports.compliance.awaiting_review")}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(l,{className:"text-end whitespace-nowrap",children:m?e.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[e.jsx(E,{module:"exports.compliance.review",action:"update",scope:"all",variant:"outline",size:"sm",onClick:()=>{Y(i),$e("false_positive"),he("")},"data-testid":`screening-review-${i.id}`,children:s("exports.compliance.action_review")}),e.jsx(E,{module:"exports.compliance",action:"update",scope:"all",variant:"ghost",size:"sm",onClick:()=>Ie(i),disabled:T.isPending,"data-testid":`screening-clear-${i.id}`,children:s("exports.compliance.action_clear")})]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})})]},i.id)})]})]})})})]}),e.jsx(Q,{open:d!==null,onOpenChange:i=>{i||y(null)},children:e.jsxs(V,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",dir:a?"rtl":"ltr","data-testid":"screening-record-dialog",children:[e.jsxs(H,{
1children:[e.jsx(W,{children:s("exports.compliance.record_title")}),e.jsx(G,{children:s("exports.compliance.record_description")})]}),d&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("exports.compliance.col_entity")}),e.jsx("span",{children:s(`exports.compliance.entity_${d.entity_type}`)})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:s("exports.compliance.col_trigger")}),e.jsx("span",{children:s(`exports.compliance.trigger_${d.trigger_reason}`)})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_lists")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Pe.map(i=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx(Ye,{checked:R.includes(i),onCheckedChange:()=>ze(i),disabled:O,"data-testid":`screening-list-${i}`}),s(`exports.compliance.list_${i}`)]},i))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_result")}),e.jsxs(_e,{value:b,onValueChange:i=>P(i),disabled:O,children:[e.jsx(ge,{"data-testid":"screening-result-select",children:e.jsx(fe,{})}),e.jsx(Ne,{children:ks.map(i=>e.jsx(ye,{value:i,"data-testid":`screening-result-${i}`,children:s(`exports.compliance.result_${i}`)},i))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_provider")}),e.jsx(I,{value:r,onChange:i=>g(i.target.value),disabled:O,placeholder:s("exports.compliance.provider_placeholder"),"data-testid":"screening-provider"})]}),Te&&e.jsxs("div",{className:"space-y-1.5 rounded-md border border-amber-300/60 p-3",children:[e.jsxs(h,{className:"text-sm flex items-center gap-1.5",children:[e.jsx(ts,{className:"h-3.5 w-3.5","aria-hidden":!0}),s("exports.compliance.field_evidence"),e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(I,{type:"file",onChange:Ue,disabled:O,"data-testid":"screening-evidence-file"}),B&&e.jsxs("p",{className:"text-xs text-emerald-600 flex items-center gap-1",children:[e.jsx(Ve,{className:"h-3 w-3","aria-hidden":!0}),B]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("exports.compliance.evidence_hint")})]})]}),e.jsxs(J,{children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>y(null),disabled:O,children:s("exports.actions.cancel")}),e.jsx(S,{type:"button",onClick:Be,disabled:O,"data-testid":"screening-record-confirm",children:s("exports.compliance.action_record")})]})]})}),e.jsx(Q,{open:K!==null,onOpenChange:i=>{i||Y(null)},children:e.jsxs(V,{className:"sm:max-w-md",dir:a?"rtl":"ltr","data-testid":"screening-review-dialog",children:[e.jsxs(H,{
1children:[e.jsx(W,{children:s("exports.compliance.review_title")}),e.jsx(G,{children:s("exports.compliance.review_description")})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_decision")}),e.jsxs(_e,{value:Ce,onValueChange:i=>$e(i),disabled:_.isPending,children:[e.jsx(ge,{"data-testid":"screening-decision-select",children:e.jsx(fe,{})}),e.jsx(Ne,{children:Ts.map(i=>e.jsx(ye,{value:i,"data-testid":`screening-decision-${i}`,children:s(`exports.compliance.decision_${i}`)},i))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_review_notes")}),e.jsx(we,{rows:2,value:ke,onChange:i=>he(i.target.value),disabled:_.isPending,"data-testid":"screening-review-notes"})]})]}),e.jsxs(J,{children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>Y(null),disabled:_.isPending,children:s("exports.actions.cancel")}),e.jsx(S,{type:"button",onClick:Ke,disabled:_.isPending,"data-testid":"screening-review-confirm",children:s("exports.compliance.action_review")})]})]})})]})}function ee(t){return t instanceof Se?t.message:(t==null?void 0:t.message)??""}function Rs({orgId:t}){const{t:s,isRTL:a}=xe(),{toast:c}=be(),{data:L=[],isLoading:f}=ys(t),u=bs(t),C=ws(t),[$,j]=o.useState(!1),[v,k]=o.useState(""),[_,T]=o.useState(null),[d,y]=o.useState(""),[b,P]=o.useState("");o.useEffect(()=>{$&&(k(""),T(null),y(""),P(""))},[$]);const R=async()=>{if(!v){c({variant:"destructive",title:s("exports.compliance.country_required")});return}try{await u.mutateAsync({country_id:v,organization_product_id:_??void 0,reason:d.trim()||void 0,override_permission:b.trim()||void 0}),c({title:s("exports.compliance.restriction_added")}),j(!1)}catch(r){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:Re(r)})}},w=async r=>{try{await C.mutateAsync({restrictionId:r}),c({title:s("exports.compliance.restriction_removed")})}catch(g){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:Re(g)})}};return e.jsxs(se,{children:[e.jsxs(te,{className:"pb-3 flex flex-row items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(ie,{className:"text-base",children:s("exports.compliance.restricted_title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("exports.compliance.restricted_hint")})]}),e.jsxs(E,{module:"exports.compliance",action:"create",scope:"all",variant:"outline",size:"sm",onClick:()=>j(!0),"data-testid":"restriction-add-button",children:[e.jsx(Ee,{className:`h-4 w-4 ${a?"ml-1.5":"mr-1.5"}`,"aria-hidden":!0}),s("exports.compliance.action_add_restriction")]})]}),e.jsx(ne,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ae,{className:"min-w-[760px]",children:[e.jsx(ce,{children:e.jsxs(p,{children:[e.jsx(x,{className:"text-start",children:s("exports.compliance.col_country")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_product")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_reason")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_override")}),e.jsx(x,{className:"text-end",children:s("exports.compliance.col_actions")})]})}),e.jsxs(re,{children:[f&&Array.from({length:2}).map((r,g)=>e.jsx(p,{children:e.jsx(l,{colSpan:5,children:e.jsx(oe,{className:"h-8 w-full"})})},`rd-sk-${g}`)),!f&&L.length===0&&e.jsx(p,{children:e.jsx(l,{colSpan:5,className:"text-center text-muted-foreground py-8","data-testid":"restrictions-empty",children:s("exports.compliance.no_restrictions")})}),!f&&L.map(r=>{var g,q;return e.jsxs(p,{"data-testid":`restriction-${r.id}`,children:[e.jsx(l,{className:"text-sm",children:((g=r.country)==null?void 0:g.name)??r.country_id}),e.jsx(l,{className:"text-sm",children:((q=r.organization_product)==null?void 0:q.name)??(r.organization_product_id?"—":e.jsx(le,{variant:"outline",children:s("exports.compliance.all_products")}))}),e.jsx(l,{className:"text-sm text-muted-foreground",children:r.reason||"—"}),e.jsx(l,{className:"text-xs font-mono text-muted-foreground",children:r.override_permission||"—"}),e.jsx(l,{className:"text-end",children:e.jsxs(E,{module:"exports.compliance",action:"delete",scope:"all",variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-destructive",onClick:()=>w(r.id),disabled:C.isPending,"data-testid":`restriction-remove-${r.id}`,children:[e.jsx(He,{className:`h-3.5 w-3.5 ${a?"ml-1.5":"mr-1.5"}`,"aria-hidden":!0}),s("exports.compliance.action_remove")]})})]},r.id)})]})]})})}),e.jsx(Q,{open:$,onOpenChange:j,children:e.jsxs(V,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",dir:a?"rtl":"ltr","data-testid":"restriction-add-dialog",children:[e.jsxs(H,{
1children:[e.jsx(W,{children:s("exports.compliance.add_restriction_title")}),e.jsx(G,{children:s("exports.compliance.add_restriction_description")})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(h,{className:"text-sm",children:[s("exports.compliance.col_country"),e.jsx("span",{className:"text-destructive ms-1",children:"*"})]}),e.jsx(is,{value:v,onChange:k,disabled:u.isPending,testId:"restriction-country-picker"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_product_optional")}),e.jsx(Fe,{orgId:t,value:_,onSelect:r=>T((r==null?void 0:r.id)??null),disabled:u.isPending,testId:"restriction-product-picker"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("exports.compliance.product_optional_hint")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.col_reason")}),e.jsx(we,{rows:2,value:d,onChange:r=>y(r.target.value),disabled:u.isPending,"data-testid":"restriction-reason"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_override_permission")}),e.jsx(I,{value:b,onChange:r=>P(r.target.value),disabled:u.isPending,placeholder:"exports.orders.override_restriction.all",className:"font-mono text-xs","data-testid":"restriction-override-permission"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("exports.compliance.override_permission_hint")})]})]}),e.jsxs(J,{children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>j(!1),disabled:u.isPending,children:s("exports.actions.cancel")}),e.jsx(S,{type:"button",onClick:R,disabled:u.isPending,"data-testid":"restriction-add-confirm",children:s("exports.compliance.action_add_restriction")})]})]})})]})}function Re(t){return t instanceof Se?t.message:(t==null?void 0:t.message)??""}const Ls={requested:"secondary",approved:"default",denied:"destructive"};function Es({orgId:t}){const{t:s,isRTL:a}=xe(),{toast:c}=be(),{data:L=[],isLoading:f}=Ss(t),{data:u}=ns(t,{limit:100}),C=(u==null?void 0:u.data)??[],$=new Map(C.map(n=>[n.id,n.order_number])),j=Cs(t),v=$s(t),[k,_]=o.useState(!1),[T,d]=o.useState(""),[y,b]=o.useState(null),[P,R]=o.useState(""),[w,r]=o.useState(null),[g,q]=o.useState(""),[U,B]=o.useState("");o.useEffect(()=>{k&&(d(""),b(null),R(""))},[k]),o.useEffect(()=>{w&&(q(""),B(""))},[w]);const X=async()=>{if(!T){c({variant:"destructive",title:s("exports.compliance.order_required")});return}try{await j.mutateAsync({export_order_id:T,organization_product_id:y??void 0,notes:P.trim()||void 0}),c({title:s("exports.compliance.license_requested")}),_(!1)}catch(n){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:Le(n)})}},ue=async()=>{if(w){if(!g.trim()){c({variant:"destructive",title:s("exports.compliance.license_number_required")});return}try{await v.mutateAsync({licenseId:w.id,body:{export_license_number:g.trim(),license_expiry:U||void 0}}),c({title:s("exports.compliance.license_approved")}),r(null)}catch(n){c({variant:"destructive",title:s("exports.compliance.action_failed"),description:Le(n)})}}};return e.jsxs(se,{children:[e.jsxs(te,{className:"pb-3 flex flex-row items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(ie,{className:"text-base",children:s("exports.compliance.dualuse_title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("exports.compliance.dualuse_hint")})]}),e.jsxs(E,{module:"exports.compliance",action:"create",scope:"all",variant:"outline",size:"sm",onClick:()=>_(!0),"data-testid":"license-request-button",children:[e.jsx(Ee,{className:`h-4 w-4 ${a?"ml-1.5":"mr-1.5"}`,"aria-hidden":!0}),s("exports.compliance.action_request_license")]})]}),e.jsx(ne,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ae,{className:"min-w-[820px]",children:[e.jsx(ce,{children:e.jsxs(p,{children:[e.jsx(x,{className:"text-start",children:s("exports.compliance.col_order")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_status")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_license_number")}),e.jsx(x,{className:"text-start",children:s("exports.compliance.col_expiry")}),e.jsx(x,{className:"text-end",children:s("exports.compliance.col_actions")})]})}),e.jsxs(re,{children:[f&&Array.from({length:2}).map((n,K)=>e.jsx(p,{children:e.jsx(l,{colSpan:5,children:e.jsx(oe,{className:"h-8 w-full"})})},`du-sk-${K}`)),!f&&L.length===0&&e.jsx(p,{children:e.jsx(l,{colSpan:5,className:"text-center text-muted-foreground py-8","data-testid":"licenses-empty",children:s("exports.compliance.no_licenses")})}),!f&&L.map(n=>e.jsxs(p,{"data-testid":`license-${n.id}`,children:[e.jsx(l,{className:"text-sm font-mono text-xs",children:$.get(n.export_order_id)??n.export_order_id.slice(0,8)}),e.jsx(l,{children:e.jsx(le,{variant:Ls[n.status],"data-testid":`license-${n.id}-status-${n.status}`,children:s(`exports.compliance.license_status_${n.status}`)})}),e.jsx(l,{className:"text-sm",children:n.export_license_number||"—"}),e.jsx(l,{className:"text-sm",children:n.license_expiry?n.license_expiry.slice(0,10):"—"}),e.jsx(l,{className:"text-end",children:n.status==="requested"?e.jsxs(E,{module:"exports.compliance",action:"update",scope:"all",variant:"outline",size:"sm",onClick:()=>r(n),"data-testid":`license-approve-${n.id}`,children:[e.jsx(as,{className:`h-3.5 w-3.5 ${a?"ml-1.5":"mr-1.5"}`,"aria-hidden":!0}),s("exports.compliance.action_approve_license")]}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})})]},n.id))]})]})})}),e.jsx(Q,{open:k,onOpenChange:_,children:e.jsxs(V,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",dir:a?"rtl":"ltr","data-testid":"license-request-dialog",children:[e.jsxs(H,{
1children:[e.jsx(W,{children:s("exports.compliance.request_license_title")}),e.jsx(G,{children:s("exports.compliance.request_license_description")})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(h,{className:"text-sm",children:[s("exports.compliance.col_order"),e.jsx("span",{className:"text-destructive ms-1",children:"*"})]}),e.jsxs(_e,{value:T,onValueChange:d,disabled:j.isPending,children:[e.jsx(ge,{"data-testid":"license-order-select",children:e.jsx(fe,{placeholder:s("exports.common.choose")})}),e.jsx(Ne,{children:C.map(n=>e.jsx(ye,{value:n.id,"data-testid":`license-order-${n.id}`,children:n.order_number},n.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_product_optional")}),e.jsx(Fe,{orgId:t,value:y,onSelect:n=>b((n==null?void 0:n.id)??null),disabled:j.isPending,testId:"license-product-picker"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.field_notes")}),e.jsx(we,{rows:2,value:P,onChange:n=>R(n.target.value),disabled:j.isPending,"data-testid":"license-notes"})]})]}),e.jsxs(J,{children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>_(!1),disabled:j.isPending,children:s("exports.actions.cancel")}),e.jsx(S,{type:"button",onClick:X,disabled:j.isPending,"data-testid":"license-request-confirm",children:s("exports.compliance.action_request_license")})]})]})}),e.jsx(Q,{open:w!==null,onOpenChange:n=>{n||r(null)},children:e.jsxs(V,{className:"sm:max-w-md",dir:a?"rtl":"ltr","data-testid":"license-approve-dialog",children:[e.jsxs(H,{
1children:[e.jsx(W,{children:s("exports.compliance.approve_license_title")}),e.jsx(G,{children:s("exports.compliance.approve_license_description")})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(h,{className:"text-sm",children:[s("exports.compliance.col_license_number"),e.jsx("span",{className:"text-destructive ms-1",children:"*"})]}),e.jsx(I,{value:g,onChange:n=>q(n.target.value),disabled:v.isPending,"data-testid":"license-number-input"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(h,{className:"text-sm",children:s("exports.compliance.col_expiry")}),e.jsx(I,{type:"date",value:U,onChange:n=>B(n.target.value),disabled:v.isPending,"data-testid":"license-expiry-input"})]})]}),e.jsxs(J,{children:[e.jsx(S,{type:"button",variant:"ghost",onClick:()=>r(null),disabled:v.isPending,children:s("exports.actions.cancel")}),e.jsx(S,{type:"button",onClick:ue,disabled:v.isPending,"data-testid":"license-approve-confirm",children:s("exports.compliance.action_approve_license")})]})]})})]})}function Le(t){return t instanceof Se?t.message:(t==null?void 0:t.message)??""}function pt(){const{t,isRTL:s}=xe(),{getCurrentOrganizationId:a}=We(),c=a();return e.jsx(Ge,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6",dir:s?"rtl":"ltr","data-testid":"exports-compliance-page",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold tracking-tight flex items-center gap-2",children:[e.jsx(De,{className:"h-5 w-5","aria-hidden":!0}),t("exports.compliance.title")]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("exports.compliance.subtitle")})]}),c&&e.jsxs(Je,{defaultValue:"screening",className:"w-full",children:[e.jsxs(Xe,{children:[e.jsx(je,{value:"screening","data-testid":"compliance-tab-screening",children:t("exports.compliance.tab_screening")}),e.jsx(je,{value:"restricted","data-testid":"compliance-tab-restricted",children:t("exports.compliance.tab_restricted")}),e.jsx(je,{value:"dualuse","data-testid":"compliance-tab-dualuse",children:t("exports.compliance.tab_dualuse")})]}),e.jsx(ve,{value:"screening",className:"mt-4",children:e.jsx(Ps,{orgId:c})}),e.jsx(ve,{value:"restricted",className:"mt-4",children:e.jsx(Rs,{orgId:c})}),e.jsx(ve,{value:"dualuse",className:"mt-4",children:e.jsx(Es,{orgId:c})})]})]})})}export{pt 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.