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

//# sourceMappingURL=app_%28dashboard%29_brands_%5Bbid%5D_assign-user_page_bf031652.js.map