(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2757],{62705:function(e,t,r){var n=r(55639).Symbol;e.exports=n},44239:function(e,t,r){var n=r(62705),a=r(89607),i=r(2333),o=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":o&&o in Object(e)?a(e):i(e)}},27561:function(e,t,r){var n=r(67990),a=/^\s+/;e.exports=function(e){return e?e.slice(0,n(e)+1).replace(a,""):e}},31957:function(e,t,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},89607:function(e,t,r){var n=r(62705),a=Object.prototype,i=a.hasOwnProperty,o=a.toString,s=n?n.toStringTag:void 0;e.exports=function(e){var t=i.call(e,s),r=e[s];try{e[s]=void 0;var n=!0}catch(e){}var a=o.call(e);return n&&(t?e[s]=r:delete e[s]),a}},2333:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},55639:function(e,t,r){var n=r(31957),a="object"==typeof self&&self&&self.Object===Object&&self,i=n||a||Function("return this")();e.exports=i},67990:function(e){var t=/\s/;e.exports=function(e){for(var r=e.length;r--&&t.test(e.charAt(r)););return r}},23279:function(e,t,r){var n=r(13218),a=r(7771),i=r(14841),o=Math.max,s=Math.min;e.exports=function(e,t,r){var l,u,c,d,m,p,f=0,h=!1,b=!1,x=!0;if("function"!=typeof e)throw TypeError("Expected a function");function v(t){var r=l,n=u;return l=u=void 0,f=t,d=e.apply(n,r)}function g(e){var r=e-p,n=e-f;return void 0===p||r>=t||r<0||b&&n>=c}function y(){var e,r,n,i=a();if(g(i))return j(i);m=setTimeout(y,(e=i-p,r=i-f,n=t-e,b?s(n,c-r):n))}function j(e){return(m=void 0,x&&l)?v(e):(l=u=void 0,d)}function k(){var e,r=a(),n=g(r);if(l=arguments,u=this,p=r,n){if(void 0===m)return f=e=p,m=setTimeout(y,t),h?v(e):d;if(b)return clearTimeout(m),m=setTimeout(y,t),v(p)}return void 0===m&&(m=setTimeout(y,t)),d}return t=i(t)||0,n(r)&&(h=!!r.leading,c=(b="maxWait"in r)?o(i(r.maxWait)||0,t):c,x="trailing"in r?!!r.trailing:x),k.cancel=function(){void 0!==m&&clearTimeout(m),f=0,l=p=u=m=void 0},k.flush=function(){return void 0===m?d:j(a())},k}},13218:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},37005:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},33448:function(e,t,r){var n=r(44239),a=r(37005);e.exports=function(e){return"symbol"==typeof e||a(e)&&"[object Symbol]"==n(e)}},7771:function(e,t,r){var n=r(55639);e.exports=function(){return n.Date.now()}},14841:function(e,t,r){var n=r(27561),a=r(13218),i=r(33448),o=0/0,s=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return o;if(a(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=a(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=n(e);var r=l.test(e);return r||u.test(e)?c(e.slice(2),r?2:8):s.test(e)?o:+e}},31365:function(e,t,r){e.exports=r(45104)},46747:function(e,t,r){"use strict";r.d(t,{X:function(){return u}});var n=r(85893),a=r(67294),i=r(87536),o=r(79734),s=r(23279),l=r.n(s);let u=e=>{var t;let{name:r,type:s,label:u,className:c,placeholder:d,disabled:m,readOnly:p,validations:f}=e,{resetField:h,getFieldState:b,watch:x,register:v,setValue:g,unregister:y,formState:{errors:j},trigger:k}=(0,i.Gc)();f?v(r,f):v(r);let N=x(r);(0,a.useEffect)(()=>{N&&!N.trim().length&&h(r)},[r,N,h]);let _=!!(null===(t=function e(t,r,n){let a=Array.isArray(r)?r:r.replace(/(\[(\d)\])/g,".$2").replace(/^\./,"").split(".");return a[0]in t?(t=t[a[0]])&&a.length>1?e(t,a.slice(1),n):t:n}(j,r,""))||void 0===t?void 0:t.message),[w,E]=(0,a.useState)(N||""),[S,T]=(0,a.useState)(),[q,C]=(0,a.useState)(!1),{invalid:L,error:F}=b(r),P=(0,a.useCallback)(l()(()=>k(r),500),[r]);return(0,a.useEffect)(()=>{C(L),T(null==F?void 0:F.message)},[_,r,null==F?void 0:F.message]),(0,a.useEffect)(()=>()=>y(r),[r,y]),(0,a.useEffect)(()=>{E(N)},[N]),(0,n.jsx)(o.n,{onChange:e=>{_&&h(r),g(r,e,{shouldDirty:!0}),E(e),P()},value:w||N||"",name:r,type:s,className:c,placeholder:d,label:u,disabled:m,readOnly:p,invalid:q,error:S})}},58280:function(e,t,r){"use strict";r.d(t,{H:function(){return l}});var n=r(85893),a=e=>{let{...t}=e;return(0,n.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",...t,children:(0,n.jsx)("path",{d:"M5 12H19",stroke:"currentColor",strokeWidth:t.isHomeBrand?"3":"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},i=e=>{let{...t}=e;return(0,n.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",...t,children:[(0,n.jsx)("path",{d:"M12 5V19",stroke:"currentColor",strokeWidth:t.isHomeBrand?"3.0":"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M5 12H19",stroke:"currentColor",strokeWidth:t.isHomeBrand?"3.0":"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})},o=r(96231),s=r.n(o);let l=e=>{let{name:t,value:r,onChange:o,min:l=1,max:u=1e5,disabled:c,type:d="text",className:m="w-full",qtyBtnClass:p,trackInventoryLevels:f=!0,isHomeBrand:h}=e,b=async e=>{o(String(Number(r)+e))},x=e=>{let{name:t}=e.currentTarget;"increase"===t?b(1):b(-1)};return(0,n.jsxs)("div",{className:"".concat(m," ").concat(s().root),children:[(0,n.jsx)("button",{name:"decrease","aria-label":"decrease product quantity by one","data-testid":"decrease-quantity",type:"button",onClick:x,className:"".concat(s().button," rounded-l-brand ").concat(p),disabled:c||r<=l,children:(0,n.jsx)(a,{isHomeBrand:h,className:"w-5 h-5 text-quantity-selection-button"})}),(0,n.jsx)("input",{"aria-label":"product quantity input",name:t,className:s().input,onChange:e=>{let{value:t}=e.currentTarget;o(t.replace(/[^0-9]/g,""))},value:r||1,type:d,max:u,min:l}),(0,n.jsx)("button",{name:"increase",type:"button","aria-label":"increase product quantity by one","data-testid":"increase-quantity",onClick:x,className:"".concat(s().button," rounded-r-brand ").concat(p),disabled:c||r<l||r>=u&&u<10&&f,children:(0,n.jsx)(i,{isHomeBrand:h,className:"w-5 h-5 text-quantity-selection-button"})})]})}},79734:function(e,t,r){"use strict";r.d(t,{n:function(){return s}});var n=r(85893),a=r(67294),i=r(64783),o=r.n(i);let s=e=>{var t;let{onChange:r,value:i,name:s,type:l="text",className:u="w-full",placeholder:c,label:d,disabled:m=!1,readOnly:p=!1,invalid:f,error:h,ariaLabel:b}=e,[x,v]=(0,a.useState)(!1),g=(0,a.useRef)(null);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"\n          ".concat(u).concat(x||(null===(t=g.current)||void 0===t?void 0:t.value)||i?" active":"","\n          ").concat(d?" floatLabelWrapper":"","\n          ").concat(f?" invalid":"","\n        "),"aria-invalid":f?"true":"false",children:[d&&(0,n.jsx)("label",{className:"floatLabel".concat(f?" invalid":""," ").concat(o().priceFilterLabel),htmlFor:s,children:d}),(0,n.jsx)("input",{className:"".concat(o().root," ").concat(f?o().invalid:""," ").concat(c?o().placeholder:""),type:l,id:s,"aria-label":b,ref:g,placeholder:c,disabled:m,readOnly:p,value:i,onChange:e=>{let{value:t}=e.currentTarget;r(t)},onFocus:()=>{v(!0)},onBlur:()=>{v(!1)}})]}),f&&(0,n.jsx)("p",{className:o().errorMessage,"data-testid":"".concat(s,"-error"),children:h})]})}},32677:function(e,t,r){"use strict";r.d(t,{G:function(){return p}});class n extends Error{}var a=r(83454);let i=e=>"".concat(JSON.stringify(a.env)," ").concat(e.join(", ")," must have a value before running the Framework.");class o extends Error{}var s=r(31365),l=r(83454),u=(e,t)=>{let r=e[t];if(void 0===r&&l.env.NEXT_PHASE!==s.PHASE_PRODUCTION_BUILD)throw new o("Value for configuration key ".concat(t," was undefined."));return r},c=e=>{let t;if("string"==typeof e)t=parseFloat(e);else if("number"==typeof e)t=e;else throw TypeError("expire must be a string containing a number or an integer.");if(t<0)throw RangeError("expire must be non-negative.");return t},d=e=>{if(!e||"false"===e)return!1;if("string"==typeof e)return e;throw TypeError("placeholderUrlOrFalse must be a string or falsy.")};let m={apiHost:"https://nf-au-api.handelnine.tech",version:"1.2.39",defaultLocale:"en-us",cartCookieName:"spree_cart_token",cartCookieExpire:c("7"),userCookieName:"spree_user_token",userCookieExpire:c("7"),imageHost:"https://nf-au-api.handelnine.tech",categoriesTaxonomyPermalink:"categories",allProductsTaxonomyId:(e=>{if(!e||"false"===e)return!1;if("string"==typeof e)return e;throw TypeError("taxonomyId must be a string or falsy.")})("false"),showSingleVariantOptions:!1,lastUpdatedProductsPrerenderCount:(e=>{let t;if("string"==typeof e)t=parseInt(e);else if("number"==typeof e)t=e;else throw TypeError("prerenderCount count must be a string containing a number or an integer.");if(t<0)throw RangeError("prerenderCount must be non-negative.");return t})("100"),productPlaceholderImageUrl:d("/product-img-placeholder.svg"),lineItemPlaceholderImageUrl:d("/product-img-placeholder.svg"),imagesOptionFilter:(e=>{if(!e||"false"===e)return!1;if("string"==typeof e)return e;throw TypeError("optionTypeNameOrFalse must be a string or falsy.")})("false"),imagesSize:(e=>{if("string"!=typeof e)throw TypeError("size must be a string.");if(!e.includes("x")||2!=e.split("x").length)throw Error("size must have two numbers separated with an 'x'");return e})("1000x1000"),imagesQuality:(e=>{let t;if("string"==typeof e)t=parseInt(e);else if("number"==typeof e)t=e;else throw TypeError("prerenderCount count must be a string containing a number or an integer.");if(Number.isNaN(t))throw TypeError("prerenderCount count must be a string containing a number or an integer.");return t})("100"),loginAfterSignup:!0,reachSandboxPaymentUrl:"https://asset.sandbox.withreach.com/dist/rch.js",reachPaymentUrl:"https://asset.withreach.com/dist/rch.js"};((e,t,r)=>{let a=r.filter(t=>void 0===e[t]);if(a.length>0)throw new n(i(a))})(m,0,["defaultLocale","cartCookieName","cartCookieExpire","userCookieName","userCookieExpire","categoriesTaxonomyPermalink","allProductsTaxonomyId","showSingleVariantOptions","lastUpdatedProductsPrerenderCount","productPlaceholderImageUrl","lineItemPlaceholderImageUrl","imagesOptionFilter","imagesSize","imagesQuality","loginAfterSignup","version","reachPaymentUrl","reachSandboxPaymentUrl"]);let p=e=>u(m,e)},52757:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return P}});var n=r(85893),a=r(67294),i=r(11163),o=r(87066),s=r(32677);let l=e=>{let{name:t,email:r,destination:n,products:a}=e,i=(0,s.G)("apiHost");return o.Z.post("".concat(i,"/api/custom/bulk_order"),{name:t,email:r,destination:n,products:a})};var u=r(87536),c=r(90312),d=r(46747),m=r(75209),p=r(23279),f=r.n(p),h=r(85180),b=r(58280),x=r(68362),v=r.n(x),g=r(79734);let y=e=>{let{name:t,value:r,validations:i,onUpdateSku:o,idx:s,item:l}=e,{register:c,getFieldState:d,unregister:m}=(0,u.Gc)(),{invalid:p,error:f}=d(t);return(0,a.useEffect)(()=>()=>m(t),[t,m]),(0,n.jsx)(g.n,{...c(t,i),onChange:e=>o(s,e,l),value:r,name:t,className:"mt-1 w-full",error:null==f?void 0:f.message,invalid:p,placeholder:"Product SKU or URL"})},j=()=>{let{control:e,trigger:t}=(0,u.Gc)(),{fields:r,remove:i,append:o,update:s}=(0,u.Dq)({control:e,name:"products"}),l=e=>i(e),c=()=>o({product:"",quantity:10,key:Math.max(...r.map(e=>e.key))+1}),d=(0,a.useCallback)(f()(e=>t(e),500),[]),m=(e,t,r)=>{s(e,{...r,quantity:Number(t)})},p=(e,t,r)=>{s(e,{...r,product:null==t?void 0:t.trim()}),d("products.".concat(e,".product"))};return(0,n.jsx)("section",{children:r.map((e,t)=>(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("label",{htmlFor:"products.".concat(t,".product"),className:v().bulkInputLabel,children:"Product SKU or URL"}),(0,n.jsx)(y,{onUpdateSku:p,value:e.product,name:"products.".concat(t,".product"),idx:t,item:e,validations:{required:"Product SKU or URL is required"}})]}),(0,n.jsxs)("div",{className:"flex justify-between items-baseline mb-1",children:[(0,n.jsx)("span",{className:v().bulkInputLabel,children:"Desired quantity (minimum order quantity 10)"}),0!==t&&(0,n.jsx)(h.Z,{variant:"brandLink",className:"underline",onClick:()=>l(t),children:"Delete"})]}),(0,n.jsxs)("div",{className:"flex justify-between flex-wrap",children:[(0,n.jsx)("div",{className:"mb-1 min-w-[194px]",children:(0,n.jsx)(b.H,{onChange:r=>m(t,r,e),value:e.quantity,name:"products[".concat(t,"].quantity"),min:10})}),t===r.length-1&&(0,n.jsx)(h.Z,{variant:"outlined",onClick:c,children:"Add more products"})]})]},e.key))})};var k=r(23575),N=r(2083),_=r(28171),w=r.n(_);let E=(e,t,r)=>{if(!r&&!e)return!0;let n=e.match(t);return null!==n&&(!n||n.join("")===e)||k.Xo};var S=e=>{let{sku:t}=e,{data:r}=(0,c.Z)(),{setValue:i}=(0,u.Gc)(),{modalView:o}=(0,N.l8)();return(0,a.useEffect)(()=>{i("products",[{product:t,quantity:10,key:0}]),r&&(i("name","".concat(r.first_name," ").concat(r.last_name),{shouldValidate:!0}),i("email",r.email,{shouldValidate:!0}))},[t,null==r?void 0:r.email,i,o]),(0,n.jsxs)("div",{className:"mx-auto max-w-tablet",children:[(0,n.jsx)(j,{}),(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("label",{htmlFor:"name",className:w().bulkInputLabel,children:"Name"}),(0,n.jsx)(d.X,{name:"name",placeholder:"Your Full Name",validations:{required:"Name is required",validate:e=>E(e,m.JX.name,!0)}})]}),(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("label",{htmlFor:"email",className:w().bulkInputLabel,children:"Email"}),(0,n.jsx)(d.X,{name:"email",placeholder:"Your Email",validations:{required:"Email is required",pattern:{value:m.s9,message:"Invalid Email address"}}})]}),(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("label",{htmlFor:"destination",className:w().bulkInputLabel,children:"Shipping Address"}),(0,n.jsx)(d.X,{name:"destination",placeholder:"Shipping address",validations:{required:"Shipping address is required"}})]})]})},T=r(22069),q=r(19940),C=r(22920),L=r(31436);let F=()=>{let e=(0,i.useRouter)(),[t,r]=(0,a.useState)(!1),[o,s]=(0,a.useState)(""),c=(0,u.cI)({mode:"onSubmit",defaultValues:{products:[{product:e.query.sku,quantity:10,key:0}]}});(0,a.useEffect)(()=>{e.query.sku&&s(e.query.sku)},[e.query.sku]);let d=async e=>{r(!0);try{await l({...e}),C.Am.success("Email was sent!",L.P),r(!1)}catch(e){C.Am.error("".concat(e.response.data.error),L.P),r(!1)}};return(0,n.jsx)(q.Z,{common:!0,children:(0,n.jsxs)("section",{className:"mt-12",children:[(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("h1",{className:"text-3xl font-bold mb-2",children:"Bulk order"}),(0,n.jsx)("p",{className:"mb-12 font-secondary",children:"Please fill-in this form and expect a quote within 48-72 hours"})]}),(0,n.jsx)(u.RV,{...c,children:(0,n.jsxs)("form",{onSubmit:c.handleSubmit(d),children:[(0,n.jsx)(S,{sku:o}),(0,n.jsx)("div",{className:"text-center mb-20",children:(0,n.jsx)(h.Z,{type:"submit",variant:"brand",size:"big",className:"mx-auto",loading:t,children:"Submit enquiry"})})]})})]})})};F.Layout=T.Z;var P=F},28171:function(e){e.exports={bulkInputLabel:"BulkOrderForm_bulkInputLabel__OiLpu"}},68362:function(e){e.exports={bulkInputLabel:"ProductBlock_bulkInputLabel__Az3_q"}},96231:function(e){e.exports={root:"QuantityField_root__J_izs",button:"QuantityField_button__YWrzL",input:"QuantityField_input__BrRxN"}},64783:function(e){e.exports={root:"TextField_root__wNRxk",invalid:"TextField_invalid__zIVQm",placeholder:"TextField_placeholder__ysYAX",errorMessage:"TextField_errorMessage__LUFD3",priceFilterLabel:"TextField_priceFilterLabel__D_1GY"}}}]);
//# sourceMappingURL=2757-156432a2d91a60a9.js.map