PageSourceSearch

https://login.commonsku.com/dist/react/components-CopyOrderPopup.9c738cf8.chunk.js

js commonsku.com collected 2026-10-02 03:15:41 UTC 15,473 bytes, 2 lines download raw bytes

1"use strict";(globalThis.__LOADABLE_LOADED_CHUNKS__=globalThis.__LOADABLE_LOADED_CHUNKS__||[]).push([[561],{95517(e,t,s){s.r(t),s.d(t,{default:()=>b});var i=s(22224),r=s(41594),n=s(98483),o=s(26926),l=s(30596),a=s(64669),d=s(1046),p=s(39913),h=s(64490),c=s(89861),m=s(58199),u=s(33872),y=s(51851),_=s(28027),g=s(22078),C=s(28029),S=s(81455),x=s(46490),O=s(44964),P=s(3602),E=s(53787),v=s(63988);const j={PRESENTATION:[{key:"PRESENTATION",value:"Presentation"},{key:"ESTIMATE",value:"Estimate"},{key:"SALES ORDER",value:"Sales Order"},{key:"SHOP",value:"Shop"}],ESTIMATE:[{key:"ESTIMATE",value:"Estimate"},{key:"PRESENTATION",value:"Presentation"},{key:"SALES ORDER",value:"Sales Order"},{key:"SHOP",value:"Shop"}],"SALES ORDER":[{key:"SALES ORDER",value:"Sales Order"},{key:"ESTIMATE",value:"Estimate"},{key:"PRESENTATION",value:"Presentation"},{key:"SHOP",value:"Shop"}],INVOICE:[{key:"INVOICE",value:"Invoice"},{key:"SHOP",value:"Shop"}],SHOP:[{key:"SHOP",value:"Shop"}]},N=[{key:"popup",value:"Popup"},{key:"marketing",value:"Marketing"},{key:"company",value:"Company"},{key:"shopify",value:"Connected"},{key:"pod",value:"Print On Demand"}];class T extends r.Component{constructor(e){super(e),this.handleUpgradeAndClosePopup=()=>{this.props.order.locked&&this.props.onUnlockOrder(this.props.order.order_id),this.props.onClosePopup()},this.state={shop_type:this.props.shop_type,client_id:this.props.order.client_id,order_type:this.props.order_type_to_copy||this.props.upgrade_type||this.props.order.order_type,items:this.props.items.reduce((e,t)=>(e[t.item_id]=!0,e),{}),all_products:!0,accept_shop_charges:!1,has_sage_connect:!1,hasError:!1,hasConvertibleSkus:!1,showNewClientForm:!1,job_name:""},this.onFormRef=this.onFormRef.bind(this),this.handleNewClientClick=this.handleNewClientClick.bind(this),this.handleCreateClient=this.handleCreateClient.bind(this),this.handleCancelNewClient=this.handleCancelNewClient.bind(this),this.handleFieldChange=this.handleFieldChange.bind(this),this.handleQuantityChange=this.handleQuantityChange.bind(this),this.onCopyOrder=this.onCopyOrder.bind(this),this.onToggleItem=this.onToggleItem.bind(this),this.onToggleSelectAll=this.onToggleSelectAll.bind(this),this.renderUpgradeProductWarning=this.renderUpgradeProductWarning.bind(this)}onFormRef(e){this._form=e}componentDidMount(){this.props.loadIndustries(),this.props.onClearStaleShop();const e=this;(0,g.oD)("GET","tenant/is-accepted-shop-charges",{}).then(t=>{let{json:s}=t;e.setState({accept_shop_charges:1==s.accept_shop_charges})});try{(0,g.oD)("GET","tenant/has-sage-connect-service",{}).then(e=>{let{json:t}=e;this.setState({has_sage_connect:t.has_sage_connect_service})})}catch(e){console.error(e)}}handleQuantityChange(e){const t=e.target;this.setState({items:Object.assign({},this.state.items,{[t.name]:t.value})})}handleFieldChange(e,t){if("order_type"===t&&"SHOP"===e)return this.props.onCreateShop(),void this.props.onClosePopup();"order_type"===t&&"PRESENTATION"===this.props.order.order_type&&(-1===["PRESENTATION","SHOP"].indexOf(e)&&-1===["PRESENTATION","SHOP"].indexOf(this.state.order_type)||this.setState({items:this.props.items.reduce((e,t)=>(e[t.item_id]=null,e),{})})),this.setState({[t]:e})}handleNewClientClick(){this.setState({showNewClientForm:!0})}handleCreateClient(e){e?this.setState({client_id:e,showNewClientForm:!1}):this.setState({showNewClientForm:!1})}handleCancelNewClient(){this.setState({showNewClientForm:!1})}onCopyOrder(e,t){if((0,i.find)(t,e=>null!==e))return;const s=this.props.order.items||[],r=s.filter(e=>this.state.items[e.item_id]||"SERVICE"===e.parent_type||"SEPARATOR"===e.parent_type),n=(0,C.zN)(r,s).map(e=>!0===this.state.items[e.item_id]||"SERVICE"===e.parent_type||"SEPARATOR"===e.parent_type?e.item_id:{item_id:e.item_id,quantity:this.state.items[e.item_id]});this.props.onCopyOrder(Object.assign({},e,{client_id:"marketing"===this.state.shop_type?null:this.state.client_id,items:n,shop_type:this.state.shop_type||"popup",source:this.props.source}),e=>this.setState({hasError:e}))}onToggleItem(e){this.setState({items:Object.assign({},this.state.items,{[e.item_id]:!this.state.items[e.item_id]})})}onToggleSelectAll(){const e=Object.values(this.state.items).reduce((e,t)=>
1e||t,!1);this.setState({all_products:!e,items:Object.keys(this.state.items).reduce((t,s)=>(t[s]=!e,t),{})})}renderSelectItem(e,t){const s=e.item_images.map(e=>e.image)[0];return(0,v.jsxs)("tr",{"data-test-name":"CopyOrderPopup.renderSelectItem",style:{display:"table",width:"100%"},children:[(0,v.jsx)("td",{style:{width:"70px",textAlign:"center"},children:(0,v.jsx)("input",{"data-test-id":e.item_id,type:"checkbox",checked:this.state.items[e.item_id],onChange:t=>this.onToggleItem(e)})}),(0,v.jsxs)("td",{children:[(0,v.jsx)("img",{style:{maxWidth:"80px",width:"100%",float:"left",marginRight:"0.1rem"},src:(0,g.AE)(s)}),(0,v.jsx)("span",{children:e.item_name})]})]},e.item_id)}renderUpgradeOption(e,t){const s=(e.options||[]).filter(e=>0===+e.hidden),i=s.length?s.map(s=>(0,v.jsx)(y.o4,{index:t+1,base_item:e,option_item:s,convert:!0,handleChangeQuantity:this.handleQuantityChange},s.item_id)):[(0,v.jsx)(y.o4,{index:t+1,base_item:e,convert:!0,handleChangeQuantity:this.handleQuantityChange},e.item_id)];return(0,v.jsx)("tbody",{"data-test-name":"CopyOrderPopup.renderUpgradeOption",style:{width:"100%"},children:i.concat(e.item_costs.map(t=>(0,v.jsx)(y.oA,{convert:!0,base_item:e,item_cost:t},t.item_cost_id)))},e.item_id)}renderUpgradePresentationHeader(){return(0,v.jsx)("thead",{"data-test-name":"CopyOrderPopup.renderUpgradePresentationHeader",style:{display:"table",width:"100%"},children:(0,v.jsxs)("tr",{children:[(0,v.jsx)("th",{style:{width:"10%"},children:"Quantity"}),(0,v.jsx)("th",{style:{width:"60%"},colSpan:"2",children:"Products"}),(0,v.jsx)("th",{style:{width:"10%"},children:"Units"}),(0,v.jsx)("th",{style:{width:"10%"},children:"Margin"}),(0,v.jsx)("th",{style:{width:"10%"},children:"Amount"})]})})}renderCopyHeader(){const{order:e,items:t,hasInventoryBreakdowns:s,source:i}=this.props,{all_products:r,order_type:n}=this.state,o=Object.values(this.state.items).reduce((e,t)=>e&&t,!0),l=i!==O.POTENTIAL_REPEAT_REPORT_SOURCE&&"PRESENTATION"===e.order_type&&"PRESENTATION"!==n&&"SHOP"!==n;return(0,v.jsx)("thead",{"data-test-name":"CopyOrderPopup.renderCopyHeader",style:{display:"table",width:"100%"},children:0===t.length?(0,v.jsx)("tr",{children:(0,v.jsx)("th",{children:"No products"})}):(0,v.jsxs)("tr",{children:[(0,v.jsx)("th",{style:{width:"70px",textAlign:"center",paddingTop:"12px",paddingBottom:"6px"},children:l?null:(0,v.jsx)("input",{"data-test-id":"select-all-products",type:"checkbox",name:"check-all",checked:o,onChange:this.onToggleSelectAll})}),(0,v.jsxs)("th",{children:[r&&!l?"All ":"","Products",r&&!l&&s&&" (Except Inventoried Products)"]})]})})}getItems(){const{items:e=[]}=this.props;return e.filter(e=>e.item_id)}getItemsWithoutSage(){const{items:e}=this.props,{order_type:t,has_sage_connect:s}=this.state;return e.filter(e=>"SHOP"===t?"sage-products"!==e.copied_from||s:e.item_id)}hasSageProducts(){const{items:e=[]}=this.props,{has_sage_connect:t}=this.state;return e.filter(e=>"sage-products"===e.copied_from&&!t).length>0}renderSageWarning(){const{order_type:e}=this.state;return"SHOP"===e&&this.hasSageProducts()?(0,v.jsx)("div",{className:"row columns",children:(0,v.jsx)("p",{style:{color:"red"},children:"Note: All Sage products will not be converted as per Sage agreement with commonsku"})}):null}renderUpgradeProductWarning(e){const{order:t}=this.props;if(!e&&t.locked)return null;const s=t.locked?(0,v.jsxs)("div",{style:{display:"flex",flexDirection:"column",flexGrow:1},children:[(0,v.jsx)("strong",{children:"This Sales Order includes products eligible for ePO."}),"Unlock and upgrade before copying for live inventory, custom pricing and real-time order updates."]}):(0,v.jsxs)("div",{style:{display:"flex",flexDirection:"column",flexGrow:1},children:[(0,v.jsx)("strong",{children:"This Sales Order includes products eligible for ePO."}),"Upgrade before copying for live inventory, custom pricing and real-time order updates."]});return(0,v.jsx)("div",{"data-test-name":"CopyOrderPopup.renderUpgradeProductWarning",className:"small-12 columns popup-size-limit",style:{marginBottom:"1rem"},children:(0,v.jsx)(P.AlertNotification,{alertType:"warn",children:(0,v.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:8,alignItems:"center",width:"100%"},children:[s,(0,v.jsx)(P.Button,{size:"small",type:"button",onClick:this.handleUpgradeAndClosePo
1pup,children:t.locked?"Unlock":"Review Products"})]})})})}renderUpgradePresentation(){return[(0,v.jsx)("table",{style:{marginBottom:"0px"},children:this.renderUpgradePresentationHeader()},"header"),(0,v.jsxs)("table",{style:{overflowY:"auto",maxHeight:"400px",display:"block"},children:[(0,v.jsx)("thead",{children:(0,v.jsxs)("tr",{style:{height:"0px"},children:[(0,v.jsx)("th",{style:{width:"10%",padding:0}}),(0,v.jsx)("th",{style:{width:"60%",padding:0},colSpan:"2"}),(0,v.jsx)("th",{style:{width:"10%",padding:0}}),(0,v.jsx)("th",{style:{width:"10%",padding:0}}),(0,v.jsx)("th",{style:{width:"10%",padding:0}})]})},"fake-header"),this.getItems().map((e,t)=>this.renderUpgradeOption(e,t))]},"body")]}renderCopy(){const{all_products:e}=this.state;return(0,v.jsxs)("table",{"data-test-name":"CopyOrderPopup.renderCopy",children:[this.renderCopyHeader(),e?null:(0,v.jsx)("tbody",{style:{overflowY:"auto",display:"block",maxHeight:"400px"},children:this.getItems().map((e,t)=>this.renderSelectItem(e,t))})]})}render(){var e;const{order:t,items:s,identity:i,onClosePopup:r,index:n,upgrade_type:o,order_type_options:l,custom_title:p,source:h}=this.props,{all_products:c,order_type:m,shop_type:y,hasError:C,showNewClientForm:S,client_id:x,job_name:E}=this.state,{hasCapabilities:T}=(0,g.el)(i),b=(null==l?void 0:l[t.order_type])||(T(["CREATE-SHOP"],!0)&&this.state.accept_shop_charges?j[t.order_type]:j[t.order_type].filter(e=>"SHOP"!==e.key)),f=T(["FEATURE-ADVANCED","FEATURE-ENTERPRISE"],!0),A=0===t.bulk_update_margin_count&&T(["UNLOCK-SALES-ORDER"],!0),w="pod"===this.props.shop_type?N.filter(e=>"pod"===e.key):N.filter(e=>"pod"!==e.key&&(f||"connected"!==e.key)),k=h!==O.POTENTIAL_REPEAT_REPORT_SOURCE&&"PRESENTATION"===t.order_type&&"PRESENTATION"!==m&&"SHOP"!==m,I="marketing"!==y,R=s||[],H=this.props.hasPSUpgradeProductEnabled&&(null===(e=this.props.convertibleProducts)||void 0===e?void 0:e.length)>0,U=H&&R.some(e=>this.state.items[e.item_id]&&"ps-products"!==e.copied_from&&this.props.convertibleProducts.some(t=>t.promo_api_name===e.promo_api_name&&t.ps_product_id===e.item_sku)),D=!k&&c?"small":"large",F=!I||!!x,B=!!E&&""!==E.trim();return(0,v.jsx)("div",{"data-test-name":"CopyOrderPopup.render",id:"convert-modal",className:`reveal ${D}`,style:{display:"block",zIndex:_.z+n,height:"initial",minHeight:"25rem",overflow:"visible",transition:"width 0.1s, height 0.1s",maxHeight:"min-content"},"data-reveal":!0,"aria-labelledby":"modalTitle","aria-hidden":"true",role:"dialog",children:S?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"row",style:{display:"flex",alignItems:"center"},children:[(0,v.jsx)("div",{className:"small-8 columns",children:(0,v.jsx)("h3",{id:"modalTitle",children:"Create New Client"})}),(0,v.jsx)("div",{className:"small-4 columns",style:{textAlign:"right"},children:(0,v.jsx)(P.Button,{size:"small",variant:"text",onClick:this.handleCancelNewClient,children:"← Back to Copy Order"})})]}),(0,v.jsx)("div",{className:"row popup-content form",children:(0,v.jsx)("div",{className:"small-12 columns",children:(0,v.jsx)(d.A,{onCreate:this.handleCreateClient})})})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)("div",{className:"row",children:[(0,v.jsx)("div",{className:"small-12 columns",children:(0,v.jsx)("h3",{id:"modalTitle",children:p||`Copy ${(0,g.nx)(t.order_type)}`})}),C?(0,v.jsx)(P.AlertNotification,{alertType:"error",className:"small-12 columns",style:{marginBottom:"1rem"},children:"Copying items failed. Please wait and try again. If the issue continues, contact support."}):null,"INVOICE"===m?(0,v.jsx)("div",{className:"small-12 columns",style:{marginBottom:"1rem"},children:"Copied invoices cannot have bills and commissions. If you require bills and commissions, copy the sales order and upgrade it to an invoice."}):null,H&&this.renderUpgradeProductWarning(A)]}),(0,v.jsxs)(u.A,{className:"row popup-content form",ref:this.onFormRef,object:{order_id:t.order_id,order_type:m,shop_type:y},onFieldChange:this.handleFieldChange,onSubmit:this.onCopyOrder,style:{overflow:"visible"},children:[o?null:(0,v.jsx)(u.A.Select,{label:"Type",field:"order_type",value:m,options:b,required:!0,disabled:"SHOP"===o,inputId:"select-order_type",instanceId:"select-instance-order_type",classNamePrefix:"select-order_type",withMarginBottom:!0}),"SHOP"===o&&"SHOP"===t.order_type?(0,v.jsx)(u.A.Select,{label:"Type",field:"shop_type",value:"connected"!==y||f?y:"popup",options:w,required:!0,inputId:"select-shop_type",instanceId:"select-instance-shop_type",classNamePrefix:"select-shop_type",withMarginBottom:!0}):null,I?(0,v.jsx)(a.A,{horizontal:!0,label:"Client",name:"client_id",value:this.state.client_id,onChange:e=>{var t;return this.handleFieldChange(null!==(t=null==e?void 0:e.value)&&void 0!==t?t:"","client_id")},onClickNewClient:this.handleNewClientClick}):null,(0,v.jsx)(u.A.TextInput,{label:"SHOP"===m?"Shop Name":"Project Name","data-testid":"select-job_name",field:"job_name",value:this.state.job_name,required:!0,placeholder:"SHOP"===m?"New Shop Name":"New Project Name"}),(0,v.jsx)("div",{className:"small-12 columns popup-size-limit",children:k?this.renderUpgradePresentation():this.renderCopy()}),(0,v.jsxs)("div",{className:"small-12 columns popup-size-limit",style:{display:"flex",justifyContent:"end",gap:8},children:[(0,v.jsx)(P.Button,{size:"medium",variant:"text",onClick:()=>r(),children:"Cancel"}),(0,v.jsx)(P.Button,{size:"medium",disabled:!(F&&B),onClick:e=>{e.preventDefault(),this._form&&this._form.submit()},children:U?"Copy without ePO":"Copy"})]})]})]})})}}const b=(0,n.Ng)((e,t)=>{var s;const i=["PRESENTATION","SHOP"].includes(t.order.order_type)?"OPTION":"PRODUCT",r=(0,o.P7)(e,{form_number:t.order.form_number,order_type:t.order.order_type}),n=r.items||[],a="SALES ORDER"===r.order_type;return{clients:(0,l.y$)(e),order:r,items:n.filter(e=>!e.hasInventoryBreakdowns&&0===+e.hidden&&e.parent_type===i),identity:e.identity,hasInventoryBreakdowns:n.filter(e=>!!e.hasInventoryBreakdowns).length>0,hasPSUpgradeProductEnabled:a,convertibleProducts:(null===(s=e.entities.convertibleProducts)||void 0===s?void 0:s.products)||[]}},(e,t)=>({loadIndustries:()=>e((0,m.bqZ)()),onCopyOrder:(s,i)=>{let{items:r,order_id:n,job_name:o,client_id:l,order_type:a,shop_type:d,source:c}=s;return e((0,p.AD)("SHOP"===a?"Copying Shop...":"Copying Order...")),e((0,h.MD)(n,o,l,a,r,d,c)).then(s=>{if(!s)return c===O.POTENTIAL_REPEAT_REPORT_SOURCE&&i(!0),void e((0,p.fs)());c===O.POTENTIAL_REPEAT_REPORT_SOURCE&&t.order_type_to_copy&&"object"==typeof s&&(e((0,p.fs)()),e((0,p.fs)()),e((0,S.KS)({orderId:String(n),actionType:x.mapOrderTypeToAction[t.order_type_to_copy],formNumber:s.form_number,jobNumber:s.job_number})))})},onClosePopup:()=>{e((0,p.fs)())},onCreateShop:()=>e((0,c.Qg)("create_shop",t.order)),onClearStaleShop:()=>e((0,c.mA)("create_shop")),onUnlockOrder:t=>{e((0,E.iY)(t,"locked",1,0))}}))(T)}}]);
2//# sourceMappingURL=components-CopyOrderPopup.9c738cf8.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.