1import{aj as s,r as o,p as e,L as A,T as K,B as l,af as O,x as B,N as d,v as W,ba as z,bF as G,ag as y,S as j,z as J,y as F}from"./index-C9IH3k-2.js";import{g as x,N as g,W as n,T as h,J as Q}from"./TemplateUtil-D1DzmWLm.js";import{P as X}from"./PageDescription-BrOUsEZE.js";import{F as Z}from"./Table-isZ0WXp4.js";import"./Wrapper-ChjuDa3w.js";import"./HelperMethods-C-ewwU_x.js";import"./index-BOwvFOZJ.js";import"./Pagination-D1z-xPUv.js";import"./HolderOutlined-YOHjCGKZ.js";const{Text:_,Title:ee}=K,{Option:I}=j,te=[{value:"TRADE_INDIA_INQUIRY",label:"Trade India Inquiry"},{value:"TRADE_INDIA_BUY_LEADS",label:"Trade India Buy Leads"}],ue=()=>{const[r]=s.useForm(),[E,N]=o.useState([]),[M,u]=o.useState(!1),[i,C]=o.useState(null),[U,T]=o.useState(!1),[q,b]=o.useState(!1),[R,v]=o.useState(!1),[k,w]=o.useState(null),f=async()=>{try{u(!0);const t=await B("/api/v1/integration/configs");t&&t.status===200&&N(t.data||[])}catch{d.error("Failed to fetch configurations. Please try again.")}finally{u(!1)}};o.useEffect(()=>{f()},[]);const L=t=>{C(t),T(!0)},m=t=>{w(t),r.setFieldsValue({name:t.name,integrationType:t.integrationType,userid:t.data?.userid,profile_id:t.data?.profile_id,key:t.data?.key,active:t.active}),v(!0)},Y=t=>{g.confirm({title:"Delete Configuration",content:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Are you sure you want to delete ",e.jsx("b",{children:t.name}),"? This action cannot be undone."]}),e.jsx("b",{children:"Warning:"})," If this configuration is currently used in any automation, deleting it will break the functionality."]}),okText:"Yes, Delete",okType:"danger",cancelText:"Cancel",onOk:async()=>{try{u(!0);const a=await J(`/api/v1/integration/config/${t.id}`);a&&a.status===200?(d.success(`Configuration "${t.name}" deleted successfully!`),f()):d.error("Failed to delete configuration. Please try again.")}catch{d.error("Failed to delete configuration. Please try again.")}finally{u(!1)}}})},p=()=>{T(!1),C(null)},$=()=>{r.resetFields(),r.setFieldsValue({active:!0}),b(!0)},D=()=>{b(!1),r.resetFields()},P=()=>{v(!1),w(null),r.resetFields()},H=async t=>{try{const a={name:t.name,integrationType:t.integrationType,active:t.active,data:{userid:t.userid,profile_id:t.profile_id,key:t.key}};if(k){a.id=k.id;const c=await F("/api/v1/integration/config",a);c&&c.status===200&&(d.success("Configuration updated successfully!"),P(),f())}else{const c=await F("/api/v1/integration/config",a);c&&c.status===200&&(d.success("Configuration created successfully!"),D(),f())}}catch{d.error("Failed to save configuration. Please try again.")}},V=[{title:"Name",dataIndex:"name",key:"name",render:(t,a)=>e.jsx(l,{type:"link",onClick:()=>m(a),children:a?.name})},{title:"Integration Type",dataIndex:"integrationType",key:"integrationType",render:t=>e.jsx(h,{color:"blue",children:t})},{title:"User ID",dataIndex:["data","userid"],key:"userid"},{title:"Profile ID",dataIndex:["data","profile_id"],key:"profile_id"},{title:"Status",dataIndex:"active",key:"active",render:t=>e.jsx(h,{color:t?"green":"red",children:t?"Active":"Inactive"})},{title:"Created",dataIndex:"creationTime",key:"creationTime",render:t=>x(t)},{title:"Actions",key:"actions",render:(t,a)=>e.jsxs(W,{children:[e.jsx(l,{type:"text",icon:e.jsx(z,{}),onClick:()=>L(a),title:"View Details"}),e.jsx(l,{type:"text",icon:e.jsx(G,{}),onClick:()=>m(a),title:"Edit Configuration"}),e.jsx(l,{type:"text",danger:!0,icon:e.jsx(Q,{}),onClick:()=>Y(a),title:"Delete Configuration"})]})}],S=()=>e.jsxs(s,{form:r,layout:"vertical",onFinish:H,autoComplete:"off",children:[e.jsx(s.Item,{name:"name",label:"Configuration Name",rules:[{required:!0,message:"Please enter configuration name"}],children:e.jsx(y,{placeholder:"My Trade India Integration"})}),e.jsx(s.Item,{name:"integrationType",label:"Integration Type",rules:[{required:!0,message:"Please select integration type"}],children:e.jsx(j,{placeholder:"Select integration type",children:te.map(t=>e.jsx(I,{value:t.value,children:t.label},t.value))})}),e.jsx(s.Item,{name:"userid",label:"User ID",rules:[{required:!0,message:"Please enter your Trade India User ID"}],children:e.jsx(y,{placeholder:"49997567"})}),e.jsx(s.Item,{name:"profile_id",label:"Profile ID",rules:[{required:!0,message:"Please enter your Trade India Profile ID"}],children:e.jsx(y,{placeholder:"3386567"})}),e.jsx(s.Item,{name:"key",label:"API Key",rules:[{required:!0,message:"Please enter your Trade India API Key"}],children:e.jsx(y.Password,{placeholder:"bec3b424f3e91c191ff437c6f7be3f5d"})}),e.jsx(s.Item,{name:"active",label:"Status",rules:[{required:!0,message:"Please select status"}],children:e.jsxs(j,{children:[e.jsx(I,{value:!0,children:"Active"}),e.jsx(I,{value:!1,children:"Inactive"})]})})]});return e.jsxs(A,{vertical:!0,gap:24,children:[e.jsxs(A,{justify:"space-between",align:"center",children:[e.jsx(ee,{level:3,style:{margin:0},children:"Trade India Integration"}),e.jsx(l,{type:"primary",icon:e.jsx(O,{}),onClick:$,children:"Create New Configuration"})]}),e.jsx(X,{description:"Connect your Trade India account to sync leads and inquiries",children:e.jsx(_,{children:"Configure your Trade India integration to automatically sync leads, inquiries, and buy leads with your WhatsApp workspace. You'll need your Trade India User ID, Profile ID, and API Key from your Trade India dashboard."})}),e.jsx(Z,{columns:V,dataSource:E,loading:M,rowKey:"id",locale:{emptyText:"No configurations foun
1d. Create your first Trade India integration."}}),e.jsx(g,{title:"Create Trade India Configuration",open:q,onOk:()=>r.submit(),onCancel:D,width:600,okText:"Create Configuration",style:{maxHeight:"80vh"},styles:{body:{maxHeight:"60vh",overflowY:"auto"}},children:S()}),e.jsx(g,{title:"Edit Trade India Configuration",open:R,onOk:()=>r.submit(),onCancel:P,width:600,okText:"Update Configuration",style:{maxHeight:"80vh"},styles:{body:{maxHeight:"60vh",overflow:"auto"}},children:S()}),e.jsx(g,{title:"Configuration Details",open:U,onCancel:p,footer:[e.jsx(l,{onClick:p,children:"Close"},"close"),e.jsx(l,{type:"primary",onClick:()=>{p(),m(i)},children:"Edit Configuration"},"edit")],width:600,style:{maxHeight:"80vh"},styles:{body:{maxHeight:"60vh",overflowY:"auto"}},children:i&&e.jsxs(n,{column:1,bordered:!0,children:[e.jsx(n.Item,{label:"Name",children:i.name}),e.jsx(n.Item,{label:"Integration Type",children:e.jsx(h,{color:"blue",children:i.integrationType})}),e.jsx(n.Item,{label:"User ID",children:i.data?.userid}),e.jsx(n.Item,{label:"Profile ID",children:i.data?.profile_id}),e.jsx(n.Item,{label:"API Key",children:e.jsx(_,{code:!0,children:i.data?.key?`${i.data.key.substring(0,8)}...${i.data.key.substring(i.data.key.length-8)}`:"Not set"})}),e.jsx(n.Item,{label:"Status",children:e.jsx(h,{color:i.active?"green":"red",children:i.active?"Active":"Inactive"})}),e.jsx(n.Item,{label:"Created",children:x(i.creationTime)}),e.jsx(n.Item,{label:"Last Updated",children:x(i.lastUpdateTime)})]})})]})};export{ue 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.