1import{aj as n,J as M,r,x as P,N as a,p as e,L as m,ak as R,T,a0 as z,a1 as w,ag as h,v as u,B as g,af as E,y as q}from"./index-C9IH3k-2.js";import{a2 as d,T as B,J as N,I as J}from"./TemplateUtil-D1DzmWLm.js";import{S as K}from"./index-8jSYgZzf.js";import{R as V}from"./SaveOutlined-gwhZZcip.js";import"./Wrapper-ChjuDa3w.js";import"./HelperMethods-C-ewwU_x.js";const{Text:o}=T,{TextArea:$}=h,X=()=>{const[l]=n.useForm(),{token:S}=M.useToken(),[k,x]=r.useState(!1),[D,j]=r.useState(!1),[c,f]=r.useState(""),[t,p]=r.useState([]);r.useEffect(()=>{I()},[]);const I=async()=>{x(!0);try{const s=await P("/api/v1/admin/support");if(s?.data){const{message:i,meetLink:v,allowedDomains:A,active:b}=s.data;l.setFieldsValue({message:i,meetLink:v,active:b}),p(A||[])}}catch(s){console.error("Failed to fetch support settings:",s),a.error("Failed to load support settings")}finally{x(!1)}},C=async()=>{try{const s=await l.validateFields();if(t.length===0){a.warning("Please add at least one allowed domain");return}j(!0);const i={message:s.message,meetLink:s.meetLink,allowedDomains:t,active:s.active};(await q("/api/v1/admin/support",i))?.data&&a.success("Support settings saved successfully")}catch(s){console.error("Failed to save support settings:",s),s.errorFields?a.error("Please fill in all required fields"):a.error("Failed to save support settings")}finally{j(!1)}},y=()=>{if(!c.trim()){a.warning("Please enter a domain");return}if(t.includes(c.trim())){a.warning("This domain is already added");return}p([...t,c.trim()]),f("")},F=s=>{p(t.filter(i=>i!==s))},L=s=>{s.key==="Enter"&&(s.preventDefault(),y())};return k?e.jsx(m,{justify:"center",align:"center",style:{minHeight:"400px"},children:e.jsx(R,{size:"large",description:"Loading support settings..."})}):e.jsxs("div",{style:{padding:"20px",background:S.colorBgContainer},children:[e.jsx(o,{children:"Configure support message, meeting link, and allowed domains for your support system."}),e.jsx(d,{}),e.jsxs(n,{form:l,layout:"vertical",initialValues:{active:!0},children:[e.jsxs(z,{gutter:24,children:[e.jsxs(w,{xs:24,lg:16,children:[e.jsx(n.Item,{label:"Support Message",name:"message",rules:[{required:!0,message:"Please enter a support message"}],children:e.jsx($,{rows:4,placeholder:"e.g., Support time: 4 PM to 7 PM",showCount:!0})}),e.jsx(n.Item,{label:"Meeting Link",name:"meetLink",rules:[{required:!0,message:"Please enter a meeting link"}],children:e.jsx(h,{placeholder:"https://meet.google.com/abc-defg-hij"})}),e.jsx(n.Item,{label:"Allowed Domains",children:e.jsxs(u,{orientation:"vertical",style:{width:"100%"},size:"middle",children:[e.jsxs(m,{gap:"small",children:[e.jsx(h,{placeholder:"e.g., example.com",value:c,onChange:s=>f(s.target.value),onKeyDown:L,style:{flex:1}}),e.jsx(g,{type:"primary",icon:e.jsx(E,{}),onClick:y,children:"Add Domain"})]}),t.length>0?e.jsx(u,{size:[8,8],wrap:!0,children:t.map(s=>e.jsx(B,{closable:!0,onClose:()=>F(s),closeIcon:e.jsx(N,{}),color:"blue",children:s},s))}):e.jsx(o,{type:"secondary",children:"No domains added yet"})]})}),e.jsx(n.Item,{label:"Active Status",name:"active",valuePropName:"checked",children:e.jsx(K,{checkedChildren:"Active",unCheckedChildren:"Inactive"})})]}),e.jsx(w,{xs:24,lg:8,children:e.jsx(J,{type:"inner",title:"Information",size:"small",children:e.jsxs(u,{orientation:"vertical",size:"small",children:[e.jsxs(o,{children:[e.jsx("strong",{children:"Support Message:"})," Display this message to users when they access support."]}),e.jsx(d,{style:{margin:"8px 0"}}),e.jsxs(o,{children:[e.jsx("strong",{children:"Meeting Link:"})," Direct link for users to join support meetings."]}),e.jsx(d,{style:{margin:"8px 0"}}),e.jsxs(o,{children:[e.jsx("strong",{children:"Allowed Domains:"})," Only users from these domains can access support features."]})]})})})]}),e.jsx(d,{}),e.jsxs(m,{justify:"flex-end",gap:"small",children:[e.jsx(g,{onClick:()=>l.resetFields(),children:"Reset"}),e.jsx(g,{type:"primary",icon:e.jsx(V,{}),onClick:()=>C(),loading:D,children:"Save Settings"})]})]})]})};export{X 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.