1import{R as l,j as e,bu as M,p as j,av as b,bv as I,d as A,H as C,bw as v,bx as S,by as w,k,m as g}from"./index-CRlowKLA.js";import"./index-nLSXREZe.js";import{J as T,F as D,c as N,a as x,A as R}from"./index-NG9vlUjF.js";import{S as $}from"./DataTable-BJbJ4R9F.js";const K=[{label:"General",value:"GENERAL"},{label:"Admin",value:"ADMIN"}],O=({companyId:d,companyName:t,show:c,setShow:m})=>{const r=l.useRef(null);return e.jsx(T,{show:c,setShow:m,title:`Add ${t} Member`,submitText:`Add ${t} Member`,onSubmit:a=>{a.preventDefault(),r.current()},children:e.jsx(D,{initialValues:{userId:"",type:""},validationSchema:N().shape({userId:x().required("User wajib diisi"),type:x().required("Tipe wajib diisi")}),onSubmit:async({userId:a,type:i})=>{try{await M({companyId:d,userId:a,type:i}),j({message:"Member berhasil ditambahkan"}),m(!1),setTimeout(()=>window.location.reload(),1e3)}catch(s){console.error(s),alert(`Error: ${s}`)}},children:({touched:a,values:i,errors:s,setFieldValue:p,handleSubmit:u})=>(r.current=u,e.jsxs("div",{className:"d-flex flex-column gap-3",children:[e.jsx(b,{type:"async",label:"User*",loadOptions:I,labelKey:"email",valueKey:"id",color:"gray",error:!!a.userId&&!!s.userId,errorMessage:s.userId,placeholder:"Pilih atau ketik User . . .",onChange:o=>{p("userId",o.value??"")}}),e.jsx(b,{label:"Type*",options:K,color:"gray",value:i.type,error:!!a.type&&!!s.type,errorMessage:s.type,placeholder:"Pilih atau ketik Tipe Member . . .",onChange:o=>{p("type",o.value??"")}})]}))})})};function F(){const d=A(),{id:t}=C(),{companyName:c}=v(t),[m,r]=l.useState(!1),[a,i]=l.useState({}),[s,p]=l.useState(0),u=async n=>{await S({companyId:n.companyId,userId:n.userId}),p(h=>h+1)},[o,y]=l.useState(!1),f=()=>y(n=>!n);return e.jsxs(e.Fragment,{children:[e.jsx(R,{show:m,setShow:r,type:"danger",footerType:"withCancel",iconID:"Outline#trash",title:`Hapus ${a.email}`,body:"And yakin ingin menghapus data ini?",yesText:"Yes, Delete",yesAction:()=>{u(a)}}),e.jsx(O,{companyName:c,companyId:t,show:o,setShow:y}),e.jsxs($,{fetchFunc:w,fetchArgs:t,idKey:"companyId",refreshKey:s,actionColumn:{header:"Actions",render:({row:n,refetch:h})=>e.jsx("button",{onClick:()=>{i({companyId:n[0],userId:n[1],email:n[3]}),r(!0)},children:"Delete"})},children:[e.jsxs("div",{className:"mb-3 w-100 d-flex justify-content-between align-items-center",children:[e.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[t&&e.jsx(k,{iconID:"Outline#arrow left",className:"pointer",onClick:()=>d(-1)}),e.jsxs("h1",{children:[c," Member"]})]}),!t&&e.jsx(g,{onClick:()=>d("/admin-testing/companies"),children:"ke Companies"})]}),e.jsx("div",{className:"d-flex gap-3",children:e.jsx(g,{onClick:f,children:"Add Member "})})]})]})}export{F 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.