PageSourceSearch

https://get.checkfront.com/lib/vite/BuilderUpsells-63223a8d.js

js checkfront.com collected 2026-09-24 15:21:41 UTC 13,102 bytes, 1 lines download raw bytes

1var Y=Object.defineProperty;var Z=(s,o,l)=>o in s?Y(s,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[o]=l;var x=(s,o,l)=>(Z(s,typeof o!="symbol"?o+"":o,l),l);import{P as t,w as y,e as ee,j as e,c as a,F as v,S as te}from"./componentLoader.jsx-2026.09.09-3cefc4ce.js";import{r as p,l as le}from"./logger-3e1e3eff.js";import{a as re}from"./index-213dd4d3.js";import{G as i}from"./Grid-63374a37.js";import{H as A}from"./Heading-45ab5a28.js";import{T as L}from"./Toggle-6d42fad4.js";import{B as se}from"./BuilderContentsLayout-29ce1ec8.js";import{i as D}from"./isEqual-8f2d02ec.js";import{c as oe}from"./cloneDeep-02f21378.js";import{u as ne}from"./index-2089c6e8.js";import{M as k}from"./Modal-25e86be7.js";import{T as h}from"./TextStyle-014c4a6a.js";import{t as ie}from"./toNumber-8f88376b.js";import{F as ce}from"./FormLayout-644dabe8.js";import{T as M}from"./TextField-3930079d.js";import{D as H}from"./DropDown2-ecd6eae7.js";import{aM as w,aR as I,aS as pe,bP as ae}from"./constants-9e5fc5e0.js";import"./index-e642497c.js";import"./_Uint8Array-4a201bc7.js";import"./_equalByTag-f809a93d.js";import"./index-6a18cc6d.js";import{L as de}from"./List-3d3404f0.js";import{B as ue}from"./ButtonGroup-b00430ce.js";import{B as P}from"./Button-ad9712a3.js";import{I as me}from"./Icon-a1844e0f.js";import{E as he}from"./Edit-1d071c82.js";import{T as fe}from"./Trash-83186639.js";import{S as ge}from"./PlusCircle-d9b3a71f.js";import{I as Ce}from"./IconButton-b18cf368.js";import{E as j}from"./Link-0005ddf4.js";import{E as Te}from"./EmptyState-53c9c04c.js";import{L as Se}from"./ProductBuilderRouter-514bb04d.js";import"./vendor-21ae10b1.js";import"./brand-387037d2.js";import"./universe.js-2026.09.09-3cefc4ce.js";import"./index-33a30c39.js";import"./Title-bc4116fa.js";import"./_baseIsEqual-8f542891.js";import"./_getAllKeys-a79fe303.js";import"./_isIndex-1f105582.js";import"./_baseClone-a0680933.js";import"./_baseAssignValue-ed5c7dbb.js";import"./_defineProperty-27e63e7c.js";import"./eq-9168d086.js";import"./isSymbol-34885b27.js";import"./react-router-dom-6e2566f9.js";import"./hoist-non-react-statics.cjs-3f8ebaa8.js";import"./objectWithoutPropertiesLoose-4f48578a.js";import"./createAxiosInstance-650ff559.js";import"./index-2506ba77.js";import"./omit-abc9bd77.js";import"./toString-4b4600cf.js";import"./_baseIteratee-2da5a91f.js";import"./_baseSlice-35988e44.js";import"./isPlainObject-b126badf.js";import"./flatten-a652afe7.js";import"./_setToString-74030a2f.js";import"./skuHelper-00d76e9e.js";import"./richTextEditorFunctions-9e6dc16b.js";import"./uniqWith-e6899964.js";import"./_baseUniq-21d7e434.js";import"./uniq-942e3a3d.js";import"./_arrayReduce-4ab62823.js";import"./_baseEach-5996395c.js";import"./constants-b445ac4b.js";const ye=s=>p.createElement("svg",{width:256,height:256,viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg",...s},p.createElement("g",{fill:"none"},p.createElement("path",{d:"M128 0C57.308 0 0 57.308 0 128c0 70.694 57.308 128 128 128 70.692 0 128-57.306 128-128C256 57.308 198.692 0 128 0z",fill:"#F3F9FD"}),p.createElement("path",{d:"M129.956 121.556c17.134 0 31.073-13.94 31.073-31.073 0-17.134-13.94-31.073-31.073-31.073-17.134 0-31.073 13.939-31.073 31.073s13.94 31.073 31.073 31.073zM111.683 87.57h15.36V72.21a2.56 2.56 0 1 1 5.12 0v15.36h15.36a2.56 2.56 0 1 1 0 5.12h-15.36v15.36a2.56 2.56 0 1 1-5.12 0V92.69h-15.36a2.56 2.56 0 1 1 0-5.12z",fill:"#32A7D9"}),p.createElement("path",{d:"M128 198.144H84.992c-16.092 0-29.184-13.092-29.184-29.184s13.092-29.184 29.184-29.184H128c16.092 0 29.184 13.092 29.184 29.184S144.092 198.144 128 198.144zm-43.008-49.152c-11.01 0-19.968 8.958-19.968 19.968s8.958 19.968 19.968 19.968H128c11.01 0 19.968-8.958 19.968-19.968S139.01 148.992 128 148.992H84.992z",fill:"#C2C7CD"}),p.createElement("path",{d:"M171.008 139.776H128c-16.092 0-29.184 13.092-29.184 29.184 0 7.727 3.04 14.742 7.959 19.968H128c-11.01 0-19.968-8.958-19.968-19.968s8.958-19.968 19.968-19.968h43.008c11.01 0 19.968 8.958 19.968 19.968s-8.958 19.968-19.968 19.968H149.25c-5.325 5.667-12.878 9.216-21.25 9.216h43.008c16.092 0 29.184-13.092 29.184-29.184s-13.092-29.184-29.184-29.184z",fill:"#E2E4E7"}),p.createElement("path",{d:"M149.225 148.992H128c5.645 0 10.74 2.365 14.375 6.144h11.318a29.323 29.323 0 0 0-4.468-6.144z",fill:"#939CA7"}))),be={name:t.string,priceOverridePercentage:t.oneOfType([t.number,t.string]),preselected:t.bool,dateRestriction:t.string,restrictGuestTypeAdjustment:t.bool,handleChange:t.func,translations:t.object};function O({name:s,priceOverridePercentage:o,preselected:l,dateRestriction:r,restrictGuestTypeAdjustment:c,handleChange:f,translations:n}){const g=ee(),C=[{value:"false",label:n.optionalDropdown},{value:"true",label:n.preselectDropdown}
1],T=[{value:w,label:n.unrestricted},{value:I,label:n.useParentDates},{value:pe,label:n.withinParentDates}];return e(k.Section,{customClass:"bg-color-white",children:a(ce,{children:[a("div",{children:[e(A,{element:"h3",children:s}),e(h,{customClass:"font-size-2 font-color-grey-400",children:n.attachedItemHelpText})]}),a("div",{children:[e(i.Row,{children:e(i.Col,{col:"4",children:e(M,{id:"pricePercentage",name:"pricePercentage",label:n.pricePercentage,onChange:d=>{f(d.length?Math.abs(ie(d)):"","priceOverridePercentage")},value:o,suffix:"%",type:"number",placeholder:"0"})})}),e(h,{customClass:"font-size-2 font-color-grey-400",children:n.pricePercentageHelpText})]}),e(i.Row,{children:e(i.Col,{children:e(H,{id:"preselected",name:"preselected",label:n.optIn,options:C,value:l?"true":"false",onChange:d=>{f(d.value=="true","preselected")},menuPortal:!0,inputText:n.optInHelpText})})}),e(i.Row,{children:e(i.Col,{children:e(H,{id:"selectUpsellDates",name:"selectUpsellDates",label:n.dateOptionsLabel,options:T,value:r||w,onChange:d=>{f(d.value,"dateRestriction")},menuPortal:!0,inputText:r===w?n.unrestrictedHelpText:r===I?n.useParentDatesHelpText:n.withinParentDatesHelpText})})}),g.restrictUpsellGuestTypeAdjustment&&a(v,{children:[e(i.Row,{children:e(i.Col,{children:e(L,{id:"guestTypeAdjustment",name:"guestTypeAdjustment",label:n.guestTypeAdjustment,on:c,onToggle:()=>{f(!c,"restrictGuestTypeAdjustment")},menuPortal:!0})})}),e(i.Row,{children:e(i.Col,{children:e(h,{children:c?n.guestTypeAdjustmentRestricted:n.guestTypeAdjustmentUnrestricted})})})]})]})})}O.propTypes=be;const Ee=y(O),ve={upsellProduct:t.object,upsell:t.object,hideUpsellModal:t.func,handleSave:t.func,active:t.bool,translations:t.object};function U(s=null){return{name:"",preselected:!1,priceOverridePercentage:"",dateRestriction:w,restrictGuestTypeAdjustment:!1,guestTypesMap:[],addonId:s}}class $ extends p.Component{constructor(l){super(l);x(this,"handleClose",()=>{this.props.hideUpsellModal(),this.setState({upsell:U()})});this.state={upsell:this.props.upsell?this.props.upsell:U()}}async componentDidUpdate(l){const{upsellProduct:r,upsell:c}=this.props;r&&c&&!D(r,l.upsellProduct)?this.setState({upsell:oe(c)}):r&&!D(r,l.upsellProduct)&&this.setState({upsell:U(r.productId,r.guestTypes)})}async handleSave(){this.props.handleSave({...this.state.upsell,isUpsell:!0}),this.setState({upsell:U()})}handleChange(l,r){const c=ne(this.state,{upsell:{[r]:{$set:l}}});this.setState(c)}canSave(){return!0}render(){const{active:l,translations:r,upsellProduct:c}=this.props;if(!c)return e(v,{});const{preselected:f,priceOverridePercentage:n,dateRestriction:g,restrictGuestTypeAdjustment:C}=this.state.upsell,T=c?c.name:"",d=this.canSave(),u=[{content:r.cancel,onClick:this.handleClose},{content:r.submit,primary:!0,disabled:!d,onClick:()=>{this.handleSave()}}];return e(k,{heading:r.packageItem,active:l,actions:u,customClass:"bg-color-grey-100",children:e(Ee,{preselected:f,priceOverridePercentage:n,dateRestriction:g,restrictGuestTypeAdjustment:C,name:T,handleChange:(S,b)=>{this.handleChange(S,b)}})})}}$.propTypes=ve;const Pe=y($);function Ue(s){return({name:o})=>o.toLowerCase().includes(s.toLowerCase())}function we(s){return({productId:o})=>s.findIndex(({addonId:l})=>l==o)>-1}function Re(s,o,l,r){let c=o;return r=="added"&&(c=o.filter(we(s))),l&&(c=c.filter(Ue(l))),c}const xe={product:t.shape({productId:t.number,name:t.string,allocation:t.string}),upsell:t.shape({preselected:t.bool,priceOverridePercentage:t.oneOfType([t.number,t.string])}),handleClickProduct:t.func,handleRemoveUpsell:t.func,translations:t.object};function F({product:{productId:s,name:o,allocation:l},upsell:r,handleClickProduct:c,handleRemoveUpsell:f,translations:n}){return a(i.Row,{noGutters:!0,customClass:"margin-x-2 padding-y-1 border-bottom-style-solid border-bottom-width-thin border-bottom-color-grey-200",children:[e(i.Col,{col:"2",alignSelf:"center",customClass:"padding-left-2",children:e(h,{children:o})}),e(i.Col,{col:"2",alignSelf:"center",children:r&&e(h,{children:`${r.priceOverridePercentage||0}%`})}),e(i.Col,{col:"2",alignSelf:"center",children:r&&e(h,{children:r.preselected?n.preselected:n.optional})}),e(i.Col,{alignSelf:"center",col:"2",offset:"1",children:e(h,{children:ae.find(g=>g.value==l).label})}),e(i.Col,{col:"auto",alignSelf:"center",children:r?a(p.Fragment,{children:[e(P,{icon:e(he,{}),flat:!0,onClick:c,children:e(h,{customClass:"padding-left-1",children:n.editUpsell})}),e(Ce,{color:"red",customClass:"padding-left-2",onClick:f,children:e(fe,{})})]}):e(P,{icon:e(me,{color:"green",children:e(ge,{})}),flat:!0,onClick:c,children:e(h,{customClass:"padding-left-1",children:n.createUpsell})})})]},s)}F.propTypes=xe;const De=y(F),He={translations:t.object};function _({translations:s}){return a(i.Row,{noGutters:!0,customClass:"margin-x-2 padding-y-1",children:[e(i.Col,{col:"2",customClass:"padding-left-2",children:e(h,{strong:!0,children:s.name})}),e(i.Col,{col:"2",children:e(h,{strong:!0,children:s.pricePercentage})}),e(i.Col,{col:"2",children:e(h,{strong:!0,children:s.preselected})}),e(i.Col,{col:"2",offset:"1",children:e(h,{strong:!0,children:s.allocation})})]})}
1_.propTypes=He;const Ie=y(_),je={show:t.string,setShow:t.func,translations:t.shape({upsellsEsTitle:t.string,upsellsEsHelpLink:t.string,upsellsEsDescription:t.string,noUpsellsEsTitle:t.string,noUpsellsEsAction:t.string,noUpsellsEsDescription:t.string})};function z({show:s,setShow:o,translations:l}){const r=s=="all";return e(Te,{illustration:e(ye,{}),imageSize:"medium",title:r?l.upsellsEsTitle:l.noUpsellsEsTitle,actions:r?e(j,{external:!0,url:"https://support.checkfront.com/hc/en-us/",children:l.upsellsEsHelpLink}):a(v,{children:[e(P,{customClass:"display-block margin-bottom-2",onClick:()=>{o("all")},children:l.noUpsellsEsAction}),e(j,{external:!0,url:"https://support.checkfront.com/hc/en-us/",children:l.upsellsEsHelpLink})]}),customClass:"margin-y-3",children:l.noUpsellsEsDescription})}z.propTypes=je;const Ae=y(z),Le={searchString:t.string,setSearchString:t.func,show:t.string,setShow:t.func,products:t.array,upsells:t.array,translations:t.object,handleClickProduct:t.func,handleRemoveUpsell:t.func};function B({searchString:s,show:o,setSearchString:l,setShow:r,upsells:c,products:f,handleRemoveUpsell:n,handleClickProduct:g,translations:C}){const T=c.filter(({deleted:u})=>!u),d=Re(T,f,s,o);return a(v,{children:[a(i.Row,{customClass:"padding-bottom-4 margin-right-2 justify-content-between",children:[e(i.Col,{col:"4",children:e(M,{id:"upsells-search",label:C.search,name:"search",value:s,onChange:u=>{l(u)}})}),e(i.Col,{col:"auto",alignSelf:"end",children:a(ue,{segmented:!0,children:[e(P,{primary:o=="all",onClick:()=>{r("all")},children:C.all}),e(P,{primary:o=="added",onClick:()=>{r("added")},children:C.added})]})})]}),d.length>0?a(v,{children:[e(Ie,{}),e(de,{children:d.map(u=>{const S=T.find(b=>b.addonId==u.productId);return e(De,{product:u,upsell:S,handleClickProduct:()=>{g(u,S)},handleRemoveUpsell:()=>{n(S)}},u.productId)})})]}):e(Ae,{show:o,setShow:r})]})}B.propTypes=Le;const ke=y(B),Me={handleChangeUpsell:t.func,upsells:t.array,product:t.shape({name:t.string,productId:t.number}),translations:t.object};function G({product:{productId:s},upsells:o,handleChangeUpsell:l,translations:r}){const[c,f]=p.useState([]),[n,g]=p.useState(!0),[C,T]=p.useState(!1),[d,u]=p.useState(null),[S,b]=p.useState(null),[N,V]=p.useState(""),[q,W]=p.useState("all");async function J(){try{const{data:{data:m}}=await re("/api/4.0/internal/products?status=unarchived&limit=500"),E=m.filter(X=>X.productId!=s);f(E),g(!1)}catch(m){le.notice({subject:"There was a problem retrieving all Products",context:m})}}p.useEffect(()=>{J()},[]);function K(m,E){T(!0),u(m),b(E)}function R(){T(!1),u(null),b(null)}function Q(m){R(),l(m)}return n?e(te,{}):a(se,{showHeader:!0,helpContents:Se,children:[e(ke,{products:c,upsells:o,searchString:N,show:q,setSearchString:V,setShow:W,handleClickProduct:(m,E)=>{K(m,E)},handleRemoveUpsell:m=>{l({...m,deleted:!0})}}),e(i.Row,{customClass:"padding-top-6",children:a(i.Col,{children:[e(A,{element:"h3",children:r.showUpsellsStartingPrice}),e(L,{id:"upsells",label:r.upsells,labelHidden:!0,customClass:"padding-top-3",disabled:!0})]})}),e(Pe,{upsellProduct:d,upsell:S,active:C,hideUpsellModal:()=>{R()},handleSave:m=>{Q(m)}})]})}G.propTypes=Me;const Kt=y(G);export{Kt 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.