PageSourceSearch

https://login.commonsku.com/dist/react/components-EditCompanyShippingAndBillingPopup.94847b7a.chunk.js

js commonsku.com collected 2026-10-02 03:15:55 UTC 7,313 bytes, 2 lines download raw bytes

1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[2879],{3375(s,e,d){d.d(e,{A:()=>c});var i=d(22224),t=d(41594),a=d.n(t),r=d(22078),n=d(39054),l=d(73882),o=d(63988);const h=()=>(0,o.jsx)("div",{"data-test-name":"Mandatory",style:{display:"inline-block",padding:5,width:3,height:3,verticalAlign:"top"},children:"*"});class p extends t.Component{constructor(s){super(s),this.countryOptions=n.Xr.map(s=>({key:s,value:s})),this.state={errors:{}},this.mandatoryFields=["address_line_1","address_city","address_country","address_state","address_postal"]}validate(){const{address:s}=this.props,e={};return this.mandatoryFields.forEach(d=>{e[d]=(0,i.isEmpty)(s[d])}),this.setState({errors:e}),e}handleAddressChange(s,e){const{onChange:d,address:i}=this.props;this.setState({errors:{...this.state.errors,...e}}),d({...i,...s})}renderInput(s){let{field:e,readOnly:d,...t}=s;const{address:a}=this.props,{errors:r}=this.state,n=this.mandatoryFields.indexOf(e)>-1;return(0,o.jsxs)("div",{"data-test-name":"AddressForm.renderInput",children:[(0,o.jsx)("input",{type:"text",style:{display:"inline-block",maxWidth:"90%",...r[e]&&!d?{borderColor:"red"}:{}},onChange:s=>{this.handleAddressChange({[e]:s.target.value},{[e]:n&&(0,i.isEmpty)(s.target.value)})},disabled:d,value:a[e]||"",...t}),n&&(0,o.jsx)(h,{})]})}render(){const{readOnly:s=!1,address:e={}}=this.props,{errors:d}=this.state,t=(0,i.get)(n.xP,e.address_country,[]).map(s=>({key:s.abbr,value:s.name}));return(0,o.jsxs)("div",{"data-test-name":"AddressForm.render",children:[this.renderInput({field:"address_line_1",placeholder:"123 Street St.",readOnly:s}),this.renderInput({field:"address_line_2",placeholder:"Suite Number",readOnly:s}),this.renderInput({field:"address_city",placeholder:"City",readOnly:s}),(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{style:{display:"inline-block",width:"90%"},children:(0,o.jsx)(l.A,{placeholder:"Country",options:this.countryOptions,disabled:s,value:e.address_country&&{value:e.address_country,label:e.address_country},error:d.address_country&&!s,onChange:s=>{this.handleAddressChange({address_country:s.value,address_state:""},{address_state:!1,address_country:(0,i.isEmpty)(s.value)})}})}),(0,o.jsx)(h,{})]}),(0,o.jsx)("div",{children:(0,i.isEmpty)(t)?this.renderInput({field:"address_state",placeholder:"State/Province",readOnly:s}):[(0,o.jsx)("div",{style:{width:"90%",display:"inline-block"},children:(0,o.jsx)(l.A,{placeholder:"State/Province",options:t,disabled:s,value:e.address_state&&{value:e.address_state,label:e.address_state},error:d.address_state&&!s,onChange:s=>{this.handleAddressChange({address_state:s.value},{address_state:(0,i.isEmpty)(s.value)})}})},"select"),(0,o.jsx)(h,{},"mandatory")]}),this.renderInput({field:"address_postal",placeholder:"ZIP/Postal Code",readOnly:s})]})}}class c extends t.Component{constructor(s){super(s),this.state={sameAsBilling:!1,billingAddress:{},shippingAddress:{}},this.billingRef=a().createRef(),this.shippingRef=a().createRef()}async loadAddress(s){if((0,i.isEmpty)(s))return{};const e=await(0,r.oD)("GET",`address/${s}`,{}).catch(()=>null);return(0,i.get)(e,"json.address")||{}}async editAddress(s){const{company_id:e}=this.props;return s.address_id?await(0,r.oD)("PUT",`address/${s.address_id}`,{...s,parent_id:e}):await(0,r.oD)("POST","address",{...s,parent_id:e})}componentDidMount(){this.loadAddresses()}componentDidUpdate(s){const{company_id:e,billing_address_id:d,shipping_address_id:i}=this.props;e==s.company_id&&d==s.billing_address_id&&i==s.shipping_address_id||this.loadAddresses()}async loadAddresses(){const{billing_address_id:s,shipping_address_id:e}=this.props,[d,i]=await Promise.all([this.loadAddress(s),this.loadAddress(e)]);this.setState({billingAddress:d,shippingAddress:i})}async validateAndSave(){const{billingAddress:s,shippingAddress:e}=this.state,d=this.billingRef.current.validate(),t=this.shippingRef.current.validate();if(!(0,i.findKey)(d)&&!(0,i.findKey)(t)){const[d,t]=await Promise.all([this.editAddress({...s,address_name:"Billing Address",tenant_default_billing:!0,address_type:"BILLING",parent_type:"TENANT-BILLING"}),this.editAddress({...e,address_name:"Shipping Address",tenant_default_shipping:!0,address_type:"SHIPPING",parent_type:"TENANT-SHIPPING"})]);return{billingAddress:(0,i.get)(d,["json","address"]),shippingAddress:(0,i.get)(t,["json","address"])}}}render(){const{sameAsBilling:s,billingAddress:e,shippingAddress:d}=this.state;return(0,o.jsxs)("div",{"data-test-name":"EditCompanyShippingAndBillingForm.render",className:"small-12 columns",children:[(0,o.jsxs)("div",{className:"small-12 medium-6 columns",children:[(0,o.jsx)("div",{children:(0,o.jsx)("h4",{style:{fontWeight:"bold"},children:"Billing Address"})}),(0,o.jsx)(p,{ref:this.billingRef,address:e,onChange:s=>{this.setState({billingAddress:s}),this.state.sameAsBilling&&this.setState({shippingAddress:s})}})]}),(0,o.jsxs)("div",{className:"small-12 medium-6 columns",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h4",{style:{display:"inline-block",paddingRight:10,fontWeight:"bold"},children:"Shipping Address"}),(0,o.jsx)("input",{style:{display:"inline-block"},type:"checkbox",onChange:s=>{s.target.checked?this.setState({sameAsBilling:!0,shippingAddress:{...this.state.billingAddress,address_id:(0,i.get)(this.state.shippingAddress,"address_id")}}):this.setState({sameAsBilling:!1})}}),(0,o.jsx)("span",{style:{display:"inline-block"},children:"Same as billing"})]}),(0,o.jsx)(p,{ref:this.shippingRef,address:d,readOnly:s,onChange:s=>{this.setState({shippingAddress:s})}})]})]})}}},59887(s,e,d){d.r(e),d.d(e,{default:()=>c});var i=d(41594),t=d.n(i),a=d(98483),r=d(28027),n=d(39913),l=d(4439),o=d(3375),h=d(63988);class p extends i.Component{constructor(s){super(s),this.formRef=t().createRef()}render(){const{index:s,closePopup:e,identity:d}
1=this.props,{company_id:i,company_billing_address_id:t,company_shipping_address_id:a}=d;return(0,h.jsx)("div",{"data-test-name":"EditCompanyShippingAndBillingPopup.render",className:"reveal large",style:{display:"block",zIndex:r.z+s,overflow:"auto"},"aria-labelledby":"modalTitle","aria-hidden":"true",role:"dialog",children:(0,h.jsxs)("div",{children:[(0,h.jsxs)("div",{className:"small-12 columns",children:[(0,h.jsx)(l.A,{className:"small-3 columns",src:"/images/commonsku-Logo-Dark.png"}),(0,h.jsxs)("div",{className:"small-9 columns",style:{padding:"20px 5px 0 5px"},children:[(0,h.jsxs)("div",{style:{fontWeight:"bold"},children:["Our records indicate we do not have a billing or shipping address on file. ",(0,h.jsx)("br",{}),"Please provide the addresses below:"]}),(0,h.jsx)("div",{children:"PLEASE NOTE: THIS POP-UP WILL CONTINUE UNTIL YOU ENTER YOUR ADDRESS"})]})]}),(0,h.jsx)(o.A,{company_id:i,shipping_address_id:a,billing_address_id:t}),(0,h.jsxs)("div",{className:"small-5 columns small-offset-7",children:[(0,h.jsx)("button",{className:"btn button",style:{marginRight:40},"aria-label":"Close modal",onClick:()=>{e()},children:"Remind me in 2 hours"}),(0,h.jsx)("button",{className:"btn button",onClick:()=>{this.formRef.current.validateAndSave()},children:"Update"})]})]})})}}const c=(0,a.Ng)(s=>{let{identity:e}=s;return{identity:e}},{closePopup:n.fs})(p)}}]);
2//# sourceMappingURL=components-EditCompanyShippingAndBillingPopup.94847b7a.chunk.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.