1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7813],{59746:function(e,t,i){(window.__NEXT_P=window.__NEXT_P||[]).push(["/bulk-gift",function(){return i(59067)}])},69413:function(e,t,i){"use strict";i.d(t,{F:function(){return n},U:function(){return s}});var a=i(85893),l=i(33637);const s=e=>{let{label:t,value:i,separator:s}=e;return s?(0,a.jsx)(l.i,{className:"m-0!"}):(0,a.jsxs)("dl",{className:"grid md:grid-flow-col grid-flow-row text-[14px] md:text-[16px]",children:[(0,a.jsx)("dt",{className:"md:col-start-1 font-semibold min-w-full md:min-w-[120px]",children:t}),(0,a.jsx)("dd",{className:"md:col-start-2 md:text-right",children:i})]})},n=e=>{let{children:t,className:i,gap:l=2}=e;return(0,a.jsx)("div",{className:"flex flex-col gap-".concat(l," ").concat(i),children:t})}},46677:function(e,t,i){"use strict";i.d(t,{K:function(){return p}});var a=i(85893),l=i(67294),s=i(7456),n=i(89827),r=i(4037),o=i(72048),d=i(18083),c=i(44156),m=i(33378);const u=e=>{let{giftTemplateOptions:t,giftTemplatesData:i,onGiftSelect:l}=e;return(0,a.jsxs)("fieldset",{children:[(0,a.jsx)("legend",{className:"sr-only",children:"Select your design"}),(0,a.jsx)("div",{className:"grid gap-5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2",children:null===t||void 0===t?void 0:t.map((e=>{var t;const s=null===i||void 0===i||null===(t=i.GiftTemplate)||void 0===t?void 0:t.find((t=>t.Id===e.value));return s?(0,a.jsx)("div",{children:(0,a.jsxs)("div",{className:"relative h-full mb-4",children:[(0,a.jsxs)(c.Hp,{className:"w-full",onClick:()=>l(s.Id),children:[(0,a.jsx)("div",{className:"overflow-clip hover:shadow-[0px_0px_20px_0px_rgba(0,0,0,0.25)] transition-shadow duration-300",children:(0,a.jsx)(d.E,{alt:s.Description,layout:"responsive",width:600,height:424,src:"".concat("https://assets.treesthatcount.co.nz","/").concat(s.Preview)})}),(0,a.jsx)("div",{className:"mt-3 mb-2",children:(0,a.jsx)(m.S,{variant:"h5",color:"forestDeep",children:s.Title})})]}),(0,a.jsx)(m.S,{variant:"paragraph",children:s.Description})]})},e.value):null}))})]})},p=e=>{let{onGiftTemplateSelect:t,category:i}=e;var d,c;const{data:m}=(0,n.zF)(),{currentPage:p,limit:v,offset:h,onPageClick:f}=(0,r.h)({limit:6}),x=(0,l.useMemo)((()=>{const e={IsBulkOnly:{_eq:!1},IsAvailable:{_eq:!0}};return i&&"all"!==i&&(e.TemplateCategories={GiftCategoryId:{_eq:i}}),e}),[i]),{data:g}=(0,n.LQp)({variables:{offset:h,where:x,limit:6}});(0,l.useEffect)((()=>{m&&g&&(0,o.L)("view_item_list",{items:g.GiftTemplate.map(((e,t)=>{var a;return{item_id:e.Id,item_name:e.Title,item_list_name:"Gift list",item_category:(null===m||void 0===m||null===(a=m.GiftCategory.find((e=>e.Id===i)))||void 0===a?void 0:a.Name)||"All",quantity:1,price:10,index:t}}))})}),[m,g,i]);const y=(null===g||void 0===g||null===(c=g.GiftTemplate_aggregate)||void 0===c||null===(d=c.aggregate)||void 0===d?void 0:d.count)||0,j=(0,l.useMemo)((()=>{return e=null===g||void 0===g?void 0:g.GiftTemplate,t=i,(null===e||void 0===e?void 0:e.reduce(((e,i)=>{var a;return"all"===t||(null===(a=i.TemplateCategories)||void 0===a?void 0:a.find((e=>e.GiftCategoryId===t)))?[...e,{label:"".concat(i.Title," - ").concat(i.Description),value:i.Id}]:[...e]}),[]))||[];var e,t}),[g,i]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u,{giftTemplateOptions:j,giftTemplatesData:g,onGiftSelect:async e=>{var a;const l=g?null===g||void 0===g?void 0:g.GiftTemplate.findIndex((t=>t.Id===e)):-1,s=-1!==l&&(null===g||void 0===g?void 0:g.GiftTemplate[l]),n=(null===m||void 0===m||null===(a=m.GiftCategory.find((e=>e.Id===i)))||void 0===a?void 0:a.Name)||"All";s&&(0,o.L)("add_to_cart",{items:[{item_id:null===s||void 0===s?void 0:s.Id,item_name:null===s||void 0===s?void 0:s.Title,item_list_name:"Gift list",item_category:n,quantity:1,price:10,index:l}]}),await t(e)}}),(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)(s.D,{count:y,onChange:e=>{f(e),window.scrollTo({behavior:"smooth",top:0})},page:p,pageSize:v})})]})}},7456:function(e,t,i){"use strict";i.d(t,{D:function(){return r}});var a=i(85893),l=i(8172),s=i(50788);const n={prev_page:"Previous page",next_page:"Next page"},r=e=>{let{count:t,page:i,pageSize:r,onChange:o,showQuickJumper:d=!1}=e;return t&&i&&r?(0,a.jsx)("div",{className:"my-6",children:(0,a.jsx)(l.Z,{current:i,jumpNextIcon:(0,a.jsx)("span",{"aria-hidden":!0,
1children:"\u2026"}),jumpPrevIcon:(0,a.jsx)("span",{"aria-hidden":!0,children:"\u2026"}),locale:n,nextIcon:(0,a.jsx)(s.FNi,{}),onChange:o,pageSize:r,prefixCls:"rc-pagination-rebrand",prevIcon:(0,a.jsx)(s.G1X,{}),total:t,showQuickJumper:d&&{goButton:"Go to page"}})}):null}},81438:function(e,t,i){"use strict";i.d(t,{S:function(){return o}});var a=i(85893),l=i(25675),s=i.n(l),n=i(24276),r=i(89827);const o=e=>{let{showLoader:t=!1,templateData:i,gift:l,alt:o,...d}=e;var c,m;const{data:u,loading:p}=(0,r.ZBX)({variables:{input:{FromName:l.FromName,ToName:l.ToName,Message:l.Message,Trees:l.Trees,TemplateId:i.Id}}});return(0,a.jsx)(n.T,{isLoading:t&&p||!(null===u||void 0===u||null===(c=u.get_gift_preview)||void 0===c?void 0:c.base64Data),children:(0,a.jsx)(s(),{alt:i.Description||o,className:"rounded-lg",layout:"responsive",src:"data:image/jpeg;base64, ".concat(null===u||void 0===u||null===(m=u.get_gift_preview)||void 0===m?void 0:m.base64Data),...d})})}},4037:function(e,t,i){"use strict";i.d(t,{h:function(){return n}});var a=i(11163),l=i(67294);const s={offset:0,page:1},n=e=>{const{limit:t=10}=e||{},i=(0,a.useRouter)(),n=(0,l.useMemo)((()=>({limit:parseInt(i.query.limit,10),offset:parseInt(i.query.offset,10),page:parseInt(i.query.page,10)})),[i.query]);(0,l.useEffect)((()=>{if(!i.query.limit||!i.query.offset||!i.query.page){const e={...s,limit:t};Object.entries(e).forEach((e=>{let[t,a]=e;i.query[t]=a})),i.replace({pathname:i.pathname,query:i.query},void 0,{shallow:!0})}}),[i.query]);return{currentPage:n.page||s.page,limit:n.limit||t,offset:n.offset||s.offset,onPageClick:e=>{const t=e&&(null===n||void 0===n?void 0:n.limit)?(e-1)*n.limit:0;i.query.offset="".concat(t),i.query.page="".concat(e),i.push({pathname:i.pathname,query:i.query},void 0,{shallow:!0})},resetPagination:()=>{delete i.query.limit,delete i.query.offset,delete i.query.page,i.push({pathname:i.pathname,query:i.query},void 0,{shallow:!0})}}}},59067:function(e,t,i){"use strict";i.r(t),i.d(t,{default:function(){return De}});var a=i(85893),l=i(67294),s=i(47788),n=i(33378),r=i(1027),o=i(7515),d=i(20512),c=i(11163),m=i(43748),u=i(29854),p=i(53719),v=i(56959),h=i(59375),f=i(67423),x=i(23450),g=i.n(x);var y,j;!function(e){e.Immediately="immediately",e.SpecificDateTime="specific_datetime"}(y||(y={})),function(e){e.Self="self",e.Recipients="recipients"}(j||(j={}));const b=[{label:"To the recipients directly",value:"recipients"},{label:"To me, so I can pass them on myself",value:"self"}],N=[{label:"Immediately",value:"immediately"},{label:"Schedule for later",value:"specific_datetime"}];var D=i(50788),w=i(13508),I=i(82999),_=i(33637),C=i(44156),S=i(91522),P=i(46677),G=i(89827),T=i(27518),A=i(13612);const F=()=>{const e=(0,d.u6)(),{setFieldValue:t,values:i}=e,s=(0,c.useRouter)(),{isUser:r,isLoading:o,loginWithCustomRedirect:m}=(0,w.a)(),{category:u}=s.query,{data:p}=(0,G.zF)(),v=(0,l.useMemo)((()=>((e,t)=>{var i;return(null===e||void 0===e?void 0:e.reduce(((e,t)=>{var i,a;if(0===(null===(i=t.TemplateCategories_aggregate.aggregate)||void 0===i?void 0:i.count))return e;const l="".concat(t.Name," (").concat(g()("card",(null===(a=t.TemplateCategories_aggregate.aggregate)||void 0===a?void 0:a.count)||0,!0),")");return[...e,{label:l,value:t.Id}]}),[{label:"All categories (".concat(g()("card",(null===t||void 0===t||null===(i=t.aggregate)||void 0===i?void 0:i.count)||0,!0),")"),value:"all"}]))||[]})(null===p||void 0===p?void 0:p.GiftCategory,null===p||void 0===p?void 0:p.GiftTemplate_aggregate)),[p]);return(0,l.useEffect)((()=>{if(u){const e=null===p||void 0===p?void 0:p.GiftCategory.find((e=>e.Name===u));e&&t("Category",e.Id)}}),[u,p,t]),(0,a.jsxs)("div",{className:"flex flex-col lg:flex-row gap-5 md:gap-10",children:[(0,a.jsxs)("div",{className:"bg-white p-5 md:p-10",children:[(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h4",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Select an e-card design"})})}),(0,a.jsx)(n.S,{variant:"paragraph",children:"Filter by category and browse the designs below to select an e-card to send. Each features precious n
1ative plant and wildlife species \u2014 from towering rimu to endemic t\u012beke."})]}),(0,a.jsx)(S.W,{id:"Category",label:"Filter by category",labelClassName:"text-forestDeep! font-body-rebrand",options:v,type:A.IY.select,onChange:async e=>{const t=null===p||void 0===p?void 0:p.GiftCategory.find((t=>t.Id===e.currentTarget.value));await s.replace({query:{category:null===t||void 0===t?void 0:t.Name}},void 0,{scroll:!1})}}),(0,a.jsx)(P.K,{onGiftTemplateSelect:async e=>{o||r?await t("GiftTemplateId",e):await m((0,T.Me)())},category:i.Category})]}),(0,a.jsxs)("div",{className:"bg-white self-start flex shrink-0 flex-col w-full lg:w-[415px] p-5 md:p-10",children:[(0,a.jsxs)("div",{className:"mb-10",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Download bulk order template"})}),(0,a.jsxs)(n.S,{variant:"paragraph",children:["Get your bulk csv template."," ",(0,a.jsx)(C.dL,{color:"forestDeep",className:"underline hover:no-underline",href:"https://help.treesthatcount.co.nz/en/articles/8622177-gifting-in-bulk-let-us-help",children:"How to use it"})]}),(0,a.jsxs)(I.J,{href:"/assets/bulk_upload_csv_template.csv",download:!0,variant:"lime",className:"gap-2 self-start",children:[(0,a.jsx)(D.uKn,{size:16}),(0,a.jsx)("span",{children:"Download template"})]})]}),(0,a.jsx)(_.i,{className:"m-0!"}),(0,a.jsxs)("div",{className:"mt-10 mb-10",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Need a hand?"})}),(0,a.jsx)(n.S,{variant:"paragraph",children:"Get in touch and we can help you with your order."}),(0,a.jsx)(I.J,{href:T.Le,variant:"outline",className:"self-start",children:"Contact us"})]}),(0,a.jsx)(_.i,{className:"m-0!"}),(0,a.jsxs)("div",{className:"mt-10",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Only have a few recipients?"})}),(0,a.jsx)(n.S,{variant:"paragraph",children:"Use our standing gifting option if you're wanting to send to fewer than 10 recipients at a time."}),(0,a.jsx)(I.J,{href:(0,T.zO)(),variant:"outline",className:"self-start",children:"Gift one at a time"})]})]})]})};var R=i(86250),q=i(84e3),k=i(69413),E=i(59736),M=i(7456),W=i(4037),O=i(36620),Y=i(73967),U=i(43974);const L=e=>{const{resetForm:t}=(0,d.u6)();return(0,a.jsx)(U.x,{...e,onCancel:()=>t()})};var V=i(27060),Z=i(55346),B=i(75850),z=i(33562),Q=i(81438),X=i(7258),H=i(22758);const $=X.Ry().shape({Index:X.Rx(),RecipientName:X.Z_().max(30,"Recipient name should be 30 characters or less").required("Please enter a recipient name"),RecipientEmail:X.Z_().email("Please enter a valid email address").required("Please enter an email address"),From:X.Z_().max(30,"From name should be 30 characters or less").required("Please enter a from name"),Message:X.Z_().optional().default(""),GiftTemplateId:X.Z_().required("This field is required"),Quantity:(0,H.W)("At least one tree required",1),Amount:(0,H.W)("",10),DeliveryDatetimeWhen:X.Z_().oneOf(N.map((e=>e.value))).required("Please select when you want to send the e-card"),DeliverOn:X.hT().nullable()}),J=X.Ry({InvoiceAddress0:X.Z_().required("Address line 1 is required"),InvoiceAddress1:X.Z_().optional(),InvoiceCity:X.Z_().required("City is required"),InvoiceCountry:X.Z_().required("Country is required"),InvoicePostCode:X.Z_().required("Post code is required")}),K=X.Ry({DeliveryDatetimeWhen:X.Z_().oneOf(N.map((e=>e.value))).required("Please select when you want to send the e-card"),DeliverOn:X.nK().when("DeliveryDatetimeWhen",{is:y.Immediately,then:X.hT().optional().nullable(),otherwise:X.hT().typeError("Please select a delivery date").required("Please select a delivery date")}),GiftsDestination:X.Z_().oneOf(b.map((e=>e.value))).required("Please select where you want the gift cards to be sent"),GiftEmailAddress:X.Z_().email("Please enter a valid email address"),ConfirmGiftEmailAddress:X.Xg().oneOf([!0],"Please check this to continue").required("Please check this to continue")}),ee=X.Ry({Amount:X.Z_().required(),Category:X.Z_().required(""),Gifts:X.IX().of($).required(""),ReceiptEmail:X.Z_().email("Please enter a valid email address").required("Please enter an email address"),ReceiptName:X.Z_().required("Please enter a name for your receipt"),CopyDetail
1s:X.Xg(),InvoiceAddress:X.nK().when("PaymentMethod",{is:h.XL.Invoice,then:J.required(),otherwise:X.nK().optional()}),GiftTemplateId:X.Z_().required(),CsvFile:X.IX().optional(),DeliveryDetails:K.required(),PlantingRegionId:X.Z_()}),te=X.Ry({PaymentMethod:X.Z_().required("Please select a payment method"),SavePaymentMethod:X.O7().optional().default(!1)}),ie=X.Ry({RecipientName:X.Z_().max(30,"Recipient name should be 30 characters or less").required("Please enter a recipient name"),RecipientEmail:X.Z_().email("Please enter a valid email address").required("Please enter an email address"),From:X.Z_().max(30,"From name should be 30 characters or less").required("Please enter a from name"),Message:X.Z_().optional().default(""),Quantity:(0,H.W)("At least one tree required",1)}),ae=e=>{let{recipient:t,onUpdated:i}=e;const s=(0,d.u6)(),{setFieldValue:n,values:r}=s,{data:o}=(0,G.LQp)({variables:{offset:0,where:{IsBulkOnly:{_eq:!1},IsAvailable:{_eq:!0}}}}),c=r.Gifts[t.Index],m=(0,l.useMemo)((()=>null===o||void 0===o?void 0:o.GiftTemplate.find((e=>e.Id===t.GiftTemplateId))),[null===o||void 0===o?void 0:o.GiftTemplate,t.GiftTemplateId]);return(0,a.jsx)(d.J9,{initialValues:c,onSubmit:async e=>{await n("Gifts[".concat(t.Index,"]"),e),i&&i()},validationSchema:ie,children:e=>{let{submitForm:i,dirty:l}=e;return(0,a.jsxs)("div",{className:"flex flex-col xl:flex-row bg-linen p-5 lg:p-10 gap-[10px] lg:gap-10 text-left",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-col lg:flex-row lg:gap-[10px]",children:[(0,a.jsx)(S.W,{id:"RecipientName",label:"To",type:A.IY.text,formFieldClassName:"bg-white"}),(0,a.jsx)(S.W,{id:"RecipientEmail",label:"Email",type:A.IY.text,formFieldClassName:"bg-white"})]}),(0,a.jsx)(S.W,{id:"From",label:"From",type:A.IY.text,formFieldClassName:"bg-white"}),(0,a.jsx)(S.W,{id:"Message",label:"Message (up to 150 characters)",type:A.IY.textarea,rows:3,formFieldClassName:"bg-white",maxCharacters:150}),(0,a.jsx)(S.W,{id:"Quantity",label:"Number of trees",type:A.IY.text,formFieldClassName:"bg-white"})]}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(I.B,{variant:"lime",disabled:!l,type:"button",onClick:i,children:"Save changes"})})]}),(0,a.jsx)("div",{className:"overflow-clip flex-1",children:m?(0,a.jsx)(Q.S,{alt:"Preview",templateData:m,gift:{FromName:t.From,ToName:t.RecipientName,ToEmail:t.RecipientEmail,Message:t.Message,Trees:Number(t.Quantity)},width:520,height:387}):null})]})}})},le=e=>{let{Gifts:t}=e;const i=(0,z.Z)("(max-width: 1024px)"),l=(0,V.Cl)(),s=[l.accessor("Index",{cell:e=>{const{RecipientName:t,RecipientEmail:i,From:l,Message:s,Quantity:n}=e.row.original;return(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)(k.F,{className:"bg-transparent mb-4",children:[(0,a.jsx)(k.U,{label:"To",value:t}),(0,a.jsx)(k.U,{label:"Recipient email",value:i}),(0,a.jsx)(k.U,{label:"From",value:l}),(0,a.jsx)(k.U,{label:"Message",value:s}),(0,a.jsx)(k.U,{label:"To",value:t}),(0,a.jsx)(k.U,{label:"Number of trees",value:n})]}),(0,a.jsxs)(C.Hp,{color:"forestDeep",className:"text-sm font-semibold",type:"button",children:["Preview card",e.row.getIsExpanded()?(0,a.jsx)(Z.s$2,{className:"inline mx-2"}):(0,a.jsx)(Z.RiI,{className:"inline mx-2"})]})]})}})],n=[l.accessor("RecipientName",{header:"To",cell:e=>(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"block",children:e.getValue()}),(0,a.jsxs)(C.Hp,{color:"forestDeep",className:"text-sm font-semibold",type:"button",children:["Preview card",e.row.getIsExpanded()?(0,a.jsx)(Z.s$2,{className:"inline mx-2"}):(0,a.jsx)(Z.RiI,{className:"inline mx-2"})]})]})}),l.accessor("RecipientEmail",{header:"Recipient email",cell:e=>e.getValue()}),l.accessor("From",{header:"From",cell:e=>e.getValue()}),l.accessor("Message",{header:"Message",cell:e=>e.getValue()}),l.accessor("Quantity",{header:"Trees qty",cell:e=>e.getValue()})],r=i?s:n;return(0,a.jsx)(B.i,{headerClasses:"py-5! text-left! lg:last:text-right!",cellClasses:"py-5! text-left! px-4! lg:last:text-right! align-top text-base font-medium",subComponentClasses:"pt-2!",isSelectable:()=>!0,onSelect:(e,t)=>
1{t.toggleExpanded()},data:t,columns:r,showHeader:!i,renderSubComponent:e=>{let{row:t}=e;return(0,a.jsx)(ae,{recipient:t.original})}})},se=()=>{var e;const{nextStep:t,steps:i}=(0,u.t)(),s=(0,c.useRouter)(),r=(0,d.u6)(),{values:o,setFieldValue:m}=r,{currentPage:v,limit:h,onPageClick:x,resetPagination:g}=(0,W.h)({limit:10}),{user:b,memberships:N}=(0,p.a)(),D=(0,l.useMemo)((()=>o.Gifts.reduce(((e,t)=>e+Number(t.Quantity)),0)),[o.Gifts]),{productPrice:w}=(0,O.u)(D,!0);(0,l.useEffect)((()=>{g()}),[]),(0,l.useEffect)((()=>{if(w&&D){m("Amount",(w*(D||0)).toString())}}),[w,D]);const I=(0,l.useMemo)((()=>{const e=(v-1)*h;return o.Gifts.slice(e,v*h)}),[v,h,o.Gifts]),[S,{data:P}]=(0,G.pJ1)(),T=(0,l.useMemo)((()=>(null===P||void 0===P?void 0:P.Region[0])?[P.Region[0].Name,P.Region[0].AltName].filter(Boolean).join(" - "):"Where trees are needed most"),[null===P||void 0===P?void 0:P.Region]);return(0,l.useEffect)((()=>{const e=o.PlantingRegionId;e&&S({variables:{regionId:e}})}),[S,o.PlantingRegionId]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h3",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Review messages and details"})})}),(0,a.jsx)(n.S,{variant:"paragraph",children:"View and confirm details before you continue."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-5 md:gap-10",children:[(0,a.jsxs)("div",{className:"w-full lg:w-1/2",children:[(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Summary"})}),(0,a.jsxs)(k.F,{className:"bg-linen p-5",children:[(0,a.jsx)(k.U,{label:"No. of trees",value:D}),(0,a.jsx)(k.U,{label:"Price per tree",value:(0,a.jsx)(q.F,{amount:w})}),"Where trees are needed most"===T?null:(0,a.jsxs)("dl",{className:"grid gap-y-2 mb-4",children:[(0,a.jsx)("dt",{className:"col-start-1 font-semibold mr-4",children:"Preferred planting region"}),(0,a.jsx)("dd",{className:"col-start-2 text-right",children:T})]}),(0,a.jsx)(k.U,{label:"No. of recipients",value:o.Gifts.length}),(0,a.jsx)(_.i,{className:"my-2!"}),(0,a.jsx)(k.U,{label:"Amount to pay (NZD)",value:(0,a.jsx)(q.F,{amount:o.Amount})})]})]}),(0,a.jsxs)("div",{className:"w-full lg:w-1/2",children:[(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Delivery details"})}),(0,a.jsxs)(k.F,{className:"bg-linen p-5",children:[(0,a.jsx)(k.U,{label:(0,a.jsxs)("div",{className:"flex flex-row justify-between md:justify-normal",children:[(0,a.jsx)("span",{className:"mr-2",children:"Scheduled delivery time"}),(0,a.jsx)(C.Hp,{color:"wine",onClick:()=>(0,f.t)(s,i.length,0),children:"(change)"})]}),value:o.DeliveryDetails.DeliveryDatetimeWhen===y.Immediately?"Immediately":(0,Y.p6)({date:o.DeliveryDetails.DeliverOn.toString(),isUtc:!0,format:"DD/MM/YYYY HH:mm"})}),(0,a.jsx)(k.U,{label:(0,a.jsxs)("div",{className:"flex flex-row justify-between md:justify-normal",children:[(0,a.jsx)("span",{className:"mr-2",children:"Send e-cards to "}),(0,a.jsx)(C.Hp,{color:"wine",onClick:()=>(0,f.t)(s,i.length,0),children:"(change)"})]}),value:o.DeliveryDetails.GiftsDestination===j.Self?o.DeliveryDetails.GiftEmailAddress:"Directly to recipients"}),(0,a.jsx)(k.U,{label:(0,a.jsxs)("span",{className:"align-middle",children:["Account name",((null===N||void 0===N?void 0:N.length)||0)>1?(0,a.jsx)(E.u,{overlay:(0,a.jsxs)("div",{className:"text-center px-[18px] py-[10px]",children:["Looks like you have multiple accounts. You can change the account you're sending these gifts from using the account menu on the top-right. ",(0,a.jsx)("br",{}),"Please note, you'll have to re-upload your order."]}),children:(0,a.jsx)(R.gOU,{className:"text-forestDeep w-5 h-5 inline ml-[10px]"})}):null]}),value:null===b||void 0===b||null===(e=b.Account)||void 0===e?void 0:e.Name})]})]}),(0,a.jsxs)("div",{className:"mb-10",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Recipients"})}),(0,a.jsx)(n.S,{variant:"paragraph",children:"Preview and update your card and message details as needed."}),(0,a.jsx)(le,{Gifts:I}),(0,a.jsx)(M.D,{page:v,pageSize:h,count:o.Gifts.length,onChange:x})]})]}),(0,a.jsx)(L,{submitText:"Next",onSubmit:()=>{t()},onBack:()=>(m("CsvFile",[]),!1)})]})};var ne=i(27484),re=i.n(ne),oe=i(18083),de=i(82784),ce=i(45798),me=i(71165);const ue=()=>{const{nextStep:e}=(0,u.t)(),{user:t}=(0,p.a)(),i=(0,d.u6)(),{values:s,setFieldValue:n}=i,{data:r}=(0,G.LQp)({variables:{offset:0,where:{IsBulkOnly:{_eq:!1},IsAvailable:{_eq:!0}}}}),o=(0,l.useMemo)((()=>{var e;return(null===r||void 0===r||null===(e=r.GiftTemplate.find((e=>e.Id===s.GiftTemplateId)))||void 0===e?void 0:e.Preview)||""}),[null===r||void 0===r?void 0:r.GiftTemplate,s]),{setValue:c}=(0,v.Y)({key:"bulkGiftForm"}),m=(0,l.useMemo)((()=>(null===r||void 0===r?void 0:r.GiftTemplate.map((e=>({label:e.Title,value:e.Id}))))||[]),[r]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ce.Z,{variant:"h4",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Delivery details"})}),(0,a.jsxs)("div",{className:"flex flex-col gap-10 lg:flex-row lg:gap-[100px] mt-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(S.W,{id:"DeliveryDetails.GiftsDestination",type:A.IY.radioGroup,options:b,label:"Where shall we send the e-cards",conditionForConditionalComponent:s.DeliveryDetails.GiftsDestination===j.Self,className:s.DeliveryDetails.GiftsDestination===j.Self?"mb-0":"",conditionalComponent:(0,a.jsxs)("div",{className:"ml-[30px]",children:[(0,a.jsx)(S.W,{id:"DeliveryDetails.GiftEmailAddress",label:"Send gifts to",labelClassName:"sr-only",type:A.IY.text,className:"mb-0"}),(0,a.jsx)(S.W,{formFieldClassName:"ml-0! border border-lavenderBright px-3 py-1 [&_svg]:fill-lavenderBright!",id:"DeliveryDetails.ConfirmGiftEmailAddress",label:"",description:"We'll email the link to the e-cards to this email address.",checkboxLabel:"I confirm this email address is correct",labelClassName:"sr-only",type:A.IY.checkbox})]}),onChange:e=>{var i;e.target.value===j.Self?(n("DeliveryDetails.GiftEmailAddress",(null===t||void 0===t||null===(i=t.Account)||void 0===i?void 0:i.Email)||""),n("DeliveryDetails.ConfirmGiftEmailAddress",!1)):n("DeliveryDetails.ConfirmGiftEmailAddress",!0)}}),(0,a.jsx)(S.W,{id:"DeliveryDetails.DeliveryDatetimeWhen",type:A.IY.radioGroup,options:N,label:"When do you want to send the e-cards?",conditionForConditionalComponent:s.DeliveryDetails.DeliveryDatetimeWhen===y.SpecificDateTime,conditionalComponent:(0,a.jsx)(S.W,{id:"DeliveryDetails.DeliverOn",label:"Deliver on",description:"Tell us when to send out the e-cards",type:A.IY.datetime,onChange:async e=>{await n("Gifts",s.Gifts.map((t=>({...t,DeliverOn:re()(e).toISOString(),DeliveryDatetimeWhen:y.SpecificDateTime}))))}}),onChange:async e=>{e.target.value===y.Immediately&&(await n("DeliveryDetails.DeliverOn",null),await n("Gifts",s.Gifts.map((e=>({...e,DeliverOn:null,DeliveryDatetimeWhen:y.Immediately})))))}}),(0,a.jsx)(de.j,{type:"infoNew",children:"You can choose to be invoiced if your gifts are being sent in 2 or more days and total over $100 (that's 10 trees or more in total)."}),(0,a.jsx)(S.W,{className:"mb-5!",id:"PlantingRegionId",label:"Select a planting region (optional)",description:(0,a.jsx)("div",{className:"mt-[10px]",children:(0,a.jsx)(ce.Z,{variant:"paragraph",children:"We'll try to allocate your tree/s to your preferred region, but they may be planted where needed most."})}),type:A.IY.regionSelect,regionsOnly:!0})]}),(0,a.jsxs)("div",{className:"flex flex-col shrink-0 w-full lg:w-1/2",children:[(0,a.jsx)(S.W,{id:"GiftTemplateId",type:A.IY.select,options:m,label:"Change design",labelClassName:"sr-only"}),(0,a.jsx)("div",{className:"overflow-clip",children:(0,a.jsx)(oe.E,{src:"".concat(me.env.NEXT_PUBLIC_ASSETS_DOMAIN,"/").concat(o),layout:"responsive",objectFit:"cover",alt:"E-card preview",width:520,height:387})})]})]}),(0,a.jsx)(L,{submitText:"Next",onSubmit:async()=>{c(s),await e()}})]})};var pe=i(86664),ve=i(82950),he=i(36634),fe=i(9488),xe=i(67851),ge=i(72048);const ye=()=>{var e,t,i;const{validateStep:s}=(0,u.t)(),r=(0,d.u6)(),{isSubmitting:o,setFieldValue:f,values:x}=r,{processing:g,succeeded:j,setProcessing:b,setSucceeded:N}=(0,m.V)(),[D,I]=(0,l.useState)(!1),{data:P}=(0,G.zF)(),{data:F}=(0,G.LQp)({variables:{offset:0,where:{IsBulkOnly:{_eq:!1},IsAvailable:{_eq:!0}}}}),{setValue:R}=(0,v.Y)({key:"bulkGiftForm"}),E=(0,pe.useStripe)(),M=(0,pe.useElements)(),W=(0,c.useRouter)(),{user:O}=(0,p.a)(),{login:Y}=(0,w.a)(),U=(0,l.useMemo)((()=>x.Gifts.reduce(((e,t)=>e+parseInt("".concat(t.Quantity))),0)),[x.Gifts]),V=(0,l.useMemo)((()=>x.DeliveryDetails.DeliveryDatetimeWhen===y.SpecificDateTime),[x.DeliveryDetails.DeliveryDatetimeWhen]),{productPrice:Z}=(0,xe.u)(U,!0);(0,l.useEffect)((()=>{f("Amount",(U*Z).toString())}),[U,Z,f]);const B=!(!o&&E&&M&&!g&&!j);(0,l.useEffect)((()=>
1{Z&&x.Gifts.forEach(((e,t)=>{f("Gifts.".concat(t,".Amount"),parseInt("".concat(e.Quantity))*Z)}))}),[Z]);const[z]=(0,G.iBL)(),[Q]=(0,G.skJ)();let X=[];X=[{label:(null===O||void 0===O||null===(e=O.Account)||void 0===e?void 0:e.PaymentMethodDescriptor)?"Different card, Google Pay, or Apple Pay":"Credit or debit card",value:h.XL.CreditCard}],(null===O||void 0===O||null===(t=O.Account)||void 0===t?void 0:t.PaymentMethodDescriptor)&&(X=[{label:"Saved card (".concat(O.Account.PaymentMethodDescriptor,")"),value:"SavedCreditCard"},...X]),Number(x.Amount)>99&&V&&O&&(X=[{label:"Invoice",value:h.XL.Invoice},...X]);const[H,{data:$}]=(0,G.pJ1)(),J=(0,l.useMemo)((()=>(null===$||void 0===$?void 0:$.Region[0])?[$.Region[0].Name,$.Region[0].AltName].filter(Boolean).join(" - "):"Where trees are needed most"),[null===$||void 0===$?void 0:$.Region]);return(0,l.useEffect)((()=>{const e=x.PlantingRegionId;e&&H({variables:{regionId:e}})}),[H,x.PlantingRegionId]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Summary"})}),(0,a.jsx)("div",{className:"mb-5 md:mb-10 w-full lg:w-1/2",children:(0,a.jsxs)(k.F,{className:"bg-linen p-5",children:[(0,a.jsx)(k.U,{label:"No. of trees",value:U}),(0,a.jsx)(k.U,{label:"Price per tree",value:(0,a.jsx)(q.F,{amount:Z})}),(0,a.jsx)(k.U,{label:"No. of recipients",value:x.Gifts.length}),"Where trees are needed most"===J?null:(0,a.jsxs)("dl",{className:"grid gap-y-2 mb-4",children:[(0,a.jsx)("dt",{className:"col-start-1 font-semibold mr-4",children:"Preferred planting region"}),(0,a.jsx)("dd",{className:"col-start-2 text-right",children:J})]}),(0,a.jsx)(_.i,{className:"my-2!"}),(0,a.jsx)(k.U,{label:"Amount to pay (NZD)",value:(0,a.jsx)(q.F,{amount:x.Amount})})]})}),(0,a.jsx)(he.B,{handleReceiptNameBlur:e=>{f("ReceiptName",e.target.value)},paymentMethod:x.PaymentMethod}),(0,a.jsx)(_.i,{}),(0,a.jsxs)("div",{className:"my-8",children:[(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(n.S,{variant:"h3",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Payment"})})}),X.length>1&&(0,a.jsx)(S.W,{id:"PaymentMethod",label:"Payment method",description:!O&&Number(x.Amou
1nt)>99?(0,a.jsxs)("div",{children:["Please"," ",(0,a.jsx)(C.Hp,{color:"forestDeep",className:"underline hover:no-underline",onClick:Y,children:"sign in"})," ","to pay by invoice"]}):"",type:A.IY.radioGroup,options:X}),Number(x.Amount)>99&&!V&&(0,a.jsx)(de.j,{type:"warning",children:"Invoice payments are not allowed for gifts sent immediately."}),Number(x.Amount)>99&&V&&x.PaymentMethod===h.XL.Invoice&&(0,a.jsx)(de.j,{type:"warning",children:"If your scheduled delivery date is soon, you may want to use a credit card as payment. Your gift will not be sent until your invoice clears."}),x.PaymentMethod===h.XL.Invoice&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Pay by invoice"}),(0,a.jsx)(S.W,{id:"InvoiceAddress.InvoiceAddress0",label:"Address Line 1",type:A.IY.text}),(0,a.jsx)(S.W,{id:"InvoiceAddress.InvoiceAddress1",label:"Address Line 2",type:A.IY.text}),(0,a.jsxs)("div",{className:"flex space-x-4",children:[(0,a.jsx)(S.W,{id:"InvoiceAddress.InvoiceCity",label:"City",type:A.IY.text}),(0,a.jsx)(S.W,{id:"InvoiceAddress.InvoicePostCode",label:"Post Code",type:A.IY.text})]}),(0,a.jsx)(S.W,{id:"InvoiceAddress.InvoiceCountry",label:"Country",type:A.IY.text})]}),x.PaymentMethod===h.XL.CreditCard&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Credit/Debit card"}),(0,a.jsx)(fe.O,{onChange:e=>{var t,i;e.complete&&(t="add_payment_info",P&&F&&(0,ge.L)(t,{currency:"NZD",value:Number(x.Amou
1nt),payment_type:x.PaymentMethod,transaction_id:i,items:x.Gifts.map(((e,t)=>{var i;const a=null===F||void 0===F?void 0:F.GiftTemplate.find((t=>t.Id===e.GiftTemplateId)),l=(null===P||void 0===P||null===(i=P.GiftCategory.find((e=>{var t;return e.Id===(null===a||void 0===a||null===(t=a.TemplateCategories[0])||void 0===t?void 0:t.GiftCategoryId)})))||void 0===i?void 0:i.Name)||"All";return{item_id:null===a||void 0===a?void 0:a.Id,item_name:null===a||void 0===a?void 0:a.Title,item_list_name:"Gift list",item_category:l,quantity:Number(e.Quantity),price:e.Amount,index:t}}))})),I("card"!==e.value.type)}}),!D&&(0,a.jsx)(S.W,{id:"SavePaymentMethod",label:"Remember my details",checkboxLabel:"Save my credit/debit card details for next time",type:A.IY.checkbox,disabled:!O}),O&&x.SavePaymentMethod&&!D&&(0,a.jsxs)(de.j,{type:"infoNew",children:[(null===(i=O.Account)||void 0===i?void 0:i.PaymentMethodDescriptor)&&(0,a.jsxs)(n.S,{variant:"paragraph",children:["Saving a new payment card will replace your existing saved card (",O.Account.PaymentMethodDescriptor,")."]}),"We'll store your payment method (credit/debit card) through Stripe's secure platform. You'll be able to change your details at any time to ensure your donation goes smoothly."]})]})]}),(0,a.jsx)(L,{isSubmitDisabled:B,processing:g,submitText:"Make payment",onSubmit:async()=>{if(!(await s()))return;b(!0),R(x);const{Amount:e,Gifts:t,InvoiceAddress:i,PaymentMethod:a=h.XL.CreditCard,ReceiptEmail:l,ReceiptName:n,PlantingRegionId:r}=x,o=e=>{b(!1),(0,ve.h4)({message:e.message,type:ve.k$.error})},d=e=>a===h.XL.Invoice?(async e=>{N(!0);const t="".concat(me.env.NEXT_PUBLIC_APP_DOMAIN).concat((0,T._O)({queryParams:{token:e.Token,hash:e.Hash,purchaseId:e.PurchaseId,purchaseType:h.Oz.BulkGifted,path:W.pathname}}));await W.push(t)})(e):(async e=>{if(null===e||void 0===e?void 0:e.PaymentIntentClientSecret){const t="SavedCreditCard"===a?{}:{elements:M},i=await E.confirmPayment({...t,clientSecret:e.PaymentIntentClientSecret,confirmParams:{payment_method_data:{billing_details:{name:n}},return_url:"".concat(me.env.NEXT_PUBLIC_APP_DOMAIN).concat((0,T._O)({queryParams:{token:e.Token,hash:e.Hash,purchaseId:e.PurchaseId,purchaseType:h.Oz.BulkGifted,path:W.pathname}}))}});i.error&&(b(!1),(0,ve.h4)({message:i.error.message,type:ve.k$.error}),await Q({variables:{input:{PurchaseId:e.PurchaseId,Error:i.error.message||"Unknown error"}}}))}else(0,ve.h4)({message:"No Client Secret!",type:ve.k$.error})})(e);if(a===h.XL.CreditCard){const{error:e}=await M.submit();if(e)return(0,ve.h4)({message:e.message,type:ve.k$.error}),void b(!1)}return(async()=>{await z({variables:{input:{IsBulkGift:!0,Amount:e,PublicName:"",PublicMessage:"",ReceiptEmail:l,ReceiptName:n,PaymentMethod:a,InvoiceAddress:i,Gifts:t.map((e=>{let{DeliverOn:t,DeliveryDatetimeWhen:i,From:a,GiftTemplateId:l,Message:s,Quantity:n,RecipientEmail:o,RecipientName:d}=e;return{DeliverOn:i===y.SpecificDateTime?re()(t).toISOString():null,From:a,GiftTemplateId:l,Message:s||"",PlantingRegionId:"choose_for_me"===r?void 0:r,Quantity:parseInt("".concat(n)),RecipientEmail:o,RecipientName:d}}))}},onError:o,onCompleted:e=>{d(e.create_gift_payment)}})})()}})]})};var je=i(77545);const be=()=>{var e,t;const i=(0,d.u6)(),{values:s,setFieldValue:r}=i,[o,c]=(0,l.useState)(!1),{nextStep:m,validateStep:p}=(0,u.t)(),[h,f]=(0,l.useState)(""),[x,{called:y}]=(0,G.qF0)(),[b,{data:N,error:w,loading:_}]=(0,G.hmR)(),{setValue:P}=(0,v.Y)({key:"bulkGiftForm"}),F=(0,l.useMemo)((()=>{const e=async e=>{if(e.length&&await p()){c(!0);const t=null===e||void 0===e?void 0:e[0];f(t.name);const{data:i}=await x({variables:{input:{FileName:t.name,ContentType:"text/csv"}}}),{S3Key:a,SignedUrl:l}=(null===i||void 0===i?void 0:i.generate_put_object_presigned_url)||{};if(!a||!l)return;await fetch(l,{method:"PUT",mode:"cors",body:t}),await b({variables:{s3Key:a},onError:async()=>{await r("CsvFile",[])},onCompleted:async e=>{var t,i;await r("CsvFile",[]),await r("Gifts",null===(i=e.list_bulk_gift_recipients)||void 0===i||null===(t=i.Gifts)||void 0===t?void 0:t.map(((e,t)=>({Index:t,RecipientName:null===e||void 0===e?void 0:e.ToName,RecipientEmail:s.DeliveryDetails.GiftsDestination===j.Self?s.DeliveryDetails.GiftEmailAddress:null===e||void 0===e?void 0:e.ToEmail,Message:null===e||void 0===e?void 0:e.Me
1ssage,From:null===e||void 0===e?void 0:e.FromName,Quantity:null===e||void 0===e?void 0:e.Trees,Amount:10*(null===e||void 0===e?void 0:e.Trees),DeliverOn:s.DeliveryDetails.DeliverOn,DeliveryDatetimeWhen:s.DeliveryDetails.DeliveryDatetimeWhen,GiftTemplateId:s.GiftTemplateId}))))}}),c(!1)}};var t,i,l,d,m,u;return y?w?(0,a.jsxs)("div",{className:"flex flex-col gap-10",children:[(0,a.jsx)(de.j,{type:"warning",className:"self-start",children:(0,a.jsx)(n.S,{variant:"paragraph",children:"Oops\u2026 something doesn't look right. Any errors are listed below."})}),(0,a.jsx)("div",{className:"whitespace-pre-line",dangerouslySetInnerHTML:{__html:(null===(i=w.graphQLErrors[0])||void 0===i||null===(t=i.extensions)||void 0===t?void 0:t.details)?w.graphQLErrors[0].extensions.details.replace(/\*\*(.*?)\*\*/g,"<b>$1</b>"):""}}),(0,a.jsxs)(n.S,{variant:"paragraph",children:["You can try again. If the problem persists or you need help, please don't hesitate to"," ",(0,a.jsx)(C.h$,{href:T.Le,openInNewTab:!0,color:"forestDeep",className:"underline hover:no-underline",children:"contact us."})]}),(0,a.jsx)(S.W,{id:"CsvFile",label:"",dropzoneText:"Drop your CSV here or click 'Upload CSV' to upload your CSV",uploadButton:(0,a.jsxs)(I.B,{variant:"lime",className:"gap-2",children:[(0,a.jsx)(D.s_P,{size:18}),(0,a.jsx)("span",{children:"Upload CSV"})]}),type:A.IY.file,fileType:je.T.csv,renderDropzone:!1,maxFiles:1,onChange:t=>{e(t)}})]}):(0,a.jsxs)("div",{className:"flex flex-col gap-10",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-5 bg-linen p-10",children:[o?"Uploading recipients":"Uploading recipients complete!",(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"h-[17px] animate-grow-width bg-limeBright"})}),(0,a.jsx)("span",{className:"text-xl font-bold",children:o?"":"".concat(null===N||void 0===N||null===(d=N.list_bulk_gift_recipients)||void 0===d||null===(l=d.Gifts)||void 0===l?void 0:l.length," ").concat(g()("recipient",null===N||void 0===N||null===(u=N.list_bulk_gift_recipients)||void 0===u||null===(m=u.Gifts)||void 0===m?void 0:m.length))})]}),_||o?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(de.j,{type:"infoNew",className:"self-start mb-0!",children:(0,a.jsx)(n.S,{variant:"paragraph",children:"There were no errors in your document. Select next to preview and check your details"})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)(n.S,{variant:"paragraph",children:[(0,a.jsx)("b",{children:"Your file: "}),h,". ",(0,a.jsx)("br",{}),(0,a.jsx)("br",{}),"Uploaded the wrong csv file by mistake? You can upload another csv file to replace it."]}),(0,a.jsx)(S.W,{id:"CsvFile",label:"",dropzoneText:"Drop your CSV here or click 'Upload CSV' to upload your CSV",uploadButton:(0,a.jsxs)(I.B,{variant:"outline",className:"self-start",children:[(0,a.jsx)(Z.lbL,{className:"mr-2"}),(0,a.jsx)("span",{children:"Replace CSV file"})]}),type:A.IY.file,fileType:je.T.csv,renderDropzone:!1,maxFiles:1,onChange:t=>{e(t)}})]})]})]}):(0,a.jsxs)("div",{className:"flex flex-col lg:flex-row gap-10",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-5 flex-1 font-medium",children:[(0,a.jsx)("div",{className:"mb-2",children:(0,a.jsx)(n.S,{variant:"h5",color:"forestDeep",children:"Now, upload completed template."})}),(0,a.jsxs)(n.S,{variant:"paragraph",children:["Still need to"," ",(0,a.jsx)(C.h$,{download:!0,href:"/assets/bulk_upload_csv_template.csv",children:"download the template?"})]}),(0,a.jsx)(n.S,{variant:"paragraph",children:"For each recipient, please include:"}),(0,a.jsxs)("ol",{className:"list-inside list-decimal space-y-1",children:[(0,a.jsx)("li",{children:"Number of trees you'd like to gift."}),(0,a.jsx)("li",{children:"Their email address."}),(0,a.jsx)("li",{children:"To."}),(0,a.jsx)("li",{children:"From."}),(0,a.jsx)("li",{children:"Message of up to 150 characters. Please note - any formatting (e.g. line breaks, bullet lists, bold) won't be applied."})]}),(0,a.jsx)(de.j,{type:"infoNew",className:"mb-0!",children:"Ready to upload? Please ensure your file is saved in CSV (comma delimited) format. The filename should end in .csv"}),(0,a.jsx)(n.S,{variant:"paragraph",children:"You'll be able to review details before payment."}),(0,a.jsx)(S.W,{id:"CsvFile",label:"",dropzoneText:"Drop your CSV here or click 'Upload CSV' to upload your CSV",uploadButton:(0,a.jsxs)(I.B,{variant:"lime",className:"gap-2",children:[(0,a.jsx)(D.s_P,{size:18}),(0,a.jsx)("span",{children:"Upload CSV"})]}),type:A.IY.file,fileType:je.T.csv,renderDropzone:!1,maxFiles:1,onChange:t=>{e(t)}})]}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)("div",{className:"relative bg-linen p-5",children:(0,a.jsx)(oe.E,{src:"/img/csvTemplateGuide.png",alt:"CSV template guide",layout:"responsive",width:508,height:494})})})]})}),[h,y,x,o,b,_,r,w,null===N||void 0===N||null===(t=N.list_bulk_gift_recipients)||void 0===t||null===(e=t.Gifts)||void 0===e?void 0:e.length,p,s]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mb-5 md:mb-10",children:(0,a.jsx)(n.S,{variant:"h3",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Add recipients - upload template"})})}),F,(0,a.jsx)(L,{submitText:"Next",onSubmit:async()=>{await p()&&(P(s),await m())},onBack:async()=>(await r("Gifts",[]),await r("CsvFile",[]),!1),isSubmitDisabled:!s.Gifts.length})]})},Ne=()=>{const e=(0,c.useRouter)(),{user:t}=(0,p.a)(),{handleReset:i}=(0,m.V)(),s=(0,l.useMemo)((()=>[{name:"Delivery details",component:ue,validationSchema:ee},{name:"Add recipients",component:be},{name:"Confirm",component:se},{name:"Payment",component:ye,validationSchema:te}]),[]),n=(0,f.V)(s.length,e.query.stepIndex),{value:r}=(0,v.Y)({key:"bulkGiftForm"}),o=(0,l.useMemo)((()=>{var e,i;return{Amount:"0",Category:"all",Gifts:[],ReceiptEmail:"",ReceiptName:"",CopyDetail
1s:!1,PaymentMethod:(null===t||void 0===t||null===(e=t.Account)||void 0===e?void 0:e.PaymentMethodDescriptor)?"":h.XL.CreditCard,SavePaymentMethod:!1,PlantingRegionId:"choose_for_me",SelectPlantingRegion:!1,InvoiceAddress:{InvoiceAddress0:"",InvoiceAddress1:"",InvoiceCity:"",InvoicePostCode:"",InvoiceCountry:"New Zealand"},GiftTemplateId:"",CsvFile:[],DeliveryDetails:{DeliverOn:null,DeliveryDatetimeWhen:y.Immediately,GiftsDestination:j.Recipients,GiftEmailAddress:(null===t||void 0===t||null===(i=t.Account)||void 0===i?void 0:i.Email)||"",ConfirmGiftEmailAddress:!0}}}),[t]);(0,l.useEffect)((()=>{n>0&&!r&&(delete e.query.stepIndex,e.replace({query:{...e.query}}))}),[r,e,n,s.length]);const x=(0,l.useMemo)((()=>{var i,a;const l=t?{ReceiptEmail:null===t||void 0===t||null===(i=t.Account)||void 0===i?void 0:i.Email,ReceiptName:null===t||void 0===t||null===(a=t.Account)||void 0===a?void 0:a.Name}:{},s={...o,...l};return void 0===e.query.stepIndex?{...s}:{...s,...r}}),[e]),g=(0,l.useMemo)((()=>s[n||0].validationSchema),[n,s]);return(0,a.jsx)(d.J9,{enableReinitialize:!0,initialValues:x,onSubmit:()=>{},validationSchema:g,children:e=>{let{resetForm:t,values:l}=e;return(0,a.jsx)(m.O,{amount:l.Amount,children:(0,a.jsx)(d.l0,{className:"min-h-dvh [&_[role=radiogroup]_svg]:fill-lavenderBright! [&_.form-input-wrapper]:rounded-none! [&_.form-label]:hover:text-forestDeep! [&_.form-group:focus-within_.form-label]:text-forestDeep!",children:l.GiftTemplateId?(0,a.jsx)("div",{className:"bg-white p-5 md:p-10",children:(0,a.jsx)(u.x,{steps:s,onReset:()=>{i(),t({values:x})}})}):(0,a.jsx)(F,{})})})}})};var De=()=>{const{setFocussedHeader:e}=(0,s.v)();return(0,l.useEffect)((()=>{e()}),[e]),(0,a.jsx)(o.T3,{title:"Gift certificates for native trees",metaTitle:"Gift certificates for native trees",metaDescription:"Gift a $10 native tree e-gift card, we`ll do the rest. We`ll send your personalised gift certificate to your recipient by email\u2014then we`ll get their native tree to a planting project, and let you both know where.",isFullWidth:!0,children:(0,a.jsxs)(r.f,{backgroundColor:r.u.linen,children:[(0,a.jsx)("div",{className:"col-md-8 offset-md-2 md:mt-10 mb-3 pb-2 text-center",children:(0,a.jsx)(n.S,{variant:"h2",as:"h1",color:"forestDeep",children:(0,a.jsx)("strong",{children:"Order gifts in bulk"})})}),(0,a.jsx)(Ne,{})]})})}},22758:function(e,t,i){"use strict";i.d(t,{W:function(){return l}});var a=i(7258);const l=(e,t,i)=>e?a.Vo((l=>""===l?a.Z_().required(e):a.Rx().typeError("Please enter a valid number").min(t||1,i||"Please enter a number greater than or equal to ".concat(t||1)).required(e))):a.Vo((e=>""===e?a.Z_():a.Rx().typeError("Please enter a valid number")))}},function(e){e.O(0,[5970,509,1255,5666,9759,4053,9503,9249,2156,1317,5850,298,2888,9774,179],(function(){return t=59746,e(e.s=t);var t}));var t=e.O();_N_E=t}]); 2//# sourceMappingURL=bulk-gift-a4069a3f97900ab2.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.