1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3566],{53566:(e,s,l)=>{l.d(s,{a:()=>G,default:()=>q});var a=l(95155),t=l(12115),i=l(83391),n=l(54768),r=l(7266),c=l(57020),d=l(26092),o=l(30814),m=l(29270),x=l(76046);let u=e=>{let{address:s}=e;return(0,a.jsxs)("div",{className:"border rounded-md p-4 mb-4",children:[(0,a.jsxs)("p",{className:"text-18 font-medium",children:[s.line1,",",s.line2&&(0,a.jsx)("span",{children:s.line2})]}),s.postalCode&&(0,a.jsxs)("p",{children:[s.postalCode," ",s.town&&(0,a.jsx)("span",{children:s.town})]}),s.country&&(0,a.jsx)("p",{children:s.country.name})]})};function p(e){let{setShowAddress:s,unitName:l,unitId:p,regionInfo:h}=e,{addresses:g,setAddresses:j,resetAddresses:v}=(0,t.useContext)(G),f=(0,i.wA)(),[N,y]=(0,t.useState)(!1),b=(0,r.useTranslations)("companyUnits.labels"),w=g.reduce((e,s)=>{let l="".concat(s.line1," ").concat(s.line2||"").trim().charAt(0).toUpperCase(),a=/^[0-9]/.test(l)?"#":l;return e[a]||(e[a]=[]),e[a].push(s),e},{}),k=Object.keys(w).sort((e,s)=>"#"===e?-1:"#"===s?1:e.localeCompare(s)),[C,U]=(0,t.useState)(""),[S,A]=(0,t.useState)(!1),[I]=(0,t.useState)(g),{access_token:T}=(0,i.d4)(e=>{var s;return null==e?void 0:null===(s=e.auth)||void 0===s?void 0:s.loginToken}),E=async e=>{if((0,c.I)(e)){j(I),A(!1);return}let s=await (0,d.nI)(T,null==h?void 0:h.siteId,null==h?void 0:h.sLang,"current",p,e);if("success"===s.status){var l;j(null==s?void 0:null===(l=s.unit)||void 0===l?void 0:l.addresses),A(!0)}else s.errors&&s.errors[0]?"InvalidTokenError"===s.errors[0].type&&(0,x.redirect)((null==h?void 0:h.slugUrl)?"/".concat(null==h?void 0:h.slugUrl,"/logout"):"/logout"):o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:s.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})};(0,t.useEffect)(()=>{C?E(C):A(!1)},[C]);let D=()=>{U(""),v(),A(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(a.Fragment,{children:[!N&&(0,a.jsx)("div",{className:"myacc-box-container",children:(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer ",children:(0,a.jsxs)("p",{className:"text-16 lg:text-20 font-medium leading-20",children:[b("address")," (",null==g?void 0:g.length,")"]})}),(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer hover:text-primary",children:(0,a.jsx)("span",{className:"items-center gap-2 flex",children:(0,a.jsx)("span",{onClick:()=>{y(!0),s(!0),f((0,m.AE)(b("address")))},children:(0,a.jsxs)("span",{className:"items-center gap-2 flex",children:[(0,a.jsx)("span",{className:"font-medium text-14 leading-14",children:b("viewAddress")}),(0,a.jsx)("span",{className:"icon-chevron-right text-24"})]})})})})]})}),N&&g&&(0,a.jsxs)("div",{className:"myacc-main-container gap-2 lg:gap-4 ",children:[(0,a.jsxs)("div",{className:"flex gap-1 items-center hover:text-primary cursor-pointer",children:[(0,a.jsx)("span",{className:"icon-chevron-left text-16"}),(0,a.jsxs)("span",{className:"text-14 font-medium leading-14",onClick:()=>{y(!1),s(!1),f((0,m.AE)("")),v()},children:[b("backToUnit"),": ",l]})]}),(0,a.jsx)("div",{className:"myacc-page-title",children:(0,a.jsx)("p",{children:b("addresses")})}),(0,a.jsxs)("div",{className:"myacc-box-container flex flex-col gap-6 myacc-main-container",children:[(0,a.jsxs)("div",{className:"flex flex-col border-b border-gray-200 pb-6 gap-6",children:[(0,a.jsxs)("p",{className:"font-medium text-20",children:[b("addressBook")," (",g.length,")"]}),(0,a.jsx)("div",{className:"w-full md:w-1/2",children:S?(0,a.jsxs)("div",{className:"pl-4 pr-3 py-2 border border-gray-200 flex items-center gap-2 bg-white w-auto justify-between sm:w-auto text-12 md:text-14 rounded-full",children:[(0,a.jsxs)("span",{className:"flex gap-2 items-center",children:[(0,a.jsx)("span",{className:"text-primaryGray",children:b("searchKeyword")}),(0,a.jsx)("span",{className:"font-medium",children:C})]}),(0,a.jsx)("span",{onClick:()=>{D()},className:"icon-close text-18 cursor-pointer hover:text-primary font-bold text-gray-500"})]}):(0,a.jsx)(n.A,{searchValue:U,className:"text-14 leading-14 w-full md:w-3/4 lg:w-3/4 ",placeHolder:"Search",searchButton:!0,searchIconPosition:"left",inputClassName:"bg-white lg:px-3 lg:py-5 lg:gap-2 md:w-3/4 lg:w-3/4"})})]}),k.map(e=>(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-18 font-medium",children:(0,a.jsx)("h2",{children:e})}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:w[e].map((e,s)=>(0,a.jsx)(u,{address:e},s))})]},e))]})]})]}),(0,a.jsx)(o.l$,{position:"top-right",richColors:!0})]})}var h=l(7837),g=l(85060),j=l(69606),v=l(6954),f=l(14085),N=l(16188),y=l(43670),b=l(34839),w=l(43415),k=l(4617),C=l.n(k),U=l(56457),S=l(9955);let A=e=>w.z.object({firstName:w.z.string().min(1,{message:e("required.mandatory")}),lastName:w.z.string().min(1,{message:e("required.mandatory")}),email:w.z.string().min(1,{message:e("required.mandatory")}).email(),parentUnit:w.z.string().min(1,{message:e("required.mandatory")}),roles:w.z.array(w.z.string())});function I(e){let{userAccountDetailData:s,token:l,siteId:i,lang:n,page:c,type:d,setOpen:m,setUserUpdate:x,rolesList:u,parentUnitsList:p}=e,w=(0,r.useTranslations)("myAccount"),k=(0,r.useTranslations)("userAccount.labels"),I=(0,r.useTranslations)("register"),T=(0,r.useTranslations)("formErrorMessages"),E=(0,r.useTranslations)("formErrorMessages"),[D,R]=(0,t.useState)(""),[F,z]=(0,t.useState)(!1),P=A(T),H=(0,j.mN)({resolver:(0,g.u)(P),defaultValues:{firstName:(null==s?void 0:s.firstName)?null==s?void 0:s.firstName:"",lastName:(null==s?void 0:s.lastName)?null==s?void 0:s.lastName:"",email:(null==s?void 0:s.uid)?null==s?void 0:s.uid:"",parentUnit:"",roles:(null==s?void 0:s.roles)?null==s?void 0:s.roles:[]}}),_=()=>{H.reset({firstName:"",lastName:"",email:"",parentUnit:"",roles:[]})};async function L(e){R("");let s=[...new Set([...e.roles||[],"b2bcustomergroup"])],t={uid:"edit"===d?U.A.sanitize(e.email):"",email:U.A.sanitize(e.email),roles:s,parentUnit:U.A.sanitize(e.parentUnit),firstName:U.A.sanitize(e.firstName),lastName:U.A.sanitize(e.lastName)},r=await (0,N.Gl)(l,i,n,t,d);r&&"success"===r.status?(o.oR.success(()=>(0,a.jsx)("div",{style:{color:"black"},children:r.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}}),"listing"===c&&m&&m(!1),x&&x(!0),z(!1),_()):r&&"error"===r.status?((null==r?void 0:r.code)==="404"&&(null==r?void 0:r.message)==="user already exist"?R(E("existingEmail")):o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:r.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}}),x(!1)):o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:r.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})}let V=()=>{R("")};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(h.Dialog,{open:F,onOpenChange:e=>{z(e),e||_()},children:[(0,a.jsx)(h.DialogTrigger,{className:C()("flex items-center gap-2 hover:text-primary "),children:"edit"===d?(0,a.jsxs)("div",{className:C()("flex gap-1 items-center hover:text-primary curs
1or-pointer font-medium",{}),children:[(0,a.jsx)("span",{className:C()("icon-edit",{"text-20":"detail"===c},{"!text-16":"listing"===c})}),(0,a.jsx)("span",{className:C()({"text-14 leading-14":"detail"===c},{"text-12 font-normal":"listing"===c}),children:k("edit")})]}):(0,a.jsxs)("span",{className:"items-center gap-2 flex",children:[(0,a.jsx)("span",{className:"icon-plus text-24"}),(0,a.jsx)("span",{children:k("addNewUser")})]})}),(0,a.jsx)(h.DialogContent,{className:"flex flex-col gap-5 lg:gap-6 w-full lg:w-[662px] px-5 lg:px-[50px] py-8 lg:py-10",children:(0,a.jsxs)("div",{className:"flex gap-5 lg:gap-6 flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1",children:(0,a.jsx)(h.DialogTitle,{children:k("edit"===d?"editUser":"addUser")})}),(0,a.jsx)("div",{children:(0,a.jsx)(b.lV,{...H,children:(0,a.jsxs)("form",{className:"flex flex-col w-full",onSubmit:H.handleSubmit(L),children:[(0,a.jsxs)("div",{className:"flex flex-col md:grid md:grid-cols-2 gap-4",children:[(0,a.jsx)(v.A,{control:H.control,placeholder:I("placeHolder.firstName"),type:"text",label:I("label.firstName"),name:"firstName",editForm:!0,regEx:"textAndSpace"}),(0,a.jsx)(v.A,{control:H.control,placeholder:I("placeHolder.lastName"),type:"text",label:I("label.lastName"),name:"lastName",editForm:!0,regEx:"textAndSpace"}),(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsx)(b.zB,{control:H.control,name:"email",render:e=>{let{field:s}=e;return(0,a.jsxs)(b.eI,{className:"",children:[(0,a.jsx)(b.lR,{children:I("label.email")}),(0,a.jsx)(b.MJ,{children:(0,a.jsx)(S.p,{placeholder:I("placeHolder.email"),type:"email",...s,onFocus:()=>V()})}),(0,a.jsx)(b.C5,{}),D&&(0,a.jsxs)("span",{className:"text-danger text-14 flex gap-1",children:[(0,a.jsx)("span",{className:"font-medium",children:E("email")}),D]})]})}})}),(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsx)(b.zB,{control:H.control,name:"parentUnit",render:e=>{let{field:s}=e;return(0,a.jsxs)(b.eI,{className:"",children:[(0,a.jsx)(b.lR,{children:I("label.parentUnit")}),(0,a.jsx)(b.MJ,{children:(0,a.jsxs)("select",{required:!0,className:"html-select text-black invalid:text-gray-400",onChange:s.onChange,value:s.value,children:[(0,a.jsx)("option",{value:"",disabled:!0,selected:!0,hidden:!0,children:I("placeHolder.parentUnit")}),p&&p.map(e=>(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("option",{className:"text-black",value:e.key,children:e.value})}))]})}),(0,a.jsx)(b.C5,{})]})}})})]}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("label",{className:"md:text-16 md:leading-16 font-medium text-gray-500",children:k("roles")}),(0,a.jsxs)(b.eI,{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mt-4 max-h-[150px] overflow-y-auto",children:[null==u?void 0:u.map(e=>(0,a.jsx)(b.zB,{control:H.control,name:"roles",render:s=>{var l;let{field:t}=s;return(0,a.jsx)(b.eI,{className:"",children:(0,a.jsxs)("div",{className:"flex gap-2 items-center cursor-pointer",children:[(0,a.jsx)(b.MJ,{children:(0,a.jsx)(y.S,{checked:null===(l=t.value)||void 0===l?void 0:l.includes(e.key),onCheckedChange:s=>{var l;return s?t.onChange([...t.value,e.key]):t.onChange(null===(l=t.value)||void 0===l?void 0:l.filter(s=>s!==e.key))}})}),(0,a.jsx)(b.lR,{className:"text-12 lg:text-14 font-medium cursor-pointer",children:e.value})]})},e.key)}},e.key)),(0,a.jsx)(b.C5,{})]})]}),(0,a.jsxs)("div",{className:"flex mt-4 gap-4 justify-end",children:[(0,a.jsx)(h.DialogClose,{onClick:()=>{z(!1),_()},children:(0,a.jsx)(f.$,{theme:"secondary",type:"reset",children:w("button.cancel")})}),(0,a.jsx)(f.$,{type:"submit",className:"w-1/2 md:w-auto ",children:k("edit"===d?"updateUser":"addUser")})]})]})})})]})})]}),(0,a.jsx)(o.l$,{position:"top-right",richColors:!0})]})}var T=l(45575),E=l(49369);function D(e){let{data:s,onSelectionChange:l,rolesList:i,regionInfo:n,selectedUsersList:c,updateSelected:d}=e,o=(0,r.useTranslations)("userAccount.labels"),m=(0,r.useTranslations)("companyUnits.labels"),x=t.useMemo(()=>{let e=new Map;return void 0!==c?(c.forEach(s=>{e.set(s.uid,!!s.selected)}),s.forEach(s=>{e.has(s.uid)||e.set(s.uid,!!s.selected)})):s.forEach(s=>e.set(s.uid,!!s.selected)),e},[s,c]),u=e=>!!x.get(e),p=e=>{let s=new Map;for(let l of e)s.set(l.uid,l);return Array.from(s.values())},h=(e,s)=>{let l;let a=c||[];l=a.find(s=>s.uid===e.uid)?a.map(l=>l.uid===e.uid?{...l,selected:s}:l):[...a,{...e,selected:s}],null==d||d(p(l))};return(0,a.jsx)("div",{className:"md:col-span-8 flex flex-col gap-3 w-full",children:0===s.length?(0,a.jsx)("div",{className:"text-center text-gray-500 mt-6",children:m("noUser")}):s.map(e=>(0,a.jsxs)("div",{className:"relative md:grid md:grid-cols-[20%_30%_25%_25%] flex flex-col border md:border-0 md:border-b roun
1ded-md md:rounded-none border-gray-100 p-4 md:px-4 md:py-6 gap-y-1",children:[(0,a.jsx)("div",{className:"absolute md:hidden right-4 top-4"}),(0,a.jsxs)("div",{className:"md:hidden flex gap-2 items-center",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary ".concat(u(e.uid)?"checkbox-red-tick":""),checked:u(e.uid),disabled:!e.status,onChange:s=>h(e,s.target.checked)}),(null==n?void 0:n.regionCode)==="jp"?(0,a.jsx)(E.A,{customerStatus:null==e?void 0:e.customerStatus,status:null==e?void 0:e.status,resetPwTriggerDate:null==e?void 0:e.resetPwTriggerDate,resetPwExpDate:null==e?void 0:e.resetPwExpDate,page:"listing"}):(0,a.jsx)(T.A,{type:e.status?"success":"warning",text:e.status?o("enabled"):o("disabled")})]}),(0,a.jsxs)("div",{className:"text-14 font-medium leading-14 flex gap-2",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 hidden md:block accent-primary ".concat(u(e.uid)?"checkbox-red-tick":""),checked:u(e.uid),disabled:!e.status,onChange:s=>h(e,s.target.checked),style:{minWidth:"20px",minHeight:"20px"}}),(0,a.jsx)("label",{className:"flex flex-row ",children:(0,a.jsx)("span",{className:"ml-2",style:{wordBreak:"break-word"},children:(null==n?void 0:n.regionCode)==="jp"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{children:null==e?void 0:e.lastName})," ",(0,a.jsx)("span",{children:null==e?void 0:e.firstName})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{children:null==e?void 0:e.firstName})," ",(0,a.jsx)("span",{children:null==e?void 0:e.lastName})]})})})]}),(0,a.jsxs)("div",{className:"pl-8 md:pl-2 text-14",children:[(0,a.jsxs)("span",{className:"md:hidden ",children:[m("email"),":"]}),(0,a.jsx)("span",{className:"ml-1",style:{wordBreak:"break-word"},children:e.uid})]}),(0,a.jsxs)("div",{className:"pl-8 md:pl-4 flex ",children:[(0,a.jsxs)("div",{className:"mb-1 md:hidden mr-1",children:[o("roles"),":"]}),e.roles&&(0,a.jsx)("div",{className:"w-2/3 md:w-full",children:(0,a.jsx)("div",{className:"flex flex-col gap-2 text-12",children:i.filter(s=>e.roles.includes(s.key)).map(e=>(0,a.jsx)("span",{className:"flex",children:(0,a.jsx)("span",{className:"bg-gray-100 px-2 md:px-3 py-1 text-gray-600 rounded-full text-10 leading-10 lg:text-12 lg:leading-12 max-w-[150px]",style:{wordBreak:"break-word"},children:e.value})},e.key))})})]}),(0,a.jsx)("div",{className:"md:pl-2 hidden md:block ",children:(null==n?void 0:n.regionCode)==="jp"?(0,a.jsx)(E.A,{customerStatus:null==e?void 0:e.customerStatus,status:null==e?void 0:e.status,resetPwTriggerDate:null==e?void 0:e.resetPwTriggerDate,resetPwExpDate:null==e?void 0:e.resetPwExpDate,page:"listing"}):(0,a.jsx)(T.A,{type:e.status?"success":"warning",text:e.status?o("enabled"):o("disabled")})})]},e.uid))})}var R=l(98925),F=l(19844),z=l(56359);function P(e){let{unitId:s,role:l,rolesList:i,fetchUnitDetail:c,regionInfo:m,token:x}=e,u=(0,r.useTranslations)("userAccount.labels"),p=(0,r.useTranslations)("companyUnits.labels"),[g,j]=(0,t.useState)(0),[v,N]=(0,t.useState)(),[y,b]=(0,t.useState)(""),[w,k]=(0,t.useState)(!1),[C,U]=(0,t.useState)(!1),[S,A]=(0,t.useState)([]),[I,T]=(0,t.useState)((null==m?void 0:m.regionCode)==="jp"?"byUid":"byNameasc"),E=async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I;k(!1);let t={role:l.key,sort:a,searchValue:"",unit:s},i=await (0,d.e9)(x,null==m?void 0:m.siteId,null==m?void 0:m.sLang,"current",e,t);if("success"===i.status){N(i);let e=i.customers.filter(e=>e.selected);A(s=>{let l=new Map(s.map(e=>[e.uid,e]));return e.forEach(e=>{l.has(e.uid)||l.set(e.uid,e)}),Array.from(l.values())})}},P=async()=>{let e=S.map(e=>({user:e.uid,select:e.selected})),s=await (0,d.v)(x,null==m?void 0:m.siteId,null==m?void 0:m.sLang,"current",e,l.key);"success"===s.status&&(o.oR.success(()=>(0,a.jsx)("div",{style:{color:"black"},children:p("sucessExistingUser")}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}}),setTimeout(()=>{(0,F.e)(),c()},2e3),A([]),U(!1)),s.errors&&s.errors[0]&&o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:s.errors[0].message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})},H=(0,t.useRef)(null),_=async(e,a)=>{let t={role:l.key,sort:I,searchValue:e,unit:s},i=await (0,d.Ce)(x,null==m?void 0:m.siteId,null==m?void 0:m.sLang,"current",a,t);if("success"===i.status){N(i),k(!0);let e=i.customers.filter(e=>e.selected);A(s=>{let l=new Map(s.map(e=>[e.uid,e]));
1return e.forEach(e=>{l.has(e.uid)||l.set(e.uid,e)}),Array.from(l.values())})}};(0,t.useEffect)(()=>{y&&(_(y,0),j(0))},[y]);let L=(null==v?void 0:v.customers)||[],V=e=>{T(e),E(g,e)},B=(null==m?void 0:m.regionCode)==="jp"?[{key:"byUid",value:"ã¡ã¼ã«æé "},{key:"byUiddesc",value:"ã¡ã¼ã«éé "}]:[{key:"byNameasc",value:p("nameAsc")},{key:"byNamedesc",value:p("nameDesc")}],[M,O]=(0,t.useState)(B[0].value);return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(h.Dialog,{open:C,onOpenChange:e=>{U(e),e||(j(0),b(""),k(!1),A([]))},children:[(0,a.jsx)(h.DialogTrigger,{className:"flex gap-2",children:(0,a.jsxs)("div",{className:"flex items-center hover:text-primary",onClick:()=>E(0),children:[(0,a.jsx)("span",{className:"icon-plus"}),(0,a.jsx)("span",{className:"font-medium text-14 lg:text-16",children:p("addExistingUser")})]})}),(0,a.jsxs)(h.DialogContent,{className:"px-0 md:px-4",children:[(0,a.jsx)("div",{className:"flex gap-2 flex-col pl-4 md:pl-0",children:(0,a.jsx)(h.DialogTitle,{children:(null==m?void 0:m.regionCode)==="jp"?(0,a.jsxs)(a.Fragment,{children:[null==l?void 0:l.value," ãã¼ã«ãä»ä¸"]}):(0,a.jsx)(a.Fragment,{children:p("addExistingUser")})})}),(0,a.jsxs)("div",{className:"p-0 md:p-4 myacc-box-container !border-0 md:!border max-h-[70vh] ",children:[(0,a.jsx)("div",{className:"w-full md:w-1/2 items-start gap-4 md:items-center mb-6",children:w?(0,a.jsxs)("div",{className:"pl-4 pr-3 py-2 border border-gray-200 flex items-center gap-2 bg-white w-auto justify-between sm:w-auto text-12 md:text-14 rounded-full",children:[(0,a.jsxs)("span",{className:"flex gap-2 items-center min-w-0",children:[(0,a.jsx)("span",{className:"text-primaryGray",children:p("searchKeyword")}),(0,a.jsx)("span",{className:"font-medium truncate",children:y})]}),(0,a.jsx)("span",{onClick:()=>{b(""),E(0),j(0),k(!1)},className:"icon-close text-18 cursor-pointer hover:text-primary font-bold text-gray-500 flex-shrink-0"})]}):(0,a.jsx)(n.A,{searchValue:b,className:"text-14 leading-14 w-full md:w-3/4 lg:w-3/4",placeHolder:u("searchUser"),searchButton:!0,searchIconPosition:"left",inputClassName:"bg-white lg:px-3 lg:py-5 lg:gap-2 md:w-3/4 lg:w-3/4"})}),(0,a.jsxs)("div",{className:"flex lg:hidden pb-3",children:[(0,a.jsxs)("div",{className:"flex flex-row w-1/2",children:[(0,a.jsx)("span",{className:"icon-sort text-20 flex items-center pr-4"}),(0,a.jsxs)("p",{className:"flex items-center pr-4 text-14 leading-14 font-medium",children:[" ",p("sortBy")]})]}),(0,a.jsx)(z.A,{placeHolder:"selectSortOption",onValueChange:e=>{O(e);let s=B.find(s=>s.value===e);s&&V(s.key)},options:B.map(e=>e.value),selectedValue:M,setSelectedValue:O,defaultVal:B[0].value,icon:"icon-class-name",inputclassName:"custom-input-class"})]}),(0,a.jsx)("div",{className:"md:col-span-5 hidden md:grid bg-gray-50",children:(0,a.jsxs)("div",{className:"text-14 leading-14 text-primaryGray items-center grid grid-cols-[20%_30%_25%_25%] sticky top-0 bg-gray-50 z-10",children:[(0,a.jsx)("div",{className:"flex flex-row items-center pl-[15px]",children:(null==m?void 0:m.regionCode)==="jp"?(0,a.jsx)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",children:(0,a.jsx)("span",{children:u("name")})}):(0,a.jsxs)("span",{className:"flex items-center py-2 pl-8 cursor-pointer",onClick:()=>V("byNamedesc"===I?"byNameasc":"byNamedesc"),children:[(0,a.jsx)("span",{children:u("name")}),(0,a.jsx)("span",{className:"icon-table-filter text-24"})]})}),(null==m?void 0:m.regionCode)==="jp"?(0,a.jsxs)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",onClick:()=>V("byUid"===I?"byUiddesc":"byUid"),children:[(0,a.jsx)("span",{children:p("email")}),(0,a.jsx)("span",{className:"icon-table-filter text-24"})]}):(0,a.jsx)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",children:(0,a.jsx)("span",{children:p("email")})}),(0,a.jsx)("span",{className:"py-2 pl-4",children:u("roles")}),(0,a.jsx)("span",{className:"py-2 pl-2",children:u("status")})]})}),(0,a.jsx)("div",{className:"max-h-[50vh] overflow-y-auto ",ref:H,children:(0,a.jsx)("div",{className:"md:grid md:grid-cols-[20%_30%_25%_25%]",children:(0,a.jsx)(D,{data:L.length>0?L:(null==v?void 0:v.customers)||[],selectedUsersList:S,updateSelected:A,rolesList:i,regionInfo:m})})}),(0,a.jsx)(R.A,{totalItems:parseInt(null==v?void 0:v.totalCount)||0,itemsPerPage:parseInt(null==v?void 0:v.pageSize)||10,currentPage:g,pagination:!0,onPageChange:e=>{H.current&&(H.current.scrollTop=0),y?_(y,e):E(e,I),j(e)},regionCode:null==m?void 0:m.regionCode})]}),(0,a.jsx)("div",{className:"flex flex-row flex-wrap items-end justify-end font-medium text-16 leading-16",children:(0,a.jsx)("div",{className:"basis-full lg:basis-1/2 mt-3 lg:mt-0",children:(0,a.jsxs)("div",{className:"flex w-full gap-2",children:[(0,a.jsx)(h.DialogClose,{type:"reset",className:"btn-secondary w-1/2 !h-[36px]",onClick:()=>{j(0),b(""),k(!1),A([])},children:p("cancel")}),(0,a.jsx)(f.$,{type:"submit",theme:"primary",className:"w-1/2 !h-[36px]",onClick:()=>{P(),b(""),k(!1)},children:p("update")})]})})})]})]})})}function H(e){let{unitId:s,roles:l,setUserUpdate:n,setShowManageUser:c,setSelectedRole:d,setSelectedRoleName:x,setSelectedRoleDetail:u,setParentUnits:p,fetchUnitDetail:h,regionInfo:g,token:j}=e,v=(0,r.useTranslations)("companyUnits.labels"),f=(0,r.useTranslations)("userAccount.labels"),y=(0,i.wA)(),[b,w]=(0,t.useState)([]),[k,C]=(0,t.useState)([]),U=Object.keys(l).reduce((e,s)=>(e[s.toLowerCase()]=l[s],e),{}),S=async()=>{let e=await (0,N.HF)(j,g);
1if(e){var s;C(null==e?void 0:e.b2bUnits.entry),p(null==e?void 0:e.b2bUnits.entry),w(null==e?void 0:null===(s=e.roles)||void 0===s?void 0:s.entry)}};(0,t.useEffect)(()=>{S()},[]);let A=(null==g?void 0:g.regionCode)==="jp"?b.filter(e=>"b2bidecadmingroup"!==e.key):b;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"myacc-box-container",children:[(0,a.jsxs)("div",{className:"flex justify-between mb-4 pb-4 border-b",children:[(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer ",children:(0,a.jsx)("p",{className:"font-medium text-20",children:v("roles")})}),(null==g?void 0:g.regionCode)!=="jp"&&(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer hover:text-primary font-medium",children:(0,a.jsx)(I,{token:j,siteId:null==g?void 0:g.siteId,lang:null==g?void 0:g.sLang,page:"listing",type:"add",setUserUpdate:n,rolesList:b,parentUnitsList:k})})]}),A.map(e=>{var l;return(0,a.jsxs)("div",{className:"flex justify-between flex-col md:flex-row gap-2 mb-4 pb-4 border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"text-18 leading-18 font-medium",children:e.value.charAt(0).toUpperCase()+e.value.slice(1)}),(0,a.jsxs)("span",{className:"text-16 leading-16 md:text-16 md:leading-16 text-gray-800 mt-1 flex gap-1",children:[f("users"),":",(0,a.jsx)("span",{className:"font-medium",children:((null===(l=U[e.key.toLowerCase()])||void 0===l?void 0:l.length)||0).toString()})]})]}),(0,a.jsxs)("div",{className:"flex md:gap-6 items-center gap-2",children:[((null==g?void 0:g.regionCode)!=="jp"||(null==g?void 0:g.regionCode)==="jp"&&"b2badmingroup"!==e.key&&"b2bwebedigroup"!==e.key&&"b2bcustomergroup"!==e.key)&&(0,a.jsx)("div",{className:"flex gap-2 items-center cursor-pointer hover:text-primary",children:(0,a.jsx)(P,{unitId:s,role:e,rolesList:A,fetchUnitDetail:h,regionInfo:g,token:j})}),(0,a.jsx)("div",{className:"flex gap-2 items-center cursor-pointer hover:text-primary",onClick:()=>{c(!0),d(e.key),x(e.value),u(e),y((0,m.Hs)(e.value))},children:(0,a.jsxs)("span",{className:"items-center gap-2 md:flex",children:[(0,a.jsx)("span",{className:"icon-edit text-24"}),(0,a.jsx)("span",{className:"font-medium",children:(null==g?void 0:g.regionCode)!=="jp"?v("manage"):v("viewUser")})]})})]})]},e.key.toLowerCase())})]}),(0,a.jsx)(o.l$,{position:"top-right",richColors:!0})]})}var _=l(67396);let L=e=>w.z.object({firstName:w.z.string().min(1,{message:e("required.mandatory")}),lastName:w.z.string().min(1,{message:e("required.mandatory")}),email:w.z.string().min(1,{message:e("required.mandatory")}).email(),parentUnit:w.z.string().min(1,{message:e("required.mandatory")})});function V(e){let{userAccountDetailData:s,token:l,siteId:i,lang:n,page:c,type:d,roleName:m,parentUnitsList:x,fetchUnitDetail:u,roleKey:p}=e,y=(0,r.useTranslations)("myAccount"),w=(0,r.useTranslations)("userAccount.labels"),k=(0,r.useTranslations)("register"),S=(0,r.useTranslations)("formErrorMessages"),[A,I]=(0,t.useState)(!1),T=L(S),E=(0,j.mN)({resolver:(0,g.u)(T),defaultValues:{firstName:(null==s?void 0:s.firstName)?null==s?void 0:s.firstName:"",lastName:(null==s?void 0:s.lastName)?null==s?void 0:s.lastName:"",email:(null==s?void 0:s.uid)?null==s?void 0:s.uid:"",parentUnit:"",roles:p}});async function D(e){let s={uid:"edit"===d?U.A.sanitize(e.email):"",email:U.A.sanitize(e.email),roles:p,parentUnit:U.A.sanitize(e.parentUnit),firstName:U.A.sanitize(e.firstName),lastName:U.A.sanitize(e.lastName)},t=await (0,N.Gl)(l,i,n,s,d);t&&"success"===t.status?(o.oR.success(()=>(0,a.jsx)("div",{style:{color:"black"},children:t.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}}),u(),I(!1)):t&&"error"===t.status&&(o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:t.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}}),I(!1))}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(h.Dialog,{open:A,onOpenChange:I,children:[(0,a.jsx)(h.DialogTrigger,{className:C()("flex items-center gap-2 hover:text-primary "),children:"edit"===d?(0,a.jsxs)("div",{className:C()("flex gap-1 items-center hover:text-primary curs
1or-pointer font-medium",{}),children:[(0,a.jsx)("span",{className:C()("icon-edit",{"text-20":"detail"===c},{"!text-16":"listing"===c})}),(0,a.jsx)("span",{className:C()({"text-14 leading-14":"detail"===c},{"text-12 font-normal":"listing"===c}),children:w("edit")})]}):(0,a.jsxs)("span",{className:"flex items-center hover:text-primary",children:[(0,a.jsx)("span",{className:"icon-plus"}),(0,a.jsx)("span",{className:"font-medium text-14 lg:text-16",children:w("addNewUser")})]})}),(0,a.jsx)(h.DialogContent,{className:"flex flex-col gap-5 lg:gap-6 w-full lg:w-[662px] px-5 lg:px-[50px] py-8 lg:py-10",children:(0,a.jsxs)("div",{className:"flex gap-5 lg:gap-6 flex-col",children:[(0,a.jsx)("div",{className:"flex flex-col gap-1",children:(0,a.jsx)(h.DialogTitle,{children:w("edit"===d?"editUser":"addUser")})}),(0,a.jsx)("div",{children:(0,a.jsx)(b.lV,{...E,children:(0,a.jsxs)("form",{className:"flex flex-col w-full",onSubmit:E.handleSubmit(D),children:[(0,a.jsxs)("div",{className:"flex flex-col md:grid md:grid-cols-2 gap-4",children:[(0,a.jsx)(v.A,{control:E.control,placeholder:k("placeHolder.firstName"),type:"text",label:k("label.firstName"),name:"firstName",editForm:!0,regEx:"textAndSpace"}),(0,a.jsx)(v.A,{control:E.control,placeholder:k("placeHolder.lastName"),type:"text",label:k("label.lastName"),name:"lastName",editForm:!0,regEx:"textAndSpace"}),(0,a.jsx)(v.A,{control:E.control,placeholder:k("placeHolder.email"),type:"email",label:k("label.email"),name:"email",editForm:!0}),(0,a.jsx)(b.zB,{control:E.control,name:"parentUnit",render:e=>{let{field:s}=e;return(0,a.jsxs)(b.eI,{className:"",children:[(0,a.jsx)(b.lR,{children:k("label.parentUnit")}),(0,a.jsx)(b.MJ,{children:(0,a.jsxs)("select",{...s,className:"html-select",onChange:s.onChange,value:s.value,children:[(0,a.jsx)("option",{value:"",selected:!0,disabled:!0,children:k("placeHolder.parentUnit")}),x&&x.map(e=>(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("option",{value:e.key,children:e.value})}))]})}),(0,a.jsx)(b.C5,{})]})}})]}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("label",{className:"md:text-16 md:leading-16 font-medium text-gray-500",children:w("roles")}),(0,a.jsx)("div",{className:"flex justify-between items-center w-full md:hidden"}),(0,a.jsxs)("label",{className:"flex items-center mt-4",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary ",checked:!0,disabled:!0}),(0,a.jsxs)("span",{className:"ml-2 text-12 lg:text-14 font-medium cursor-pointer",children:[" ",m]})]})]}),(0,a.jsxs)("div",{className:"flex mt-4 gap-4 justify-end",children:[(0,a.jsx)(h.DialogClose,{children:(0,a.jsx)(f.$,{theme:"secondary",type:"reset",children:y("button.cancel")})}),(0,a.jsx)(f.$,{type:"submit",className:"w-1/2 md:w-auto ",children:w("edit"===d?"updateUser":"addUser")})]})]})})})]})})]}),(0,a.jsx)(o.l$,{position:"top-right",richColors:!0})]})}function B(e){let{handleRemove:s,item:l,index:i,isBulkRemove:n=!1,roleName:c="",selectedCount:d=0,regionInfo:o,userUids:m}=e,x=(0,r.useTranslations)("cart"),u=(0,r.useTranslations)("companyUnits.labels"),[p,g]=(0,t.useState)(!1),j=async()=>{n?s("",-1):s(l.uid,i),g(!1)};return(0,a.jsxs)(h.Dialog,{open:p,onOpenChange:e=>{(!n||d>0)&&g(e)},children:[(0,a.jsx)(h.DialogTrigger,{className:"flex gap-2",children:(0,a.jsx)(a.Fragment,{children:n?(0,a.jsxs)("div",{className:"flex flex-row items-center ".concat(d>0?"cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:()=>{d>0&&g(!0)},children:[(0,a.jsx)("span",{className:"icon-delete text-24"}),(0,a.jsx)("span",{className:"ml-2",children:u("removeSelection")})]}):(0,a.jsxs)("div",{className:"flex items-center -mt-9 md:mt-0 justify-end cursor-pointer",onClick:()=>g(!0),children:[(0,a.jsx)("span",{className:"icon-delete text-24"}),(0,a.jsx)("span",{className:"ml-2 hidden md:block hover:underline underline-offset-4",children:u("remove")})]})})}),(0,a.jsxs)(h.DialogContent,{className:"flex flex-col gap-[10px] w-full lg:w-[450px] px-5 lg:px-[50px] py-8",children:[(0,a.jsxs)("div",{className:"flex gap-2 flex-col",children:[(0,a.jsx)(h.DialogTitle,{children:u(n?"removeAllUser":"removeUser")}),(0,a.jsxs)("div",{className:"flex flex-row flex-wrap justify-between mt-4 items-center",children:[(null==o?void 0:o.regionCode)==="jp"?(0,a.jsx)("div",{className:"text-16 block",children:n?(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{children:"鏿ãã"}),(0,a.jsx)("div",{className:"flex flex-col gap-1 mt-2 inline-block",children:(m||[]).map(e=>(0,a.jsx)("p",{children:e},e))}),(0,a.jsxs)("p",{className:"mt-2",children:["ã®ãã¼ã« ",c," ","ãåé¤ãã¾ããç¶è¡ãã¾ããã"]})]}):" ".concat(null==l?void 0:l.uid,"ã®ãã¼ã« ").concat(c," ãåé¤ãã¾ããç¶è¡ãã¾ããã")}):(0,a.jsx)("span",{className:"text-16",children:n?"".concat(u("
1confirm"))+" ".concat(c," ").concat(u("confirm1")," ").concat(d," ").concat(u("confirm2")):u("confirmation")})," "]})]}),(0,a.jsx)("div",{className:"flex flex-col gap-4 overflow-y-auto pr-4"}),(0,a.jsx)("div",{className:"flex justify-end gap-2",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(h.DialogClose,{type:"reset",className:"btn-secondary w-1/2",children:x("buttons.cancel")}),(0,a.jsx)(f.$,{type:"submit",theme:"primary",className:"w-1/2",onClick:j,children:x("buttons.delete")})]})})]})]})}function M(e){let{data:s,selectAll:l,fetchUnitDetail:t,roleKey:n,roleName:c,clearSearch:m,regionInfo:x,selectedMap:u,onToggleRow:p}=e,h=(0,r.useTranslations)("companyUnits.labels"),{access_token:g}=(0,i.d4)(e=>{var s;return null==e?void 0:null===(s=e.auth)||void 0===s?void 0:s.loginToken}),j=e=>{let s=!u[e];p(e,s)},v=async e=>{let s=await (0,d.o)(g,null==x?void 0:x.siteId,null==x?void 0:x.sLang,"current",e,n);m(),"success"===s.status?(t(),p(e,!1),o.oR.success(()=>(0,a.jsx)("div",{style:{color:"black"},children:h("userSuccess")}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})):o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:s.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})};return(0,a.jsx)(a.Fragment,{children:s&&(0,a.jsx)("div",{className:"md:col-span-8 flex flex-col gap-3 w-full",children:s.map(e=>(0,a.jsxs)("div",{className:"relative grid lg:grid-cols-[25%_50%_25%] border-b-2 md:border-0 md:border-b rounded-md md:rounded-none border-gray-100 pl-0 p-4 md:px-4 md:py-6 gap-y-1",children:[(0,a.jsx)("div",{className:"flex items-center text-14 font-medium leading-14",children:(0,a.jsxs)("label",{className:"flex flex-row items-center",children:[((null==x?void 0:x.regionCode)!=="jp"||(null==x?void 0:x.regionCode)==="jp"&&"b2badmingroup"!==n&&"b2bwebedigroup"!==n&&"b2bcustomergroup"!==n)&&(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary",checked:!!u[e.uid],onChange:()=>j(e.uid)}),(0,a.jsx)("span",{className:"ml-3",children:(null==x?void 0:x.regionCode)==="jp"?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{children:null==e?void 0:e.lastName})," ",(0,a.jsx)("span",{children:null==e?void 0:e.firstName})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{children:null==e?void 0:e.firstName})," ",(0,a.jsx)("span",{children:null==e?void 0:e.lastName})]})})]})}),(0,a.jsxs)("div",{className:"flex md:pl-2 text-14 gap-1 pr-7 lg:pr-0",style:{wordBreak:"break-word"},children:[(0,a.jsxs)("span",{className:"pl-8 md:hidden",children:[h("email"),":"]}),(0,a.jsx)("span",{className:"w-2/3 max-w-[200px] lg:max-w-full",children:e.uid})]}),((null==x?void 0:x.regionCode)!=="jp"||(null==x?void 0:x.regionCode)==="jp"&&"b2badmingroup"!==n&&"b2bwebedigroup"!==n&&"b2bcustomergroup"!==n)&&(0,a.jsx)("div",{className:"flex items-center -mt-9 md:mt-0 justify-end cursor-pointer",children:(0,a.jsx)(B,{handleRemove:()=>v(e.uid),item:e,roleName:c,regionInfo:x})})]},e.uid))})})}function O(e){let{role:s,roleName:l,selectedRoleDetail:c,unitId:u,unitName:p,setShowManageUser:h,parentUnits:g,fetchUnitDetailList:j,regionInfo:v,token:f}=e,y=(0,r.useTranslations)("userAccount.labels"),b=(0,r.useTranslations)("companyUnits.labels"),[w,k]=(0,t.useState)([]),[C,U]=(0,t.useState)({}),[S,A]=(0,t.useState)([]),[I,T]=(0,t.useState)((null==v?void 0:v.regionCode)==="jp"?"byEmail":"byNameasc"),[E,D]=(0,t.useState)(""),[H,_]=(0,t.useState)(0),[L,O]=(0,t.useState)(0),$=(null==v?void 0:v.regionCode)==="jp"?L:10,G=e=>{let s=e.target.checked;et(s);let l={...C};w.forEach(e=>{l[e.uid]=s}),U(l)};(0,t.useEffect)(()=>{Array.isArray(w)&&w.length>0?et(w.every(e=>!!C[e.uid])):et(!1)},[C,w]),(0,t.useEffect)(()=>{(0,F.e)(),E?el(E):J()},[H,I]);let[q,K]=(0,t.useState)(!1),J=async()=>{let e=await (0,d.Vb)(f,v,"current",u,s,I,H,$);e&&"success"===e.status&&(k(e.data),O(e.totalCount)),"error"===e.status&&(O(e.totalCount),k([])),e.errors&&e.errors[0]&&"InvalidTokenError"===e.errors[0].type&&(0,x.redirect)((null==v?void 0:v.slugUrl)?"/".concat(null==v?void 0:v.slug
1Url,"/logout"):"/logout")};(0,t.useEffect)(()=>{J()},[]);let X=(null==v?void 0:v.regionCode)==="jp"?[{key:"byEmail",value:"ã¡ã¼ã«æé "},{key:"desc",value:"ã¡ã¼ã«éé "}]:[{key:"byNameasc",value:b("nameAsc")},{key:"byNamedesc",value:b("nameDesc")}],[W,Z]=(0,t.useState)(X[0].value),Q=e=>{T(e)},[Y,ee]=(0,t.useState)(""),es=async()=>{let e=await (0,N.HF)(f,v);if(e){var s;A(null==e?void 0:null===(s=e.roles)||void 0===s?void 0:s.entry)}};(0,t.useEffect)(()=>{es()},[]);let el=async e=>{var l;let a=await (0,d.xS)(f,v,"current",u,s,I,H,$,encodeURIComponent(e));"success"===a.status&&(null==a?void 0:null===(l=a.data)||void 0===l?void 0:l.length)>0?(k(null==a?void 0:a.data),K(!0),O(a.totalCount)):(k(null==a?void 0:a.data),K(!0),O(a.totalCount),ee(a.message))};(0,t.useEffect)(()=>{E&&(_(0),el(E))},[E]);let[ea,et]=(0,t.useState)(!1),ei=async()=>{let e=w.filter(e=>C[e.uid]).map(e=>e.uid),s=await (0,d.o)(f,null==v?void 0:v.siteId,null==v?void 0:v.sLang,"current",e,c.key);"success"===s.status?(ec(),J(),U({}),et(!1),o.oR.success(()=>(0,a.jsx)("div",{style:{color:"black"},children:b("userSuccess")}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})):o.oR.error(()=>(0,a.jsx)("div",{style:{color:"black"},children:s.message}),{action:{label:(0,a.jsx)("span",{className:"icon-close text-18"}),onClick:()=>o.oR.dismiss()}})},en=Object.keys(C).filter(e=>!0===C[e]),er=(0,i.wA)(),ec=()=>{D(""),K(!1),_(0)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"myacc-main-container gap-2 lg:gap-4 ",children:[(0,a.jsxs)("div",{className:"flex gap-1 items-center hover:text-primary cursor-pointer",onClick:()=>{h(!1),j(),er((0,m.Hs)(""))},children:[(0,a.jsx)("span",{className:"icon-chevron-left text-16"}),(0,a.jsxs)("span",{className:"text-14 font-medium leading-14",children:[b("backToUnit")," : ",p]})]}),(0,a.jsx)("div",{className:"myacc-page-title",children:(0,a.jsx)("p",{children:(null==v?void 0:v.regionCode)!=="jp"?l.charAt(0).toUpperCase()+l.slice(1):"ã¦ã¼ã¶ã¼ä¸è¦§ ("+l+")ã表示"})}),(0,a.jsxs)("div",{className:"myacc-box-container",children:[(0,a.jsxs)("div",{className:" grid lg:flex justify-between pb-4 border-b gap-y-2 lg:gap-y-0",children:[(0,a.jsxs)("div",{className:"flex gap-1 items-center cursor-pointer ",children:[(0,a.jsx)("p",{className:"font-medium text-20",children:y("users")}),(0,a.jsx)("span",{translate:"no",children:L?"(".concat(L,")"):0})]}),(0,a.jsxs)("div",{className:"flex gap-2 lg:gap-4 items-center cursor-pointer font-medium",children:[(null==v?void 0:v.regionCode)!=="jp"&&(0,a.jsx)(V,{token:f,siteId:null==v?void 0:v.siteId,lang:null==v?void 0:v.sLang,page:"listing",type:"add",roleName:l,parentUnitsList:g,fetchUnitDetail:J,roleKey:c.key}),((null==v?void 0:v.regionCode)!=="jp"||(null==v?void 0:v.regionCode)==="jp"&&"b2badmingroup"!==c.key&&"b2bwebedigroup"!==c.key&&"b2bcustomergroup"!==c.key)&&(0,a.jsx)(P,{unitId:u,role:c,rolesList:S,fetchUnitDetail:J,regionInfo:v,token:f})]})]}),(0,a.jsxs)("div",{className:"myacc-box-container !border-0 !px-0",children:[(0,a.jsxs)("div",{className:(null==v?void 0:v.regionCode)==="jp"?"flex justify-between flex-col md:flex-row items-start gap-4 md:items-center mb-6 lg:mb-0":"flex flex-col gap-4 justify-between lg:mb-0 mb-6 items-end",children:[(null==v?void 0:v.regionCode)==="jp"&&(0,a.jsx)("div",{className:"w-full md:w-1/2",children:q?(0,a.jsxs)("div",{className:"pl-4 pr-3 py-2 border border-gray-200 flex items-center gap-2 bg-white w-auto justify-between sm:w-auto text-12 md:text-14 rounded-full",children:[(0,a.jsxs)("span",{className:"flex gap-2 items-center",children:[(0,a.jsxs)("span",{className:"text-primaryGray",children:[b("searchKeyword"),":"]}),(0,a.jsx)("span",{className:"font-medium",children:E})]}),(0,a.jsx)("span",{onClick:()=>{J(),D(""),_(0),K(!1)},className:"icon-close text-18 cursor-pointer hover:text-primary font-bold text-gray-500"})]}):(0,a.jsx)(n.A,{searchValue:e=>D(e.trim()),className:"text-14 leading-14 w-full md:w-3/4 lg:w-3/4 ",placeHolder:y("searchEmail"),searchButton:!0,searchIconPosition:"left",inputClassName:"bg-white lg:px-3 lg:py-5 lg:gap-2 md:w-3/4 lg:w-3/4"})}),((null==v?void 0:v.regionCode)!=="jp"||(null==v?void 0:v.regionCode)==="jp"&&"b2badmingroup"!==c.key&&"b2bwebedigroup"!==c.key&&"b2bcustomergroup"!==c.key)&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex justify-between items-center w-full md:hidden",children:[(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary",checked:ea,onChange:G}),(0,a.jsx)("span",{className:"ml-2",children:b("selectAll")})]}),(0,a.jsx)(B,{handleRemove:ei,isBulkRemove:!0,roleName:l,selectedCount:Object.values(C).filter(e=>e).length,regionInfo:v,userUids:en})]}),Array.isArray(w)&&w.length>0&&(0,a.jsx)("div",{className:"hidden md:flex flex-row items-center justify-end",children:(0,a.jsx)(B,{handleRemove:ei,isBulkRemove:!0,roleName:l,selectedCount:Object.values(C).filter(e=>e).length,regionInfo:v,userUids:en})})]})]}),Array.isArray(w)&&w.length>0?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex pb-4 lg:hidden",children:[(0,a.jsxs)("div",{className:"flex flex-row w-1/2",children:[(0,a.jsx)("span",{className:"icon-sort text-20 flex items-center pr-4"}),(0,a.jsxs)("p",{className:"flex items-center pr-4 text-14 leading-14 font-medium",children:[" ",b("sortBy")]})]}),(0,a.jsx)(z.A,{placeHolder:"selectSortOption",icon:"",inputclassName:"w-full",onValueChange:e=>{Z(e);let s=X.find(s=>s.value===e);s&&Q(s.key)},options:X.map(e=>e.value),selectedValue:W,setSelectedValue:Z,defaultVal:X[0].value})]}),(0,a.jsx)("div",{className:" md:col-span-8 hidden md:grid bg-gray-50 mb-4",children:(0,a.jsxs)("div",{className:"text-14 leading-14 text-primaryGray items-center grid grid-cols-[25%_50%_15%]",children:[(0,a.jsxs)("div",{className:"flex flex-row items-center pl-[15px]",children:["b2badmingroup"!==c.key&&"b2bwebedigroup"!==c.key&&"b2bcustomergroup"!==c.key&&
1(null==v?void 0:v.regionCode)==="jp"&&(0,a.jsx)("label",{className:"pt-2",children:(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary",checked:ea,onChange:G})}),(null==v?void 0:v.regionCode)==="jp"?(0,a.jsx)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",children:(0,a.jsx)("span",{children:y("name")})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("label",{className:"pt-2",children:(0,a.jsx)("input",{type:"checkbox",className:"w-5 h-5 accent-primary",checked:ea,onChange:G})}),(0,a.jsxs)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",onClick:()=>Q("byNameasc"===I?"byNamedesc":"byNameasc"),children:[(0,a.jsx)("span",{children:y("name")}),(0,a.jsx)("span",{className:"icon-table-filter text-24"})]})]})]}),(null==v?void 0:v.regionCode)==="jp"?(0,a.jsxs)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",onClick:()=>Q("byEmail"===I?"desc":"byEmail"),children:[(0,a.jsx)("span",{children:b("email")}),(0,a.jsx)("span",{className:"icon-table-filter text-24"})]}):(0,a.jsx)("span",{className:"flex items-center py-2 pl-4 cursor-pointer",children:(0,a.jsx)("span",{children:b("email")})})]})}),(0,a.jsx)("div",{className:"max-h-[50vh] overflow-y-auto md:-mt-4 border-t md:border-t-0",children:(0,a.jsx)("div",{className:"md:grid md:grid-cols-[25%_50%_15%]",children:(0,a.jsx)(M,{data:w,selectAll:ea,fetchUnitDetail:J,roleKey:c.key,roleName:l,selectedMap:C,onToggleRow:(e,s)=>{U(l=>({...l,[e]:s}))},clearSearch:ec,regionInfo:v})})}),(null==v?void 0:v.regionCode)!=="jp"&&(0,a.jsx)(R.A,{totalItems:L,itemsPerPage:$,currentPage:H,pagination:!0,onPageChange:e=>{_(e),et(!1),(0,F.e)()},regionCode:null==v?void 0:v.regionCode})]}):(0,a.jsx)("div",{className:" flex items-center justify-center min-h-[200px]",children:(null==v?void 0:v.regionCode)==="jp"?"ã¦ã¼ã¶ã¼ã¯è¦ã¤ããã¾ããã§ãã":Y})]})]})]}),(0,a.jsx)(o.l$,{position:"top-right",richColors:!0})]})}var $=l(36247);let G=(0,t.createContext)(void 0);function q(e){var s,l,n;let{regionInfo:c,token:o}=e,u=(0,r.useTranslations)("companyUnits.labels"),h=(0,x.useSearchParams)(),[g,j]=(0,t.useState)(!0),v=h.get("unitID")||"",[f,N]=(0,t.useState)(null),[y,b]=(0,t.useState)([]),[w,k]=(0,t.useState)([]),[U,S]=(0,t.useState)(!1),[A,I]=(0,t.useState)([]),[T,E]=(0,t.useState)(!1),[D,R]=(0,t.useState)(!1),[F,z]=(0,t.useState)([]),[P,L]=(0,t.useState)(""),[V,B]=(0,t.useState)({key:"",value:""}),[M,q]=(0,t.useState)(null),[K,J]=(0,t.useState)([]),[X,W]=(0,t.useState)({unitID:"",unitName:""}),Z=async()=>{j(!0);let e=await (0,d.GJ)(o,c,"current",v);if(e&&e.unit){var s,l,a,t;j(!1),N(e.unit),k(null==e?void 0:null===(s=e.unit)||void 0===s?void 0:s.addresses),b(null==e?void 0:null===(l=e.unit)||void 0===l?void 0:l.addresses);let{addresses:i,unitId:n,unitName:r,children:d,...o}=e.unit;I(o),W({unitID:null==e?void 0:null===(a=e.unit)||void 0===a?void 0:a.unitId,unitName:null==e?void 0:null===(t=e.unit)||void 0===t?void 0:t.unitName}),e.errors&&e.errors[0]&&"InvalidTokenError"===e.errors[0].type&&(0,x.redirect)((null==c?void 0:c.slugUrl)?"/".concat(null==c?void 0:c.slugUrl,"/logout"):"/logout")}};(0,t.useEffect)(()=>{(v||T)&&Z()},[v,T]);let Q=(0,i.wA)(),{parentName:Y,childName:ee,address:es,manage:el}=(0,i.d4)(e=>e.breadcrumb);return(0,t.useEffect)(()=>{el&&Q((0,m.Hs)("")),es&&Q((0,m.AE)(""))},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-col gap-6",children:[!U&&!D&&(0,a.jsxs)("div",{className:"myacc-main-container gap-2 lg:gap-4 ",children:[(0,a.jsxs)("div",{className:"flex gap-1 items-center hover:text-primary cursor-pointer",children:[(0,a.jsx)("span",{className:"icon-chevron-left text-16"}),(0,a.jsx)(_.default,{prefetch:!1,href:ee?"company-detail?unitID=".concat(null==f?void 0:f.parentName):"./",children:(0,a.jsx)("span",{className:"text-14 font-medium leading-14",onClick:()=>{ee?Q((0,m.AX)("")):Q((0,m.G)(""))},children:Y&&ee?(0,a.jsxs)(a.Fragment,{children:[u("backToUnit")," : ",Y]}):(0,a.jsx)(a.Fragment,{children:u("backToCompanyUnit")})})})]}),(0,a.jsx)("div",{className:"myacc-page-title",children:(0,a.jsx)("p",{children:null==f?void 0:f.unitName})}),(0,a.jsxs)("div",{className:"myacc-box-container bg-gray-50 ",children:[(0,a.jsx)("div",{className:"flex justify-between mb-4 pb-4 border-b border-gray-200 items-center",children:(0,a.jsx)("div",{className:"flex gap-2 items-center font-medium text-16 leading-16 lg:text-20 lg:leading-20",children:u("unitDetails")})}),(0,a.jsxs)("div",{className:"grid sm:grid-cols-2 gap-4",children:[(0,a.jsxs)("p",{className:"flex gap-1",children:[u("unitName"),":",(0,a.jsx)("span",{className:"font-medium",children:null==f?void 0:f.unitName})]}),(0,a.jsxs)("p",{className:"flex gap-1",children:[u("unitId"),":",(0,a.jsx)("span",{className:"font-medium",children:null==f?void 0:f.unitId})]}),(null==c?void 0:c.regionCode)!=="jp"&&(0,a.jsxs)("p",{className:"flex gap-1",children:[u("parentName"),":",(0,a.jsx)("span",{className:"font-medium",children:(null==f?void 0:f.parentName)?Y:"-"})]})]})]})]}),(null==c?void 0:c.regionCode)!=="jp"&&(0,a.jsxs)(a.Fragment,{children:[y&&!D&&(0,a.jsx)(G.Provider,{value:{addresses:y,setAddresses:b,originalAddresses:w,resetAddresses:()=>b(w)},children:(0,a.jsx)(p,{setShowAddress:S,unitName:X.unitName,unitId:v,regionInfo:c})}),!y&&!D&&(0,a.jsx)("div",{className:"myacc-box-container",children:(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer ",children:(0,a.jsxs)("p",{children:[u("address")," (0)"]})}),(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer hover:text-primary",children:(0,a.jsx)("span",{className:"items-center gap-2 flex",children:(0,a.jsx)("span",{children:(0,a.jsxs)("span",{className:"items-center gap-2 flex",children:[(0,a.jsx)("span",{className:"font-medium text-gray-400 cursor-not-allowed",children:u("viewAddress")}),(0,a.jsx)("span",{className:"icon-chevron-right text-24 text-gray-400 cursor-not-allowed"})]})})})})]})}),!U&&!D&&(0,a.jsx)(a.Fragment,{children:(null==f?void 0:null===(s=f.children)||void 0===s?void 0:s.length)>0?(0,a.jsx)(a.Fragment,{children:(null==f?void 0:f.children)&&(null==f?void 0:null===(l=f.children)||void 0===l?void 0:l.length)>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"myacc-box-container",children:[(0,a.jsx)("div",{className:"flex justify-between mb-4 md:mb-0 pb-4 border-b border-gray-200 items-center",children:(0,a.jsxs)("div",{className:"flex gap-2 items-center font-medium text-16 leading-16 lg:text-20 lg:leading-20",children:[u("childUnits")," ","(",null==f?void 0:null===(n=f.children)||void 0===n?void 0:n.length,")"]})}),(0,a.jsx)("div",{className:"text-14 lg:text-16 flex flex-col cursor-pointer max-h-[340px] md:max-h-[300px] overflow-y-auto",children:null==f?void 0:f.children.map(e=>(0,a.jsxs)("div",{className:"flex justify-between flex-col md:flex-row gap-2 mb-4 pb-4 border-b border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"text-18 leading-18 font-medium",children:e.unitName}),(0,a.jsxs)("span",{className:"text-16 leading-16 md:text-16 md:leading-16 text-gray-800 mt-1",children:[u("unitId")," ",":"," ",(0,a.jsx)("span",{className:"font-medium",children:e.unitId})]})]}),(0,a.jsx)("div",{className:"flex gap-1 items-center cursor-pointer hover:text-primary",children:(0,a.jsxs)(_.default,{prefetch:!1,href:"company-detail?unitID=".concat(e.unitId),onClick:()=>{Q((0,m.AX)(e.unitName))},children:[(0,a.jsxs)("span",{className:"text-14 font-medium leading-14",children:[u("viewChildUnits")," "]}),(0,a.jsx)("span",{className:"icon-chevron-right"})]})})]},e.id))})]})})}):(0,a.jsxs)("div",{className:"myacc-box-container",children:[(0,a.jsx)("div",{className:"flex justify-between mb-4 md:mb-0 pb-4 border-b border-gray-200 items-center",children:(0,a.jsxs)("div",{className:"flex gap-2 items-center font-medium text-16 leading-16 lg:text-20 lg:leading-20",children:[u("childUnits")," (0)"]})}),(0,a.jsxs)("div",{className:"text-14 lg:text-16 flex flex-col cursor-pointer",children:[(0,a.jsx)("div",{className:C()("font-medium flex justify-between w-full")}),(0,a.jsx)("span",{children:u("noChildUnits")})]})]})})]}),!U&&!D&&(0,a.jsx)(H,{unitId:null==f?void 0:f.unitId,roles:A,setUserUpdate:E,setShowManageUser:R,setSelectedRole:z,setSelectedRoleName:L,setSelectedRoleKey:q,setSelectedRoleDetail:B,setParentUnits:J,fetchUnitDetail:Z,regionInfo:c,token:o}),D&&(0,a.jsx)(O,{role:F,roleName:P,selectedRoleDetail:V,unitId:v,roleKey:M,unitName:(null==f?void 0:f.unitName)||"",setShowManageUser:R,parentUnits:K,fetchUnitDetailList:Z,regionInfo:c,token:o})]}),g&&(0,a.jsx)($.A,{})]})}},29270:(e,s,l)=>{l.d(s,{AE:()=>n,AX:()=>i,Ay:()=>d,G:()=>t,Hs:()=>r,hH:()=>c});let a=(0,l(79442).Z0)({name:"breadcrumb",initialState:{parentName:"",childName:"",address:"",manage:""},reducers:{setParentName(e,s){e.parentName=s.payload,e.childName="",e.address="",e.manage=""},setChildName(e,s){e.childName=s.payload},setAddressName(e,s){e.address=s.payload},setManageName(e,s){e.manage=s.payload},clearBreadcrumb:e=>{e.parentName="",e.childName="",e.address="",e.manage=""}}}),{setParentName:t,setChildName:i,setAddressName:n,setManageName:r,clearBreadcrumb:c}=a.actions,d=a.reducer}}]);
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.