PageSourceSearch

https://portal.continental-industry.com/assets/ApproveUserPage-QuXy8eKt.js

js continental-industry.com collected 2026-09-24 21:47:27 UTC 12,698 bytes, 1 lines download raw bytes

1var it=Object.defineProperty;var rt=(p,f,y)=>f in p?it(p,f,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[f]=y;var ve=(p,f,y)=>rt(p,typeof f!="symbol"?f+"":f,y);import{x as lt,o as ct,u as dt,U as ut,r as c,bA as mt,l as ft,av as Ie,j as t,J as ht,z as ke,d as se,aq as qe,a3 as bt,t as Me,b as pt,a0 as gt,Q as Ct,N as xt,i as Oe,ay as yt,bB as jt,I as T,Z as St,Y as Nt,B as Pe,aU as wt,g as Z,T as Lt,aW as At,aQ as Ft,by as vt}from"../index.js";import{C as Be,F as It}from"./CustomerModeButton-CwIL_Lmo.js";import{g as Mt}from"./UserManagement-C0Y0ygrD.js";import{a as Ot}from"./RegionDropdown-D0AtchZY.js";import{u as Pt}from"./useRegionTags-D92lxYJo.js";import{m as ne}from"./mulesoft-B1-VwAro.js";import{C as Bt}from"./customer-status-Cww_sR-5.js";import{u as kt,P as qt}from"./PermissionsSection-Bp7ij5fv.js";import{u as Rt}from"./user-permissions-Cy1t-3uL.js";import{F as zt}from"./PlusIcon-C9L_bqJt.js";import"./CollectionTable-DvusUM9e.js";import"./ListView-CfXJBcSF.js";import"./ExclamationCircleIcon-D4d25Pjr.js";import"./Pagination-gjxk26P9.js";import"./export-BQOJ0QNK.js";import"./xlsx-CygJKsBP.js";import"./useSearchQueryState-Bl1H5UGN.js";import"./Cell-JllDn1xc.js";import"./ChevronDownIcon-IoQOyGWS.js";const L={documentId:"",customerStatus:"PendingApproval",country:"",address:"",zipCode:"",city:"",participatesInPOC:!1,industries:[],products:[],accountNumber:"",name:"",domain:"",salesforceAccountId:""};class Qt{constructor(){ve(this,"subscribers",new Set)}subscribe(f){return this.subscribers.add(f),()=>{this.subscribers.delete(f)}}publish(){this.subscribers.forEach(f=>f())}}const ae=new Qt;function rn(){var le,ce,de,ue,me,fe,he;const{language:p}=lt(),{labels:f}=ct(),[y]=dt(),_=ut(),A=y.get("documentId")||"",[z,K]=c.useState(!1),[g,Q]=c.useState(!1),[I,$]=c.useState(!1),E=c.useRef(new AbortController),Y=y.get("nextParams")||"",{countryDropdownOptions:J}=mt(),[C,i]=c.useState(null),[M,F]=c.useState(null),[N,oe]=c.useState(null),{regionTags:Re}=Pt(),{messages:ze}=ft(),[ie,Qe]=c.useState(new Set),$e=c.useCallback(n=>{if(!n){F(null);return}Ie({title:"Confirm change",description:t.jsxs("p",{className:"text-sm text-gray-500",children:["Are you sure you want to change the customer to",t.jsx("br",{}),t.jsx("span",{className:"font-semibold text-gray-900",children:n==null?void 0:n.name})]}),onConfirm:()=>{F(n),H(null)},onCancel:()=>{ae.publish()},confirmLabel:"Yes",cancelLabel:"No"})},[]),re=n=>{n!==g&&(Q(n),F(null),H(null),$(!1),v(L),i(null),ae.publish())},[h,D]=c.useState({email:"",firstName:"",lastName:"",telephone:{code:"",number:""},department:""}),[a,v]=c.useState(L),{data:U,loading:Ee}=ht({language:p,path:"user-management",query:"user-management"}),{data:r,isLoading:Ye,error:Je}=ke(`${se.getCustomerContact(A)}`,qe,{revalidateOnFocus:!1}),G=(ce=(le=r==null?void 0:r.data)==null?void 0:le.user)==null?void 0:ce.id,{allPermissions:We,isLoading:Ze}=kt(G,void 0,"customer"),[d,H]=c.useState(null),u=c.useMemo(()=>{var n,o;return g?d?ne(d):null:M||(d?{...(n=r==null?void 0:r.data)==null?void 0:n.customer,...ne(d)}:(o=r==null?void 0:r.data)==null?void 0:o.customer)},[r,M,d,g]),j=g?!!d:(u==null?void 0:u.customerStatus)!=="PendingApproval"||!!d,{industries:_e,products:Ke,isLoading:Ge}=bt(),He=c.useCallback(n=>{if(!n){H(null);return}Ie({title:"Confirm change",description:t.jsxs("div",{className:"text-sm text-gray-500",children:["Are you sure you want to change the customer to",t.jsx("br",{}),t.jsx("span",{className:"font-semibold text-gray-900",children:n==null?void 0:n.Name}),t.jsx("br",{}),t.jsx("span",{children:"All fields will be overwritten with data from salesforce"})]}),onConfirm:()=>{H(n)},onCancel:()=>{},confirmLabel:"Yes",cancelLabel:"No"})},[]);c.useEffect(()=>{var n,o;if((n=r==null?void 0:r.data)!=null&&n.user){const e=(o=r==null?void 0:r.data)==null?void 0:o.user;D({email:(e==null?void 0:e.email)||"",firstName:(e==null?void 0:e.firstName)||"",lastName:(e==null?void 0:e.lastName)||"",telephone:{code:"",number:(e==null?void 0:e.telephone)||""},department:(e==null?void 0:e.department)||""}),oe((e==null?void 0:e.region)||null)}},[r]),c.useEffect(()=>{if(!u){v(L),i(null);return}
1Object.keys(L).forEach(o=>{if(o==="country"){const e=J.find(w=>w.countryCode===(u==null?void 0:u.country));i(e||null)}else u!=null&&u[o]?v(e=>({...e,[o]:u==null?void 0:u[o]})):Object.prototype.hasOwnProperty.call(L,o)&&v(e=>({...e,[o]:L==null?void 0:L[o]}))})},[u,J]);async function Ve(n){var pe,ge,Ce,xe,ye,je,Se,Ne,we,Le,Ae;const o=ee["Message.MissingInfo"],e=ee["Message.ApproveError"],w=ee["Message.InvalidCountryRegionTag"],be=(pe=Re.find(b=>{var X;return(b==null?void 0:b.aemTag)===((X=C==null?void 0:C.regionTag)==null?void 0:X.trim())}))==null?void 0:pe.id;try{n.preventDefault(),K(!0),E.current.abort(),E.current=new AbortController;const b=wt.bind(null,o==null?void 0:o.title,o==null?void 0:o.description);if(!j&&!C){b();return}else if((!j||d)&&(a!=null&&a.industries)&&((ge=a==null?void 0:a.industries)==null?void 0:ge.length)<=0){b();return}else if((!j||d)&&!be){Z(w==null?void 0:w.title,w==null?void 0:w.description);return}if(j===!1&&I===!1&&d===null){b();return}const X=[h==null?void 0:h.firstName,h==null?void 0:h.lastName,a==null?void 0:a.zipCode,a==null?void 0:a.city,a==null?void 0:a.name,a==null?void 0:a.address];if(!j&&X.some(x=>!(x!=null&&x.trim()))){b();return}if(!N){b();return}const te={...a};delete te.documentId,delete te.customerStatus;const ot={firstName:(Ce=h.firstName)==null?void 0:Ce.trim(),lastName:(xe=h.lastName)==null?void 0:xe.trim(),telephone:(je=(ye=h.telephone)==null?void 0:ye.number)!=null&&je.trim()?(((Se=h.telephone)==null?void 0:Se.code)+((Ne=h.telephone)==null?void 0:Ne.number)).trim():void 0,department:(we=h.department)==null?void 0:we.trim(),customer:{...g?te:a,salesforceAccountId:I?null:d==null?void 0:d.Id,country:C==null?void 0:C.countryCode,region:be,...d?ne(d):{}},region:{documentId:N==null?void 0:N.documentId,id:N==null?void 0:N.id}},W=await fetch(se.approveCustomerContact(A,I),{method:"POST",headers:{Authorization:`Bearer ${Lt()}`,"Content-Type":"application/json"},body:JSON.stringify(ot),signal:E.current.signal});if(!W.ok)if((Le=W.headers.get("content-type"))!=null&&Le.includes("application/json")){const x=await W.json(),Fe=(Ae=x==null?void 0:x.error)==null?void 0:Ae.message;Fe?Z(ze[Fe]):Z(e==null?void 0:e.title,e==null?void 0:e.description);return}else{const x=await W.text();throw new Error(x)}if(G)try{await Rt(G,ie,We)}catch(x){Z(e==null?void 0:e.title,e==null?void 0:e.description),console.error("Permissions update error:",x)}return _(Oe.userManagement+`?${atob(Y)}`,{replace:!0}),W.json()}catch(b){(b==null?void 0:b.name)!=="AbortError"&&(Z(e==null?void 0:e.title,e==null?void 0:e.description),console.error("Approval error:",b))}finally{K(!1)}}const V=n=>o=>{D(e=>({...e,[n]:o.target.value}))},Xe=n=>o=>{v(e=>({...e||{},[n]:o.target.value}))},s=(ue=(de=U==null?void 0:U.userManagementByPath)==null?void 0:de.item)==null?void 0:ue.approve,m=Me((s==null?void 0:s.userDetailsInputs)||[]),l=Me((s==null?void 0:s.customerDetailsInputs)||[]),ee=pt((s==null?void 0:s.toastMessages)||[]),Te=gt((s==null?void 0:s.checkboxes)||[]),S=l==null?void 0:l["InputField.SelectCustomer"],O=m==null?void 0:m["InputField.Email"],P=m==null?void 0:m["InputField.FirstName"],B=m==null?void 0:m["InputField.LastName"],k=m==null?void 0:m["InputField.Telephone"],q=m==null?void 0:m["InputField.Department"],R=m==null?void 0:m["InputField.Region"],De=l==null?void 0:l["InputField.CompanyName"],Ue=l==null?void 0:l["InputField.CompanyAddress"],et=l==null?void 0:l["InputField.CompanyZipCode"],tt=l==null?void 0:l["InputField.CompanyIndustries"],nt=l==null?void 0:l["InputField.CompanyProducts"],st=l==null?void 0:l["InputField.SalesforceCustomerId"],at=l==null?void 0:l["InputField.CompanyCity"];return Ye||Ee||Ze?t.jsx("div",{className:"grow flex items-center justify-center",children:t.jsx(Ct,{})}):Je?t.jsx("div",{children:"error"}):r&&((me=r==null?void 0:r.data)==null?void 0:me.customerContactStatus)!=="PendingApproval"?t.jsx(xt,{to:Oe.userManagement,replace:!0}):t.jsx("main",{className:"p-2 lg:p-6",children:t.jsxs("form",{onSubmit:Ve,children:[t.jsx("h2",{className:"font-bold text-lg",children:s==null?void 0:s.customerDetailsLabel}),t.jsxs("div",{className:"grid bg-white shadow-sm lg:grid-cols-3 py-7 px-8 gap-8 my-6",children:[t.jsxs("div",{className:"col-span-full flex flex-wrap items-center justify-between gap-4",children:[t.jsx("div",{className:"flex items-center gap-x-4",children:!g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"font-semibold",children:s==null?void 0:s.statusLabel}),t.jsx(yt,{variant:Mt(u==null?void 0:u.customerStatus),children:u==null?void 0:u.customerStatus})]})}),t.jsxs("div",{className:"inline-flex bg-white ring-1 ring-gray-300",children:[t.jsx(Be,{active:!g,onClick:()=>re(!1),Icon:It,label:S==null?void 0:S.inputLabel}),t.jsx(Be,{active:g,onClick:()=>re(!0),Icon:zt,label:(s==null?void 0:s.createCustomerButtonLabel)??"Create Customer"})]})]}),!g&&t.jsx($t,{label:S==null?void 0:S.inputLabel,placeholder:S==null?void 0:S.inputPlaceholder,disabled:!!d,onCustomerChange:$e}),t.jsx(jt,{values:a,onTextChange:Xe,labels:{name:De,address:Ue,city:at,zipCode:et,industries:nt,products:tt},disabled:j,selectedCountry:C,onCountryChange:i,industries:{options:_e,selected:(a==null?void 0:a.industries)||[],onChange:n=>v(o=>({...o,industries:n})),disabled:!d&&j,required:!0},products:{options:Ke,selected:(a==null?void 0:a.products)||[],onChange:n=>v(o=>({...o,products:n})),disabled:!d&&j},salesforce:{selected:d,onSelect:He,createNew:I,onCreateNewChange:$,input:st,checkboxLabel:s==null?void 0:s.createCustomerLabel,readOnly:j&&!d,readOnlyValue:(a==null?void 0:a.salesforceAccountId)||""}})]}),t.jsx("h2",{className:"font-bold text-lg mt-10",children:s==null?void 0:s.userDetailsTitle}),t.jsxs("div",{className:"grid bg-white shadow-sm lg:grid-cols-3 py-7 px-8 gap-8 my-6",children:[t.jsx(T,{label:O==null?void 0:O.inputLabel,placeholder:O==null?void 0:O.inputPlaceholder,name:"email",type:"email",value:h.email,onChange:V("email"),disabled:!0}
1),t.jsx(T,{label:P==null?void 0:P.inputLabel,placeholder:P==null?void 0:P.inputPlaceholder,value:h.firstName,onChange:V("firstName"),required:!0}),t.jsx(T,{label:B==null?void 0:B.inputLabel,placeholder:B==null?void 0:B.inputPlaceholder,value:h.lastName,onChange:V("lastName"),required:!0}),t.jsx(St,{defaultValue:((he=(fe=r==null?void 0:r.data)==null?void 0:fe.user)==null?void 0:he.telephone)||"",label:k==null?void 0:k.inputLabel,placeholder:k==null?void 0:k.inputPlaceholder,onChange:n=>{D(o=>({...o,telephone:{code:n.code,number:n.number}}))},type:"tel",pattern:"\\d*",title:f[Nt.digitsOnly],required:!0}),t.jsx(Ot,{selectedRegion:N,setSelectedRegion:oe,label:R==null?void 0:R.inputLabel,placeholder:R==null?void 0:R.inputPlaceholder}),t.jsx(T,{label:q==null?void 0:q.inputLabel,placeholder:q==null?void 0:q.inputPlaceholder,value:h.department,onChange:V("department")}),t.jsx(qt,{userId:G,variant:"customer",selectedPermissions:ie,setSelectedPermissions:Qe,inputFields:m,checkboxes:Te}),t.jsxs("div",{className:"flex items-center justify-end gap-x-6 col-span-full",children:[t.jsx(Pe,{variant:"light",type:"button",onClick:()=>_(-1),children:s==null?void 0:s.backLabel}),t.jsx("div",{className:"relative",children:t.jsx(Pe,{type:"submit",loading:z,disabled:z||Ge,children:s==null?void 0:s.approveLabel})})]})]})]})})}function $t({onCustomerChange:p,disabled:f,label:y,placeholder:_}){var C;const[A,z]=c.useState(""),[K,g]=c.useState(""),{data:Q,isLoading:I,error:$}=ke(`${se.getCustomers}?${At.stringify({filters:{customerStatus:Bt.Active},populate:"*",_q:K||void 0})}`,qe,{revalidateOnFocus:!1,dedupingInterval:1e4}),E=((C=Q==null?void 0:Q.data)==null?void 0:C.map(i=>({...i,title:i==null?void 0:i.name,description:i==null?void 0:i.accountNumber})))||[],[Y,J]=c.useState(null);return c.useEffect(()=>{const i=setTimeout(()=>{g((A==null?void 0:A.trim())||"")},500);return()=>clearTimeout(i)},[A]),c.useEffect(()=>{p(Y)},[p,Y]),c.useEffect(()=>ae.subscribe(()=>{J(null),z("")}),[]),$&&console.log($),t.jsx(Ft,{renderDescription:i=>{var M;return t.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-x-2 justify-items-center justify-between",children:[t.jsx("span",{className:"block text-sm text-gray-400 group-data-focus:text-white mt-1 justify-self-start",title:i==null?void 0:i.description,children:i==null?void 0:i.description}),t.jsx(vt,{minItemsToRender:1,isStatic:!0,items:((M=i==null?void 0:i.industries)==null?void 0:M.map(F=>F==null?void 0:F.title))||[]})]})},disabled:f,label:y,options:E,selectedOption:Y,onChange:J,placeholder:_,onQueryChange:z,loading:I,unfiltered:!0})}export{rn 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.