1import{J as V,aj as a,r,p as e,L as j,T as k,v as S,B as l,af as _,S as R,x as F,N as n,bF as K,y as U,z as Y}from"./index-C9IH3k-2.js";import{c as G}from"./cronstrue-BcT_JlZH.js";import{C as H}from"./index-DumxKeW3.js";import{g as Q,N as W,T as g,J as X}from"./TemplateUtil-D1DzmWLm.js";import{N as T}from"./NextRunsModal-Bn9oyH7m.js";import{e as v}from"./HelperMethods-C-ewwU_x.js";import{P as Z}from"./PageDescription-BrOUsEZE.js";import{R as ee}from"./ReloadOutlined-0KdG7zYw.js";import{F as te}from"./Table-isZ0WXp4.js";import{P as se}from"./index-C0dhduHx.js";import"./Wrapper-ChjuDa3w.js";import"./ClockCircleOutlined-Cym7vptW.js";import"./index-DNqpjC0Z.js";import"./Pagination-D1z-xPUv.js";import"./index-BOwvFOZJ.js";import"./HolderOutlined-YOHjCGKZ.js";const{Title:re}=k,{Option:ne}=R,Te=()=>{const{token:m}=V.useToken(),[i]=a.useForm(),[P,z]=r.useState([]),[y,A]=r.useState([]),[C,E]=r.useState(!1),[B,I]=r.useState(!1),[M,f]=r.useState(!1),[N,d]=r.useState(!1),[u,p]=r.useState(null),[b,h]=r.useState(""),D=async()=>{I(!0);try{const t=await F("/api/v1/integration/types");t&&t.status===200&&A(t.data||[])}catch{n.error("Failed to fetch integration types")}I(!1)},x=async()=>{E(!0);try{const t=await F("/api/v1/admin/schedule/integrations");t&&t.status===200&&z(t.data||[])}catch{n.error("Failed to fetch integration schedules")}E(!1)},L=async t=>{f(!0);try{const s=await i?.validateFields().catch(()=>({}));if(!s?.cronExpression){n.error("Please enter a valid cron expression"),f(!1);return}const o={integrationType:s.integrationType,schedule:{cronExpression:s.cronExpression}},c=await U("/api/v1/admin/schedule/integration",o);c&&c.status===200?(n.success(u?"Schedule updated successfully":"Schedule created successfully"),d(!1),i.resetFields(),p(null),x()):n.error("Failed to save schedule")}catch{n.error("Error saving schedule")}f(!1)},$=async t=>{try{const s=await Y(`/api/v1/admin/schedule/integration/${t}`);s&&s.status===200?(n.success("Schedule deleted successfully"),x()):n.error("Failed to delete schedule")}catch{n.error("Error deleting schedule")}},O=t=>{p(t),i.setFieldsValue({integrationType:t.integrationType,cronExpression:t.cronExpression||""}),h(t.cronExpression||""),d(!0)},q=()=>{p(null),i.resetFields(),h(""),d(!0)},w=()=>{d(!1),p(null),i.resetFields(),h("")},J=[{title:"Integration Type",dataIndex:"integrationType",key:"integrationType",render:t=>{const s=v(t);return e.jsx(g,{color:"blue",children:s})}},{title:"Schedule",key:"schedule",render:(t,s)=>{const o=s.cronExpression;if(o)try{const c=G.toString(o);return e.jsxs("div",{children:[e.jsx(g,{color:"blue",children:"Recurring"}),e.jsx(T,{cronExpression:o}),e.jsx("div",{style:{marginTop:4,fontSize:12,color:m.colorTextSecondary},children:c})]})}catch{return e.jsxs("div",{children:[e.jsx(g,{color:"blue",children:"Recurring"}),e.jsx(T,{cronExpression:o}),e.jsx("div",{style:{marginTop:2,fontSize:11,color:m.colorTextTertiary,fontFamily:"monospace"},children:o})]})}return e.jsx(g,{color:"default",children:"Not Scheduled"})}},{title:"id",dataIndex:"id",key:"id"},{title:"Created",dataIndex:"creationTime",key:"creationTime",render:t=>t?Q(t):"-"},{title:"Actions",key:"actions",render:(t,s)=>e.jsxs(S,{children:[e.jsx(l,{type:"text",icon:e.jsx(K,{}),onClick:()=>O(s),size:"small",children:"Edit"}),e.jsx(se,{title:"Delete Schedule",description:"Are you sure you want to delete this integration schedule?",onConfirm:()=>$(s.integrationType),okText:"Yes",cancelText:"No",children:e.jsx(l,{type:"text",danger:!0,icon:e.jsx(X,{}),size:"small",children:"Delete"})})]})}];return r.useEffect(()=>{x(),D()},[]),e.jsxs(j,{vertical:!0,gap:24,style:{width:"100%"},children:[e.jsxs(j,{justify:"space-between",wrap:!0,children:[e.jsx(re,{level:3,style:{margin:0},children:"Integration Schedules"}),e.jsxs(S,{children:[e.jsx(l,{icon:e.jsx(ee,{}),onClick:x,loading:C,children:"Refresh"}),e.jsx(l,{type:"primary",icon:e.jsx(_,{}),onClick:q,children:"Create Schedule"})]})]}),e.jsx(Z,{description:"Integration Schedule Management",children:e.jsxs(k.Paragraph,{style:{marginBottom:4},children:["Configure automated scheduling for different integration types. Set delays and intervals for when integrations should sync or process data.",e.jsx("br",{}),e.jsx("br",{}),e.jsx("strong",{children:"Supported Integration Types:"}),e.jsx("br",{}),y.map((t,s)=>e.jsxs("span",{children:["⢠",e.jsx("strong",{children:v(t)}),s<y.length-1&&e.jsx("br",{})]},t))]})}),e.jsx(te,{columns:J,dataSource:P,loading:C,rowKey:"integrationType",pagination:{pageSize:10,showSizeChanger:!0,showTotal:t=>`Total ${t} schedules`}}),e.jsx(W,{title:u?"Edit Integration Schedule":"Create Integration Schedule",open:N,onCancel:w,footer:null,width:600,children:e.jsxs(a,{form:i,layout:"vertical",onFinish:L,style:{marginTop:24},children:[e.jsx(a.Item,{name:"integrationType",label:"Integration Type",rules:[{required:!0,message:"Please select an integration type"}],children:e.jsx(R,{placeholder:"Select integration type",disabled:u,loading:B,children:y.map(t=>e.jsx(ne,{value:t,children:v(t)},t))})}),e.jsxs(a.Item,{label:"Schedule Configuration",style:{marginBottom:16},children:[e.jsx("div",{style:{marginBottom:8,color:m.colorTextSecondary},children:"Set the recurring schedule for when the integration should be processed"}),e.jsxs("div",{style:{marginLeft:"20px",marginTop:"12px"},children:[e.jsx(a.Item,{name:"cronExpression",rules:[{required:!0,message:"Please enter a valid cron expression"}],children:e.jsx(H,{showResultText:!0,showResultCron:!1,onChange:t=>h(t)})}),b&&e.jsx(S,{children:e.jsx(T,{cronExpression:b})})]})]}),e.jsx(a.Item,{style:{marginBottom:0},children:e.jsxs(j,{justify:"end",gap:8,children:[e.jsx(l,{onClick:w,children:"Cancel"}),e.jsxs(l,{type:"primary",htmlType:"submit",loading:M,children:[u?"Update":"Create"," Schedule"]})]})})]})})]})};export{Te 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.