PageSourceSearch

https://login.commonsku.com/dist/react/DistributorAddressesApp.65bc413c.chunk.js

js commonsku.com collected 2026-10-02 03:13:58 UTC 9,286 bytes, 53 lines download raw bytes

1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[375],{3375(s,e,d){d.d(e,{A:()=>h});var i=d(22224),t=d(41594),a=d.n(t),n=d(22078),r=d(39054),l=d(73882),o=d(63988);const p=()=>(0,o.jsx)("div",{"data-test-name":"Mandatory",style:{display:"inline-block",padding:5,width:3,height:3,verticalAlign:"top"},children:"*"});class c extends t.Component{constructor(s){super(s),this.countryOptions=r.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:n}=this.state,r=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%",...n[e]&&!d?{borderColor:"red"}:{}},onChange:s=>{this.handleAddressChange({[e]:s.target.value},{[e]:r&&(0,i.isEmpty)(s.target.value)})},disabled:d,value:a[e]||"",...t}),r&&(0,o.jsx)(p,{})]})}render(){const{readOnly:s=!1,address:e={}}=this.props,{errors:d}=this.state,t=(0,i.get)(r.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)(p,{})]}),(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)(p,{},"mandatory")]}),this.renderInput({field:"address_postal",placeholder:"ZIP/Postal Code",readOnly:s})]})}}class h 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,n.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,n.oD)("PUT",`address/${s.address_id}`,{...s,parent_id:e}):await(0,n.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)(c,{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)(c,{ref:this.shippingRef,address:d,readOnly:s,onChange:s=>{this.setState({shippingAddress:s})}})]})]})}}},99373(s,e,d){d.d(e,{A:()=>n});var i=d(41594),t=d(23652),a=d(63988);const n=(0,t.default)(s=>{let{className:e,style:d}=s;const t=(0,i.useRef)(null);return(0,i.useEffect)(()=>{const s=document.getElementById("tools-nav");s.style.display="inline-block",t.current.append(s)},[]),(0,a.jsx)("div",{ref:t,className:e,style:d})})`
2  &&& {
3    #tools-nav {
4      height: 150px;
5      
6      .cs-header {
7        h1 {
8          font-size: 32px;
9          color: #555;
10          font-family: museo-slab,sans-serif;
11        }
12      }
13      
14      .cs-nav {
15        height: 34px;
16
17        ul {
18          margin: 0;
19          list-style: none;
20
21          li {
22            display: inline-block;
23            border: 0;
24            margin-left: -4px;
25            border-bottom: 1px solid #eaeaea;
26
27            a {
28              color: #5ba0b4;
29              display: inline-block;
30              padding: 9px 7px;
31              text-decoration: none;
32              white-space: nowrap;
33              padding-bottom: 6px;
34              font-size: 14px;
35            }
36
37            a:hover {
38              padding-bottom: 3px;
39              border-bottom: 3px solid #d8ecf1;
40            }
41          }
42
43          li.active a {
44            font-weight: 700;
45            border-bottom: 3px solid #5ba0b4;
46            padding-bottom: 3px;
47          }
48        }
49      }
50    }
51  }
52`},81880(s,e,d){d.r(e),d.d(e,{default:()=>_});var i=d(22224),t=d(41594),a=d(98483),n=d(22078),r=d(26926),l=d(3375),o=d(2596),p=d(28420),c=d(73882),h=d(97728),g=d(73021),u=d(51904),m=d(99373),y=d(63988);const _=(0,a.Ng)((s,e)=>({popups:(0,r.ag)(s)}))(s=>{let{popups:e,dispatch:d}=s;const[a,r]=(0,t.useState)([]),[_,b]=(0,t.useState)(),[x,A]=(0,t.useState)(),[v,j]=(0,t.useState)({}),f=(0,t.useRef)(null);return(0,t.useEffect)(()=>{(0,n.oD)("GET","company/csku-distributors",{}).then(s=>{r((0,i.keyBy)((0,i.get)(s,["json","companies"],[]),"company_id"))})},[]),(0,y.jsxs)(o.A,{"data-test-name":"DistributorAddressApp",children:[(0,y.jsx)(g.A,{}),(0,y.jsx)(u.A,{popups:e,children:(0,y.jsxs)("div",{className:"main-content",children:[(0,y.jsx)("div",{className:"row",children:(0,y.jsx)(m.A,{})}),(0,y.jsxs)("div",{className:"row",children:[(0,y.jsx)("div",{className:"columns small-6",children:(0,y.jsx)(c.A,{placeholder:"Select a distributor",options:(0,i.filter)((0,i.map)(a,(s,e)=>{let{company_name:d,billing_address_id:i,shipping_address_id:t}=s;return!(v.withoutShipping&&t||v.withoutBilling&&i)&&{key:e,value:d}}),Boolean),value:(0,i.get)(_,"company_id"),change:s=>{b(a[s])}})}),(0,y.jsxs)("div",{className:"columns small-3",children:[(0,y.jsx)("input",{style:{display:"inline-block"},type:"checkbox",onChange:s=>{j({...v,withoutShipping:s.target.checked})}}),(0,y.jsx)("span",{style:{display:"inline-block"},children:"no shipping"})]}),(0,y.jsxs)("div",{className:"columns small-3",children:[(0,y.jsx)("input",{style:{display:"inline-block"},type:"checkbox",onChange:s=>{j({...v,withoutBilling:s.target.checked})}}),(0,y.jsx)("span",{style:{display:"inline-block"},children:"no billing"})]})]}),_&&(0,y.jsxs)("div",{className:"row",children:[(0,y.jsx)(l.A,{ref:f,...(0,i.pick)(_,["company_id","billing_address_id","shipping_address_id"])}),(0,y.jsx)("div",{className:"columns small-4 offset-6",children:x?(0,y.jsx)(h.A,{}):(0,y.jsx)("button",{className:"btn button",onClick:async()=>{A(!0);const{billingAddress:s,shippingAddress:e}=await f.current.validateAndSave()||{},d={..._,billing_address_id:(0,i.get)(s,"address_id"),shipping_address_id:(0,i.get)(e,"address_id")};b(d),r({...a,[_.company_id]:d}),A(!1)},children:"Update"})})]})]})}),(0,y.jsx)(p.A,{popups:e})]})})}}]);
53//# sourceMappingURL=DistributorAddressesApp.65bc413c.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.