1import{J as Y,ac as J,C as Q,r as o,x as h,p as e,L as $,T as i,a0 as v,a1 as l,v as c,B as p,N as b,a_ as j,w as W,b9 as V,bj as f,bk as H,y as K}from"./index-C9IH3k-2.js";import{I as u,g as O,$ as X,h as E,U as Z,aD as ee,Y as se}from"./TemplateUtil-D1DzmWLm.js";import{E as te}from"./ErrorModal-CCK02OhG.js";import{P as ae}from"./PageDescription-BrOUsEZE.js";import{R as ie}from"./CalendarOutlined-DyzsKNdO.js";import{R as re}from"./ReloadOutlined-0KdG7zYw.js";import{F as oe}from"./Table-isZ0WXp4.js";import{R as k}from"./TeamOutlined-BZ7WVDnA.js";import{S as P}from"./index-BNG9Amsm.js";import{R as ne}from"./ClockCircleOutlined-Cym7vptW.js";import{R as le}from"./SyncOutlined-D8Vo-rc6.js";import{F as ce}from"./MainApp-BoiAvjMg.js";import{P as de}from"./index-C0dhduHx.js";import{R as pe}from"./UserDeleteOutlined-BDyroRhc.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{Title:ue}=i,Le=()=>{const{token:w}=Y.useToken(),x=J(),D=Q(),L=x.state&&(x.state.groupId||x.state.group&&x.state.group.id)||null,[r]=o.useState(L),[a,S]=o.useState(null),[_,R]=o.useState(!1),[y,g]=o.useState(!1),[B,T]=o.useState(!1),[z,I]=o.useState({}),[C,d]=o.useState({});o.useEffect(()=>{if(!r){D("/Groups");return}m()},[r]);const m=async()=>{try{const s=await h(`/api/v1/whatsapp/group/${r}`);s&&s.data?S(s.data):S(null)}catch(s){console.error(s)}},M=async()=>{try{g(!0),await h(`/api/v1/whatsapp/group/${r}/sync`,!1),f.success({title:"Success",description:"Whatsapp group synced successfully"}),m()}catch(s){console.error(s);const t=s?.response?.data||{message:s?.message||String(s)};d(t)}finally{g(!1)}},A=async()=>{try{g(!0);const s=await h(`/api/v1/whatsapp/group/${r}/inviteLink/reset`,!1);s&&s.data&&(f.success({title:"Success",description:`New invite link: ${s.data.invite_link}`}),m())}catch(s){console.error(s);const t=s?.response?.data||{message:s?.message||String(s)};d(t)}finally{g(!1)}},G=async()=>{try{R(!0);const s=await h(`/api/v1/whatsapp/group/${r}/joinRequests`);if(s&&s.data)return s.data}catch(s){console.error(s);const t=s?.response?.data||{message:s?.message||String(s)};d(t)}finally{R(!1)}return null},N=async s=>{try{T(!0);const t=new FormData;t.append("uploadFile",s),await H(`/api/v1/whatsapp/group/${r}/profilePicture`,t,!1)&&(f.success({title:"Uploaded",description:"Profile picture uploaded"}),m())}catch(t){console.error(t);const n=t?.response?.data||{message:t?.message||String(t)};d(n)}finally{T(!1)}},U=async s=>{try{const t=s[0]&&s[0].user;I(q=>({...q,[t]:!0})),await K(`/api/v1/whatsapp/group/${r}/participants/delete`,{participants:s},!1)&&(f.success({title:"Success",description:"Participants deletion requested"}),m())}catch(t){console.error(t);const n=t?.response?.data||{message:t?.message||String(t)};d(n)}finally{const t=s[0]&&s[0].user;I(n=>({...n,[t]:!1}))}},F=[{title:"Member",dataIndex:"wa_id",key:"wa_id",render:s=>e.jsx(c,{children:e.jsx(i.Text,{children:s})})},{title:"Actions",key:"actions",align:"right",width:120,render:(s,t)=>e.jsx(de,{title:"Remove this member?",description:`Are you sure you want to remove ${t.wa_id} from this group?`,onConfirm:()=>U([{user:t.wa_id}]),okText:"Yes, remove",cancelText:"Cancel",icon:e.jsx(se,{style:{color:"#ff4d4f"}}),children:e.jsx(p,{danger:!0,size:"small",icon:e.jsx(pe,{}),loading:z[t.wa_id],children:"Remove"})})}];return e.jsxs($,{vertical:!0,gap:"large",children:[e.jsx($,{justify:"space-between",align:"center",children:e.jsx(ue,{level:4,style:{margin:0},children:a?.subject||"Group Details"})}),e.jsx(ae,{description:"Manage group settings, members, and invite links",children:"This section allows you to view and manage the details of your WhatsApp group. You can see group information such as the name, description, creation date, and status. Manage members by viewing the participant list and removing members if necessary. You can also generate and reset invite links to share with others, upload a group profile picture, and sync group data to ensure all information is up to date."}),e.jsx(te,{errorData:C,onClose:()=>d({})}),a?e.jsxs(v,{gutter:[24,24],children:[e.jsxs(l,{xs:24,lg:16,children:[e.jsx(u,{title:e.jsxs(c,{children:[e.jsx(X,{}),e.jsx("span",{children:"Group Information"})]}),variant:"borderless",style:{marginBottom:24,borderRadius:8},children:e.jsxs(v,{gutter:[24,24],children:[e.jsx(l,{xs:24,sm:12,children:e.jsxs("div",{style:{marginBottom:16},children:[e.jsx(i.Text,{type:"secondary",style:{fontSize:"12px",display:"block",marginBottom:4},children:"Group Name"}),e.jsx(i.Text,{strong:!0,style:{fontSize:"16px"},children:a.subject||"-"})]})}),e.jsx(l,{xs:24,sm:12,children:e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs(i.Text,{type:"secondary",style:{fontSize:"12px",display:"block",marginBottom:4},children:[e.jsx(ie,{})," Created"]}),e.jsx(i.Text,{strong:!0,style:{fontSize:"16px"},children:a.creationTime?O(a.creationTime):"-"})]})}),e.jsx(l,{xs:24,children:e.jsxs("div",{children:[e.jsx(i.Text,{type:"secondary",style:{fontSize:"12px",display:"block",marginBottom:4},children:"Description"}),e.jsx(i.Paragraph,{style:{marginBottom:0},children:a.description||e.jsx(i.Text,{type:"secondary",italic:!0,children:"No description provided"})})]})})]})}),e.jsx(u,{title:e.jsxs(c,{children:[e.jsx(E,{}),e.jsx("span",{children:"Invite Link"})]}),variant:"borderless",style:{marginBottom:24,borderRadius:8},extra:e.jsx(W,{title:"Reset and generate a new invite link",children:e.jsx(p,{danger:!0,size:"small",icon:e.jsx(re,{}),onClick:A,loading:y,children:"Reset Link"})}),children:a.invite_link?e.jsx("div",{style:{background:w.colorBgLayout,padding:"16px",borderRadius:8,border:`1px solid ${w.colorBorder}`},children:e.jsxs(c,{orientation:"vertical",style:{width:"100%"},size:"middle",children:[e.jsx(i.Text,{style:{wordBreak:"break-all"},children:a.invite_link}),e.jsx(p,{type:"primary",icon:e.jsx(E,{}),onClick:()=>{navigator.clipboard.writeText(a.invite_link),b.success("Invite link copied to clipboard!")},children:"Copy Invite Link"})]})}):e.jsx(j,{description:"No invite link available",image:j.PRESENTED_IMAGE_SIMPLE})}),e.jsx(u,{title:e.jsxs(c,{children:[e.jsx(k,{}),e.jsxs("span",{children:["Members (",a.participants?.length||0,")"]})]}),variant:"borderless",children:Array.isArray(a.participants)&&a.participants.length>0?e.jsx(oe,{columns:F,dataSource:a.participants.map(s=>({...s,key:s.wa_id})),pagination:{pageSize:10,showSizeChanger:!0,showTotal:s=>`Total ${s} members`},size:"middle"}):e.jsx(j,{description:"No members in this group yet",image:j.PRESENTED_IMAGE_SIMPLE,style:{padding:"40px 0"}})})]}),e.jsxs(l,{xs:24,lg:8,children:[e.jsx(u,{variant:"borderless",style:{marginBottom:24,borderRadius:8},children:e.jsxs(v,{gutter:[16,16],children:[e.jsx(l,{span:24,children:e.jsx(P,{title:"Total Members",value:a.participants?.length||0,prefix:e.jsx(k,{})})}),e.jsx(l,{span:24,children:e.jsx(P,{title:"Status",value:a.active?"Active":"Inactive",prefix:a.active?e.jsx(V,{}):e.jsx(ne,{})})})]})}),e.jsx(u,{title:"Quick Actions",variant:"borderless",style:{marginBottom:24,borderRadius:8},children:e.jsxs(c,{orientation:"vertical",style:{width:"100%"},size:"middle",children:[e.jsx(p,{type:"primary",icon:e.jsx(le,{spin:y}),onClick:M,loading:y,block:!0,children:"Sync Group Data"}),e.jsx(p,{icon:e.jsx(k,{}),onClick:async()=>{const s=await G();s&&s.length>0?b.info(`${s.length} join request(s) found`):b.info("No pending join requests")},block:!0,loading:_,children:"View Join Requests"}),e.jsx(Z,{beforeUpload:s=>(N(s),!1),showUploadList:!1,accept:"image/*",children:e.jsx(p,{icon:e.jsx(ce,{}),loading:B,block:!0,children:"Upload Group Picture"})})]})}),e.jsx(u,{variant:"borderless",style:{borderRadius:8},children:e.jsxs(c,{orientation:"vertical",size:"small",children:[e.jsx(i.Text,{strong:!0,children:"Qu
1ick Tips"}),e.jsx(i.Text,{children:"⢠Sync regularly to keep member data updated"}),e.jsx(i.Text,{children:"⢠Reset invite link if it's been compromised"}),e.jsx(i.Text,{children:"⢠Upload a group picture to make it recognizable"})]})})]})]}):e.jsx(ee,{active:!0,paragraph:{rows:8}})]})};export{Le 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.