PageSourceSearch

https://app.verbix.ai/assets/index-Cn7svo88.js

js verbix.ai collected 2026-10-05 13:54:03 UTC 15,574 bytes, 1 lines download raw bytes

1import{e as b,u as I,p as ee,r as c,j as e,C as te,q as Y,n as ae,D as W,S as se}from"./index-jmx1CJ5H.js";import{A as q}from"./ActionButton-BWKzBBnO.js";import{T as K}from"./ToggleSwitch-CuQxza_f.js";import{P as X}from"./pencil-UGJV4GmF.js";import{M as re}from"./ManagementTable-DCUOCC2g.js";import{P as le}from"./PageHeader-CkQKu4xM.js";import{P as oe}from"./PageWrapper-CCnK_byA.js";import{T as ne}from"./ThemedDropdown-K28QxV7p.js";import{L as Z}from"./list-checks-CB4PfshH.js";import"./PageToolbar-D7lryljW.js";import"./search-5NPkC-jz.js";import"./DataTable-BLniFSoP.js";import"./CommonPagination-CB9HkcoT.js";const ce=s=>b.get(`/auto-flags?companyId=${s}`),ie=(s,a)=>s?b.put(`/auto-flags/${s}`,a):b.post("/auto-flags",a),ue=(s,a)=>b.put(`/auto-flags/${s}`,a),de=s=>b.delete(`/auto-flags/${s}`),ge=()=>{const{t:s}=I(),{showAlert:a,showConfirm:m}=ee(),[o,u]=c.useState([]),[d,n]=c.useState(!0),[y,t]=c.useState(!1),[r,v]=c.useState(""),[x,G]=c.useState(""),[k,A]=c.useState(1),[j]=c.useState(25),[_,L]=c.useState("flag_name"),[R,D]=c.useState("asc"),[M,T]=c.useState(!1),[P,w]=c.useState(null),[F,C]=c.useState({flag_name:"",flag_question:"",status:!0,category:"Compliance",flag_color:"#E2E8F0",rule_group_name:""}),N=async()=>{n(!0);try{const i=JSON.parse(globalThis.localStorage.getItem("user")||"{}").company_id||"",g=await ce(i);u(g.data)}catch(l){console.error("Error fetching flags:",l)}finally{n(!1)}};c.useEffect(()=>{N()},[]);const S=()=>{C({flag_name:"",flag_question:"",status:!0,category:"Compliance",flag_color:"#E2E8F0",rule_group_name:""})},O=async()=>{if(!F.flag_name.trim()||!F.flag_question.trim()){a(s("alerts.validationErrorTitle"),s("autoFlags.validationError"),"warning");return}try{const i=JSON.parse(globalThis.localStorage.getItem("user")||"{}").company_id||"",g={...F,company_id:i};await ie(P?.id,g),T(!1),w(null),S(),N()}catch(l){console.error("Error saving flag:",l),a(s("alerts.saveErrorTitle"),s("autoFlags.saveError"),"error")}},V=async l=>{try{await ue(l.id,{...l,status:!l.status}),u(i=>i.map(g=>g.id===l.id?{...g,status:!g.status}:g))}catch(i){console.error("Error toggling flag status:",i)}},z=async l=>{m(s("autoFlags.deleteConfirmTitle"),s("autoFlags.deleteConfirmMessage"),async()=>{try{await de(l),N(),a(s("alerts.saveSuccessTitle"),s("autoFlags.deleteSuccess"),"success")}catch(i){console.error("Error deleting flag:",i),a(s("alerts.saveErrorTitle"),s("autoFlags.deleteError"),"error")}},"danger")},[E,U]=c.useState("");let f=o.filter(l=>{const i=(l.flag_name||"").toLowerCase().includes(r.toLowerCase())||(l.flag_question||"").toLowerCase().includes(r.toLowerCase()),g=!x||(x==="Active"?l.status===!0:l.status===!1),h=!E||l.rule_group_name===E;return i&&g&&h});_==="flag_name"&&(f=f.sort((l,i)=>{const g=l.flag_name||"",h=i.flag_name||"",H=g.localeCompare(h);return R==="asc"?H:-H}));const $=k*j,B=$-j,Q=f.slice(B,$),J=Math.ceil(f.length/j),p=o.filter(l=>l.status).length;return{flags:o,setFlags:u,loading:d,refreshData:N,isRefreshing:y,setIsRefreshing:t,searchQuery:r,setSearchQuery:v,statusFilter:x,setStatusFilter:G,ruleGroupFilter:E,setRuleGroupFilter:U,page:k,setPage:A,rowsPerPage:j,sortBy:_,setSortBy:L,sortOrder:R,setSortOrder:D,isAddingFlag:M,setIsAddingFlag:T,editingFlag:P,setEditingFlag:w,flagForm:F,setFlagForm:C,resetForm:S,handleSaveFlag:O,toggleFlagStatus:V,handleDeleteFlag:z,filteredFlags:f,currentRows:Q,totalPages:J,activeFlagsCount:p}};function me({setEditingFlag:s,setFlagForm:a,setIsAddingFlag:m,handleDeleteFlag:o,toggleFlagStatus:u}){const{t:d}=I();return{columns:[{label:d("autoFlags.flagName"),key:"flag_name",sortable:!0,width:"25%",render:t=>e.jsxs("div",{className:"text-xs font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(te,{size:14,className:"text-[#EF4444]"}),t.flag_name]})},{label:d("autoFlags.aiEvaluationLogic"),key:"flag_question",width:"40%",render:t=>e.jsxs("div",{className:"text-[11px] text-gray-600 bg-gray-50/50 p-2 rounded-lg border border-gray-100 truncate max-w-xs italic",title:t.flag_question,children:['"',t.flag_question,'"']})},{label:d("autoFlags.flagColor"),width:"15%",render:t=>{const r=!t.flag_color||t.flag_color.toUpperCase()==="#E2E8F0"||t.flag_color.toUpperCase()==="DEFAULT";return e.jsxs("div",{className:"flex items-center gap-2 justify-center",children:[e.jsx("div",{className:`w-3.5 h-3.5 rounded-full border border-gray-200 shadow-sm ${r?"bg-slate-100":""}`,style:r?{}:{backgroundColor:t.flag_color}}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-tight ${r?"text-slate-400":"text-gray-600"}`,children:r?d("autoFlags.defaultColor"):t.flag_color})]})}},{label:d("common.status"),width:"10%",headerClassName:"text-center",className:"text-center",render:t=>e.jsx(K,{checked:t.status,onChange:()=>u(t),size:"sm"})},{label:d("common.actions"),width:"10%",headerClassName:"text-center",className:"text-center",render:t=>e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(q,{icon:X,tooltip:d("autoFlags.editFlag"),onClick:r=>{r?.stopPropagation(),s(t),a({flag_name:t.flag_name,flag_question:t.flag_question,status:t.status,category:t.category||"General",flag_color:t.flag_color||"#EF4444",rule_group_name:t.rule_group_name||""}),m(!0)}}),e.jsx(q,{icon:Y,variant:"danger",tooltip:d("autoFlags.deleteFlag"),onClick:r=>{r?.stopPropagation(),o(t.id)}})]})}],renderMobileCard:t=>e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden p-5",children:[e.jsxs("div",{className:"flex justify-between items-start gap-3 mb-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${t.status?"bg-emerald-500 animate-status-pulse":"bg-gray-300"}`}),e.jsx("span",{className:"text-sm font-bold text-gray-900 leading-tight truncate",children:t.flag_name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border border-gray-100 shadow-inner ${!t.flag_color||t.flag_color.toUpperCase()==="#E2E8F0"?"bg-slate-100":""}`,style:!t.flag_color||t.flag_color.toUpperCase()==="#E2E8F0"?{}:{backgroundColor:t.flag_color}}),e.jsx("span",{className:`text-[9px] font-black uppercase tracking-widest ${!t.flag_color||t.flag_color.toUpperCase()==="#E2E8F0"?"text-slate-400":"text-gray-400"}`,children:!t.flag_color||t.flag_color.toUpperCase()==="#E2E8F0"?"DEFAULT":t.flag_color||"#E2E8F0"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 bg-gray-50 p-1 rounded-xl border border-gray-100",children:[e.jsx(q,{icon:X,size:"sm",onClick:()=>{s(t),a({flag_name:t.flag_name,flag_question:t.flag_question,status:t.status,category:t.category||"General",flag_color:t.flag_color||"#EF4444",rule_group_name:t.rule_group_name||""}),m(!0)}}),e.jsx(q,{icon:Y,variant:"danger",size:"sm",onClick:()=>o(t.id)})]})]}),e.jsx("div",{className:"p-4 bg-gradient-to-br from-gray-50/50 to-white rounded-xl border border-gray-100 border-dashed mb
1-4",children:e.jsxs("p",{className:"text-[11px] text-gray-600 font-medium leading-relaxed line-clamp-2 italic",children:['"',t.flag_question,'"']})}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-gray-50",children:[e.jsx("span",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:d("common.status")}),e.jsx(K,{checked:t.status,onChange:()=>u(t),size:"sm"})]})]})}}const pe=({checked:s,onChange:a,size:m="md"})=>{const o={sm:"h-4 w-7",md:"h-5 w-9",lg:"h-6 w-11"},u={sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"},d={sm:"translate-x-3 rtl:-translate-x-3",md:"translate-x-4 rtl:-translate-x-4",lg:"translate-x-5 rtl:-translate-x-5"};return e.jsxs("button",{type:"button",role:"switch","aria-checked":s,onClick:a,className:`relative inline-flex shrink-0 cursor-pointer items-center rounded-full transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 ${s?"bg-gradient-to-r from-[#EF4444] to-[#f43f5e]":"bg-gray-200"} ${o[m]}`,children:[e.jsx("span",{className:"sr-only",children:"Toggle status"}),e.jsx("span",{className:`pointer-events-none inline-block transform rounded-full bg-white shadow-lg ring-0 transition-transform duration-200 ease-in-out ${s?d[m]:"translate-x-0.5 rtl:-translate-x-0.5"} ${u[m]}`})]})};function xe({isOpen:s,onClose:a,editingFlag:m,flagForm:o,setFlagForm:u,onSave:d}){const{t:n}=I(),[y,t]=c.useState([]);return c.useEffect(()=>{s&&b.get("/compliance/settings/type/Rules Group").then(r=>{const v=(r.data||[]).filter(x=>x.mandatory==="Yes");t(v)}).catch(r=>{console.error("Error fetching rule groups:",r)})},[s]),e.jsx(ae,{isOpen:s,onClose:a,title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-[#EF4444] to-[#f43f5e]",children:e.jsx(W,{size:16,className:"text-white"})}),e.jsx("span",{className:"text-sm font-bold text-gray-900",children:n(m?"autoFlags.editTrigger":"autoFlags.newAutoFlag")})]}),maxWidth:"max-w-md",children:e.jsxs("form",{onSubmit:r=>{r.preventDefault(),d()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[9px] font-bold text-gray-500 uppercase mb-1",children:[n("autoFlags.flagName")," ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("input",{type:"text",className:"w-full bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 text-xs focus:ring-4 focus:ring-red-500/5 focus:border-red-300 outline-none transition-all font-medium text-gray-900",placeholder:n("autoFlags.flagNamePlaceholder"),value:o.flag_name,onChange:r=>u({...o,flag_name:r.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-1 relative group",children:[e.jsx("label",{className:"block text-[9px] font-bold text-gray-500 uppercase mb-1",children:n("rulesGroup.title",{defaultValue:"Rule Group"})}),e.jsx(ne,{label:n("rulesGroup.selectGroup",{defaultValue:"Select Rule Group"}),value:o.rule_group_name||"",onChange:r=>u({...o,rule_group_name:r||null}),options:[{value:"",label:n("common.none",{defaultValue:"None"})},...y.map(r=>({value:r.statement,label:n(r.statement,{defaultValue:r.statement})}))],icon:Z,placeholder:n("rulesGroup.selectGroup",{defaultValue:"Select Rule Group"}),fullWidth:!0,maxHeight:116})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[9px] font-bold text-gray-500 uppercase mb-1",children:[n("autoFlags.evaluationLogic")," ",e.jsx("span",{className:"text-rose-500",children:"*"})]}),e.jsx("textarea",{className:"w-full bg-gray-50 border border-gray-200 rounded-lg px-3 py-2 text-xs focus:ring-4 focus:ring-red-500/5 focus:border-red-300 outline-none transition-all min-h-[100px] resize-none font-medium text-gray-900",placeholder:n("autoFlags.logicPlaceholder"),value:o.flag_question,onChange:r=>u({...o,flag_question:r.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[9px] font-bold text-gray-500 uppercase mb-1",children:n("autoFlags.flagColor")}),e.jsxs("div",{className:"h-9 flex items-center gap-0 border border-gray-200 bg-gray-50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"w-9 h-full shrink-0 border-e border-gray-200 flex items-center justify-center bg-white p-1 relative",children:[e.jsx("div",{className:"w-full h-full rounded shadow-inner border border-gray-100",style:{backgroundColor:o.flag_color}}),e.jsx("input",{type:"color",className:"absolute inset-0 opacity-0 cursor-pointer",value:o.flag_color,onChange:r=>u({...o,flag_color:r.target.value})})]}),e.jsx("input",{type:"text",className:"flex-1 px-2 h-full text-[10px] outline-none text-slate-800 font-bold uppercase bg-transparent",value:o.flag_color,onChange:r=>u({...o,flag_color:r.target.value})})]})]}),e.jsxs("div",{className:"flex items-center justify-between bg-gray-50/50 p-3 rounded-xl border border-gray-100",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-bold text-gray-900 uppercase",children:n("autoFlags.activeStatus")}),e.jsx("p",{className:"text-[9px] text-gray-500",children:n("autoFlags.evaluateForNewCalls")})]}),e.jsx(pe,{checked:o.status,onChange:()=>u({...o,status:!o.status})})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-gray-100",children:[e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 text-xs font-bold text-gray-600 hover:bg-gray-50 rounded-lg transition-colors border border-transparent hover:border-gray-200",children:n("common.cancel")}),e.jsx("button",{type:"submit",className:"bg-gradient-to-r from-[#EF4444] to-[#f43f5e] text-white px-4 py-2 rounded-lg text-xs font-bold transition-all active:scale-95 shadow-md shadow-red-100 hover:from-red-600 hover:to-rose-600",children:n(m?"common.saveChanges":"autoFlags.newAutoFlag")})]})]})})}function Ge({setBreadcrumbs:s}){const{t:a}=I(),[m,o]=c.useState([]),{flags:u,loading:d,refreshData:n,isRefreshing:y,setIsRefreshing:t,searchQuery:r,setSearchQuery:v,statusFilter:x,setStatusFilter:G,ruleGroupFilter:k,setRuleGroupFilter:A,page:j,setPage:_,rowsPerPage:L,sortBy:R,setSortBy:D,sortOrder:M,setSortOrder:T,isAddingFlag:P,setIsAddingFlag:w,editingFlag:F,setEditingFlag:C,flagForm:N,setFlagForm:S,resetForm:O,handleSaveFlag:V,toggleFlagStatus:z,handleDeleteFlag:E,filteredFlags:U,currentRows:f,totalPages:$,activeFlagsCount:B}=ge(),{columns:Q,renderMobileCard:J}=me({setEditingFlag:C,setFlagForm:S,setIsAddingFlag:w,handleDeleteFlag:E,toggleFlagStatus:z});return c.useEffect(()=>{const l=JSON.parse(globalThis.localStorage.getItem("user")||"{}").company_id||"";
1b.get(`/compliance/settings/type/Rules Group?companyId=${l}`).then(i=>{const g=(Array.isArray(i.data)?i.data:[]).filter(h=>h.mandatory==="Yes").map(h=>h.statement);o(g)}).catch(i=>console.error("Error fetching rule groups:",i))},[]),c.useEffect(()=>{s&&s([{label:a("sidebar.aiAnalytics",{defaultValue:"AI Analytics"})},{label:a("autoFlags.title")}])},[s,a]),e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(le,{title:a("autoFlags.title"),icon:W,stats:[{label:`${u.length} ${a("autoFlags.totalFlags")}`,valueColorClass:"text-[#EF4444]"},{label:`${B} ${a("autoFlags.active")}`,colorClass:"bg-emerald-500"}],actionButton:{label:a("autoFlags.addNewFlag"),onClick:()=>{C(null),O(),w(!0)}}}),e.jsx("div",{className:"flex-1 md:overflow-y-auto overflow-x-hidden custom-scrollbar",children:e.jsx("div",{className:"p-4 sm:px-8 py-0 flex flex-col min-h-full",children:e.jsx(re,{searchQuery:r,onSearchChange:v,searchPlaceholder:a("autoFlags.searchPlaceholder"),onRefresh:async()=>{v(""),G(""),A(""),_(1),t(!0),await n(),t(!1)},loading:d||y,dropdowns:[{label:a("autoFlags.filterStatus"),value:x,onChange:G,options:[{value:"",label:a("alerts.allStatuses")},{value:"Active",label:a("alerts.activeOnly")},{value:"Inactive",label:a("alerts.inactiveOnly")}],icon:se,placeholder:a("alerts.allStatuses")},{label:a("rulesGroup.selectGroup",{defaultValue:"Select Rule Group"}),value:k,onChange:p=>{A(p),_(1)},options:[{value:"",label:a("common.all",{defaultValue:"All Groups"})},...m.map(p=>({value:p,label:p}))],icon:Z,placeholder:a("rulesGroup.selectGroup",{defaultValue:"Select Rule Group"})}],columns:Q,data:f,loaderIcon:W,loaderMessage:a("autoFlags.loading"),renderMobileCard:J,emptyMessage:a("autoFlags.noData"),page:j,totalPages:$,totalItems:U.length,limit:L,setPage:_,sortBy:R,sortOrder:M,onSort:(p,l)=>{D(p),T(l)}})})})]}),e.jsx(xe,{isOpen:P,onClose:()=>w(!1),editingFlag:F,flagForm:N,setFlagForm:S,onSave:V})]})}export{Ge 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.