(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,92657,e=>{"use strict";var s=e.i(43476);e.i(29519),e.i(19169);var a=e.i(75385),r=e.i(3903),t=e.i(18566),n=e.i(71645),i=e.i(55487),c=e.i(25348);e.s(["default",0,({params:e})=>{let[d,l]=(0,n.useState)([]),[o,u]=(0,n.useState)(""),[h,p]=(0,n.useState)(!1),{bid:m}=e,j=(0,t.useRouter)(),f=(0,i.useSelector)(e=>e.user.userInfo),[x,g]=(0,n.useState)(f.userId);(0,n.useEffect)(()=>{(0,r.getCookie)("token")||j.push("/login")},[]),(0,n.useEffect)(()=>{if(!m||!f.company_id)return;let e=new URL("https://v5.vchat.ourprojectdemo.com/api/companies/brands/users-assign");e.searchParams.append("brandid",m),e.searchParams.append("company_id",f.company_id),e.searchParams.append("filter",!1),fetch(e,{method:"GET"}).then(e=>e.json()).then(e=>l(e)).catch(e=>console.error("Error fetching data:",e))},[m,f.company_id]);let v=async()=>{let e={brandId:m,users:d,company_id:f.company_id,createdBy:x};try{await (0,a.default)("/api/companies/brands/update-users-assign","PUT",e),(0,c.default)("Success!","User successfully Assigned to Brand.","success")}catch(e){(0,c.default)("Oops!",e.message,"error")}},b=d.filter(e=>e.user_name?.toLowerCase()?.includes(o.toLowerCase()));return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"container-fluid top-bar",children:[(0,s.jsx)("div",{className:"left-div",children:(0,s.jsx)("h2",{children:"Assign User"})}),(0,s.jsx)("div",{className:"right-div"})]}),(0,s.jsx)("div",{className:"container-fluid company-header",children:(0,s.jsxs)("div",{className:"comp-header-row flex justify-content-between align-items-center",children:[(0,s.jsx)("input",{type:"text",className:"form-control w-75 ",placeholder:"Search Brands",value:o,onChange:e=>{u(e.target.value)}}),h&&(0,s.jsx)("button",{className:"btn p-btn",onClick:v,children:"Save Changes"})]})}),(0,s.jsx)("div",{className:"container-fluid table-container",children:(0,s.jsxs)("table",{className:"table table-striped mt-4",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"User"}),(0,s.jsx)("th",{children:"Assign"})]})}),(0,s.jsx)("tbody",{children:b.map(e=>1!==f.role&&1===e.is_private&&e.id!==f.userId?null:(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:e.user_name}),(0,s.jsx)("td",{children:(0,s.jsx)("input",{type:"checkbox",checked:1===e.assigned,onChange:()=>{var s;return s=e.user_id,void(l(d.map(e=>e.user_id===s?{...e,assigned:+(1!==e.assigned)}:e)),p(!0))}})})]},e.user_id))})]})})]})}])}]);