1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6797],{56923:(e,a,t)=>{"use strict";t.d(a,{o:()=>r,t:()=>d});var l=t(6029);t(55729);var s=t(51369);let i=e=>{let{count:a,active:t}=e;return(0,l.jsx)("span",{className:(0,s.cx)("hidden border border-gray-300 ml-1.5 py-0.5 px-1 rounded-md text-xs font-medium md:inline-block",t?"bg-transparent text-indigo-600":"bg-gray-100 text-gray-600"),children:a})},r=e=>{let{active:a,onClick:t,count:r,children:d,disabled:n,id:c,controls:o,href:m}=e,x=(0,s.cx)("border-b-2 py-3 transition-colors",a?"border-indigo":"border-transparent"),u=(0,l.jsxs)("div",{className:(0,s.cx)(a?"bg-indigo-50 text-indigo-700":"bg-gray-50 text-gray-500 hover:text-gray-700 hover:bg-gray-100","whitespace-nowrap py-1.5 px-3 rounded-lg font-medium text-sm"),children:[d,"number"==typeof r&&(0,l.jsx)(i,{count:r,active:a})]});return m?(0,l.jsx)("a",{href:m,onClick:e=>{e.preventDefault(),t&&t()},id:c,role:"tab","aria-selected":a,"aria-controls":o,className:x,children:u}):(0,l.jsx)("button",{type:"button",onClick:t,disabled:n,id:c,role:"tab","aria-selected":a,"aria-controls":o,className:x,children:u})},d=e=>{let{tabs:a,active:t,onClick:i,className:d,label:n="Tabs",useAnchor:c,noBorder:o}=e;return(0,l.jsx)("div",{className:(0,s.cx)(!o&&"border-b border-gray-200",d),children:(0,l.jsx)("div",{className:"-mb-px -mx-4 px-4 flex space-x-3 overflow-x-auto scrollbar-hidden",role:"tablist","aria-label":n,children:a.map(e=>(0,l.jsx)(r,{onClick:()=>i(e.key),active:t===e.key,count:e.count,id:"tab-".concat(e.key),controls:"tabpanel-".concat(e.key),href:c?e.path:void 0,children:e.label},e.key))})})}},57610:(e,a,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/organization",function(){return t(84614)}])},72373:(e,a,t)=>{"use strict";t.d(a,{ZA:()=>n,rd:()=>d,s5:()=>c});
1var l=t(6029),s=t(55729),i=t(81278),r=t(57521);let d=e=>{let a=(0,i.useRouter)();return(0,s.useEffect)(()=>{a.replace(e.to)},[]),null},n=e=>a=>{let{currentUser:t,loading:s}=(0,r.Us)(),n=(0,i.useRouter)();return s?null:t?(0,l.jsx)(e,{...a}):(0,l.jsx)(d,{to:"/login?returnPath=".concat(n.asPath)})},c=e=>a=>{let{currentUser:t,loading:s}=(0,r.Us)();return s?null:(null==t?void 0:t.role)!=="admin"?(0,l.jsx)(d,{to:"/not-found"}):(0,l.jsx)(e,{...a})}},84614:(e,a,t)=>{"use strict";t.r(a),t.d(a,{default:()=>v});var l=t(6029),s=t(55729),i=t(71422),r=t(47623),d=t(71434),n=t.n(d),c=t(61604),o=t.n(c),m=t(56923),x=t(60722),u=t(31240),h=t(13771),g=t(57521),b=t(25961);let p={ADD:"add",EDIT:"edit"},y=[{key:p.ADD,label:"Add members"},{key:p.EDIT,label:"Manage members"}],f={org:"",file:null,email:"",date:""},j=r.object({org:r.string().required("Required"),file:r.mixed().when("email",{is:e=>!e||""===e.trim(),then:r.mixed().required("Please upload a CSV file or provide an email"),otherwise:r.mixed().notRequired()}),email:r.string(),expiryDate:r.date().nullable()}),v=(0,t(72373).s5)(()=>
1{let[e,a]=(0,s.useState)(p.ADD),{setSuccess:t}=(0,g.E$)(),[r,d]=(0,s.useState)({}),[c,v]=(0,s.useState)({}),[N,w]=(0,s.useState)([]),[D,E]=(0,s.useState)([]),[k,A]=(0,s.useState)([]),[Y,_]=(0,s.useState)(""),[S,C]=(0,s.useState)(!1);(0,s.useEffect)(()=>{(async()=>{E(await (0,b.h6R)())})()},[]),(0,s.useEffect)(()=>{let e=async()=>{C(!0),w([]),w(await (0,b.cuf)(c.id)),C(!1)};n().isEmpty(c)?w([]):e()},[c]);let M=async()=>{try{await (0,b.HD$)({orgId:r.id,list:k}),t("New members added successfully"),d({}),A([]),v(n().find(D,{id:r.id})),a(p.EDIT)}catch(e){_(e)}};return(0,l.jsxs)("div",{className:"mt-10 mx-auto flex flex-col max-w-md w-full",children:[(0,l.jsx)("div",{className:"flex justify-center mb-4",children:(0,l.jsx)(m.t,{tabs:y,active:e,onClick:a})}),e===p.ADD&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("h2",{className:"text-xl font-bold mb-2",children:n().isEmpty(r)?"Add users":"Add ".concat(k.length," users to ").concat(r.name)}),n().isEmpty(k)&&(0,l.jsx)(i.l1,{initialValues:f,validationSchema:j,onSubmit:e=>{if(d(n().find(D,{id:e.org})),e.file){let a=new FileReader;a.onload=e=>{let a=e.target.result.split("\n").map(e=>{let a=e.trim().split(",").map(e=>e.replace(/\r/g,"").trim());return n().zipObject(["email","expires_at"],a)}).map(e=>{let{email:a,expires_at:t}=e,l=o()(t,"YYYY-MM-DD",!0);return{email:a,expires_at:l.isValid()?l.toDate():null}});A(n().uniqBy(a,"email"))},a.readAsText(e.file)}else e.email&&A([{email:e.email.trim(),expires_at:e.expiryDate?new Date(e.expiryDate):null}])},children:e=>{let{setFieldValue:a}=e;return(0,l.jsxs)(i.lV,{className:"flex flex-col",children:[(0,l.jsx)(u.W7,{label:"Select organization",name:"org",options:n().map(D,e=>({value:e.id,label:e.name})),showFilter:!0}),(0,l.jsx)("h3",{className:"text-lg font-semibold my-2",children:"Add multiple users"}),(0,l.jsx)("p",{className:"text-sm mb-4 bg-gray-100 p-3 rounded-lg",children:"Your csv file should have two columns, email and expiry date, with no column headers. Dates should be in the YYYY-MM-DD format."}),(0,l.jsx)(u.UI,{label:"Upload csv file",id:"file",name:"file",accept:"text/csv",onChange:e=>a("file",e.currentTarget.files[0])}),(0,l.jsxs)("div",{className:"flex items-center my-4",children:[(0,l.jsx)("div",{className:"grow border-t border-gray-300"}),(0,l.jsx)("span",{className:"mx-4 text-gray-500",children:"OR"}),(0,l.jsx)("div",{className:"grow border-t border-gray-300"})]}),(0,l.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Add single user"}),(0,l.jsx)(u.ks,{label:"Email",name:"email"}),(0,l.jsx)(u.ks,{type:"date",label:"Expiry date (leave blank if not applicable)",name:"expiryDate"}),(0,l.jsx)(h.Ay,{type:"submit",size:h.lO.LARGE,children:"Preview"})]})}}),!n().isEmpty(k)&&(0,l.jsxs)("div",{className:"flex flex-col gap-y-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)("li",{className:"grid grid-cols-2 items-center bg-gray-100 dark:bg-gray-700 p-3 font-semibold text-gray-800 dark:text-white",children:[(0,l.jsx)("div",{children:"Email"}),(0,l.jsx)("div",{className:"text-center",children:"Expires At"})]}),(0,l.jsx)("div",{className:"max-h-80 overflow-y-scroll",children:(0,l.jsx)("ol",{className:"divide-y divide-gray-200",children:k.map((e,a)=>(0,l.jsxs)("li",{className:"grid grid-cols-2 items-center bg-white dark:bg-gray-800 p-3",children:[(0,l.jsx)("div",{className:"text-gray-500",children:"".concat(a+1,". ").concat(e.email)}),(0,l.jsx)("div",{className:"text-gray-500 text-center",children:e.expires_at?o()(e.expires_at).format("YYYY-MM-DD"):"N/A"})]}))})})]}),(0,l.jsx)(h.Ay,{size:h.lO.LARGE,onClick:M,children:"Confirm"}),(0,l.jsx)(h.Ay,{size:h.lO.LARGE,buttonType:h.EY.SECONDARY,onClick:()=>{d({}),A([])},children:"Back"}),Y&&(0,l.jsx)("div",{className:"text-red",children:Y})]})]}),e===p.EDIT&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("h2",{className:"text-lg font-bold mb-2",children:"View organization members"}),(0,l.jsx)(x.A,{label:"Select organization",name:"view",options:n().map(D,e=>({value:e.id,label:e.name})),onChange:e=>v(n().find(D,{id:e})),value:null==c?void 0:c.id,showFilter:!0,className:"mb-4"}),(0,l.jsx)("div",{className:"font-semibold mb-2",children:"Organization: ".concat((null==c?void 0:c.name)||"Not selected")}),(0,l.jsx)("div",{className:"font-semibold mb-2",children:"Member count: ".concat((null==N?void 0:N.length)||"N/A")}),S&&(0,l.jsx)("div",{className:"text-center w-full font-medium text-gray-500",children:"Loading..."}),!n().isEmpty(N)&&(0,l.jsxs)("div",{children:[(0,l.jsxs)("li",{className:"grid grid-cols-3 items-center bg-gray-100 dark:bg-gray-700 p-3 font-semibold text-gray-800 dark:text-white",children:[(0,l.jsx)("div",{children:"Email"}),(0,l.jsx)("div",{className:"text-center",children:"Expires At"}),(0,l.jsx)("div",{className:"text-center",children:"Date Added"})]}),(0,l.jsx)("div",{className:"max-h-80 overflow-y-scroll",children:(0,l.jsx)("ol",{className:"divide-y divide-gray-200",children:N.map((e,a)=>(0,l.jsxs)("li",{className:"grid grid-cols-3 items-center bg-white dark:bg-gray-800 p-3",children:[(0,l.jsx)("div",{className:"text-gray-500",children:"".concat(a+1,". ").concat(e.email)}),(0,l.jsx)("div",{className:"text-gray-500 text-center",children:e.expires_at?o()(e.expires_at).format("YYYY-MM-DD"):"N/A"}),(0,l.jsx)("div",{className:"text-gray-500 text-center",children:o()(e.created_at).format("YYYY-MM-DD")})]}))})})]})]})]})})}},e=>{e.O(0,[5789,1479,525,2342,6184,2953,7623,1240,6593,636,8792],()=>e(e.s=57610)),_N_E=e.O()}]); 2//# sourceMappingURL=organization-1f6375986380f996.js.map
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.