1import{J as Q,r as s,y as X,bj as n,p as a,L as m,T as o,v as A,S as D,B as I,bE as P,x as z,z as E}from"./index-C9IH3k-2.js";import{I as Z,g as p}from"./TemplateUtil-D1DzmWLm.js";import{u as ee,D as te}from"./HelperMethods-C-ewwU_x.js";import{P as ae}from"./PageDescription-BrOUsEZE.js";import{O as L}from"./OutSendMessagePreview-VUmnjP6y.js";import{G as g}from"./GetTableLocalColumnSearchProps-xZFQtvK6.js";import{F as _}from"./Table-isZ0WXp4.js";import{P as F}from"./index-C0dhduHx.js";import"./Wrapper-ChjuDa3w.js";import"./tiny-invariant-CopsF_GD.js";import"./MenuOutlined-DhPBrr1e.js";import"./useTemplateDetails-DA6kn5sZ.js";import"./AuditConstant-C6syQHOu.js";import"./index-CmSVNJzc.js";import"./index-Bv3SRNsl.js";import"./CalendarOutlined-DyzsKNdO.js";import"./ClockCircleOutlined-Cym7vptW.js";import"./index-BOwvFOZJ.js";import"./Pagination-D1z-xPUv.js";import"./HolderOutlined-YOHjCGKZ.js";const ve=()=>{const{token:b}=Q.useToken(),[O,x]=s.useState([]),[l,R]=s.useState(null),[M,c]=s.useState([]),[B,d]=s.useState([]),[S,f]=s.useState(!1),[$,T]=s.useState(!1),[G,j]=s.useState(!1),[v,J]=s.useState(""),u=s.useRef(null),w=ee(),h=(e,t,r)=>{t()},C=s.useCallback(async()=>{f(!0);try{const t=await X("/api/v1/chatbot/list",{name:v},!1);t&&t.data?x(t.data):x([])}catch(e){n.error({title:"Error",description:e?.response?.data?.detail||"Failed to fetch chatbots list"}),x([])}finally{f(!1)}},[v]),N=async e=>{T(!0);try{const t=await z(`/api/v1/chatbot/${e}/schedule/list`,!1);if(t&&t.data){const r=t.data.map((i,y)=>({...i,key:i.scheduleId||y}));c(r)}else c([])}catch(t){n.error({title:"Error",description:t?.response?.data?.detail||"Failed to fetch schedule list"}),c([])}finally{T(!1)}},k=async e=>{j(!0);try{const t=await z(`/api/v1/chatbot/${e}/schedule/clearContactAttribute/list`,!1);if(t&&t.data){const r=t.data.map((i,y)=>({...i,key:i.scheduleId||y}));d(r)}else d([])}catch(t){n.error({title:"Error",description:t?.response?.data?.detail||"Failed to fetch schedule attribute list"}),d([])}finally{j(!1)}},K=async(e,t)=>{try{await E(`/api/v1/chatbot/${e}/schedule/${t}`),n.success({title:"Success",description:"Schedule deleted successfully. Cron job has been removed and no further messages will be processed."}),N(e)}catch{}},U=async(e,t)=>{try{await E(`/api/v1/chatbot/${e}/schedule/clearContactAttribute/${t}`),n.success({title:"Success",description:"Schedule deleted successfully. Cron job has been removed and no further attribute clearances will be processed."}),k(e)}catch{}},Y=e=>{try{const t=JSON.parse(e.messages);if(e.drip==="true"||t&&!Array.isArray(t)&&t.templateName){const r={type:"template",template:{name:t.templateName,language:{code:t.language}}};return a.jsx(m,{wrap:!0,gap:"large",children:a.jsx(L,{data:{message:r},mediaUse:"OUT"})})}return a.jsx(m,{wrap:!0,gap:"large",children:t?.map((r,i)=>a.jsx("span",{children:a.jsx(L,{data:{message:r},mediaUse:"PRE_COMPOSED_MESSAGE"})},i))})}catch{return a.jsxs("div",{style:{padding:"16px",backgroundColor:b.colorBgLayout},children:[a.jsx(o.Text,{type:"danger",children:"Error parsing message content"}),a.jsx("pre",{style:{marginTop:"8px",fontSize:"12px",color:b.colorTextSecondary},children:e.messages})]})}},W=[{title:"Node Name",dataIndex:"nodeName",key:"nodeName",...g("nodeName","Node Name",u,h)},{title:"Receiver Number",dataIndex:"receiver_number",key:"receiver_number",...g("receiver_number","Receiver Number",u,h)},{title:"Scheduled Time",dataIndex:"exactDateTime",key:"exactDateTime",render:e=>p(e)},{title:"Creation Time",dataIndex:"creationTime",key:"creationTime",sorter:(e,t)=>e.creationTime-t.creationTime,render:e=>p(e)},{title:"Action",key:"action",width:100,render:(e,t)=>a.jsx(F,{title:"Delete Schedule",description:"Are you sure you want to delete this schedule?",okText:"Yes, Delete",okType:"danger",cancelText:"Cancel",onConfirm:()=>K(l,t.scheduleId),children:a.jsx(I,{type:"primary",danger:!0,size:"small",icon:a.jsx(P,{}),children:"Delete"})})}],H=[{title:"Node Name",dataIndex:"nodeName",key:"nodeName",...g("nodeName","Node Name",u,h)},{title:"Receiver Number",dataIndex:"receiver_number",key:"receiver_number",...g("receiver_number","Receiver Number",u,h)},{title:"Attributes",dataIndex:"clearContactAttributes",key:"clearContactAttributes",render:e=>{try{return JSON.parse(e).join(", ")}catch{return e||"N/A"}}}
1,{title:"Scheduled Time",dataIndex:"exactDateTime",key:"exactDateTime",render:e=>p(e)},{title:"Creation Time",dataIndex:"creationTime",key:"creationTime",sorter:(e,t)=>e.creationTime-t.creationTime,render:e=>p(e)},{title:"Action",key:"action",width:100,render:(e,t)=>a.jsx(F,{title:"Delete Schedule",description:"Are you sure you want to delete this schedule?",okText:"Yes, Delete",okType:"danger",cancelText:"Cancel",onConfirm:()=>U(l,t.scheduleId),okButtonProps:{disabled:!w("manage_messages")},children:a.jsx(I,{type:"primary",danger:!0,size:"small",icon:a.jsx(P,{}),disabled:!w("manage_messages"),children:"Delete"})})}];s.useEffect(()=>{C()},[C]);const V=te(e=>{J(e)},300),q=e=>{R(e),e?(N(e),k(e)):(c([]),d([]))};return a.jsxs(m,{vertical:!0,gap:"large",children:[a.jsx(m,{justify:"space-between",wrap:!0,children:a.jsx(o.Title,{level:4,style:{margin:0},children:"Schedule Chatbots Message"})}),a.jsx(ae,{description:"How Schedule chatbot messages works?",children:"View and manage scheduled messages for your chatbots. Select a chatbot from the dropdown to see all its scheduled messages with details like node name, receiver number, and scheduled time. You can delete any scheduled message to stop it from being sent in the future."}),a.jsx(Z,{size:"small",variant:"borderless",children:a.jsxs(A,{orientation:"vertical",style:{width:"100%"},size:"large",children:[a.jsxs("div",{children:[a.jsx(o.Text,{strong:!0,children:"Select Chatbot:"}),a.jsx(D,{style:{width:"100%",marginTop:8},showSearch:!0,placeholder:"Search and select a chatbot",optionFilterProp:"children",loading:S,onSearch:V,onChange:q,value:l,filterOption:!1,notFoundContent:S?"Searching...":"No chatbots found",children:O.map(e=>a.jsx(D.Option,{value:e.id,children:e.name},e.id))})]}),l?a.jsxs(A,{orientation:"vertical",style:{width:"100%"},size:"small",children:[a.jsxs("div",{children:[a.jsx(o.Title,{level:5,style:{margin:0,marginBottom:16},children:"Scheduled Messages"}),a.jsx(_,{columns:W,dataSource:M,loading:$,scroll:{x:"max-content",y:500},pagination:{defaultPageSize:10,showSizeChanger:!0,pageSizeOptions:["10","20","50","100"]},expandable:{expandedRowRender:Y,rowExpandable:e=>e.messages&&e.messages.length>0},locale:{emptyText:"No scheduled messages found for this chatbot"}})]}),a.jsxs("div",{children:[a.jsx(o.Title,{level:5,style:{margin:0,marginBottom:16},children:"Scheduled Attribute Clearance"}),a.jsx(_,{columns:H,dataSource:B,loading:G,scroll:{x:"max-content",y:500},pagination:{defaultPageSize:10,showSizeChanger:!0,pageSizeOptions:["10","20","50","100"]},locale:{emptyText:"No scheduled attribute clearances found for this chatbot"}})]})]}):a.jsx("div",{style:{textAlign:"center",padding:"40px 0"},children:a.jsx(o.Text,{type:"secondary",style:{fontSize:"16px"},children:"Please select a chatbot to see schedule messages"})})]})})]})};export{ve 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.