1import{j as e,V as P,bJ as Y,a2 as H,ah as W,ai as K,at as Z,al as v,am as B,an as F,ao as $,E as _,F as I,ap as X,ce as ee,cf as te,aq as se,as as ae,b as re,cg as ne,au as le,c5 as D,av as oe,bh as ie,b_ as de,c7 as ce,L as me}from"./index-2ed27e87.js";import{r as n,B as r,k as xe,d as ue}from"./utils-40ed1a82.js";import{C as fe}from"./page-1e49cfbd.js";import{a as pe}from"./animation_writing-5f952e60.js";const U=({imageUrl:t,width:l=400,height:s=200})=>e.jsx("div",{className:`relative w-[${l}px] h-[${s}px]`,children:e.jsx("div",{className:`w-[${l/1.2}px] lg:w-[${l}px] h-[${s}px] bg-center bg-no-repeat bg-[length:${l*2}px]`,style:{backgroundImage:`url(${t})`}})}),ye=({groupCreative:t,OnGuestOrderClick:l,onSignUpClick:s})=>e.jsxs("div",{className:"flex flex-col lg:flex-row py-20 justify-between w-full",children:[e.jsxs("div",{className:"w-full lg:w-1/2 text-secondary text-2xl lg:text-3xl font-PlayfairRegular flex flex-col",children:[e.jsxs("p",{children:["Would You Like to Order a Copy of ",t==null?void 0:t.remembered_full_name,"âs Lifebook or Request to Contribute to a New Volume"]}),e.jsxs("div",{className:"flex flex-col gap-4 md:gap-0 md:flex-row py-8 justify-between",children:[e.jsx(P,{text:"Order a Copy Now",onClick:l}),e.jsx(P,{text:"Request to Contribute",onClick:s})]})]}),e.jsx("div",{className:"w-full lg:w-1/2 flex justify-center items-center m-auto",children:e.jsx(U,{imageUrl:Y})})]}),he=({setUIAfterCoupon:t,refresh:l,copies:s,userData:i,onSubmit:c,headingCount:u=2,updatedPrice:f,groupCreative:p})=>{const{createModal:x,removeModal:o}=H(),d=W(),h=K(),[C,j]=n.useState(!1),[m,w]=n.useState({coupon:"",nameOnCard:""}),[A,R]=n.useState(""),[k,y]=n.useState(!1),N=a=>{a.key==="Enter"&&E()},E=async a=>{if(a.preventDefault(),m.coupon=="")return;if(parseInt(s)<=0){r.info("1 minimum copy required");return}const{data:g,status:O}=await _.post(`${I}/payments/test/validate_coupon/`,{coupon:m.coupon,numberOfBooks:s,type:"signup"});if(O==200)if(g.valid)t({amount_off:g.amount_off,percent_off:g.percent_off}),r.info("Coupon applied");else{t(0),r.info(g.message);return}},T=async()=>{try{if(parseInt(s)<=0)return r.info("1 minimum copy required"),!1;if(!ee(i.phone_number)){r.error("Please enter valid phone number");return}if(!te(i.email)){r.error("Please enter valid email");return}if(m.nameOnCard.length<=0)return r.info("Your name for cardholder is empty"),!1;const a=h.getElement(B),g=h.getElement($),O=h.getElement(F);if(!a||!g||!O)return console.error("One or more elements are not found"),!1;const{data:S,status:V}=await _.post(`${I}/payments/test/createpaymentintent/`,{items:[{id:"xl-tshirt"}],number_of_books:parseInt(s),coupon:m.coupon,type:"qr"});if(V==200){if(S.isFree)return!0;if(S.error)return r.info(S.error),!1}R(S.client_secret);const{paymentMethod:Q,error:G}=await d.createPaymentMethod({type:"card",card:a,billing_details:{name:m.nameOnCard}});if(G)return console.log(G.message),r.info(G.message),!1;const{paymentIntent:z,error:L}=await d.confirmCardPayment(S.client_secret,{payment_method:Q.id});return L?(console.error(L),r.info(L.code),!1):z.status==="succeeded"?(r.info("Payment Successful"),!0):(console.log("No error, but payment failed"),r.info("Payment Failed"),!1)}catch(a){return r.info(a.message),!1}},q=async a=>{a.preventDefault(),x(e.jsx(X,{booksToOrder:s,price:f,confirmPayment:J,closeModal:()=>o()}))};n.useEffect(()=>{k&&x(e.jsx(Z,{closeModal:()=>{o()},groupName:p.name||""}))},[k]);const J=async a=>{j(!0),a(!0);try{await T()===!0?(await c(),r.info("Order Complete"),j(!1),a(!1),w({...m,coupon:""}),typeof l=="function"&&l(),y(!0)):(j(!1),a(!1))}catch(g){j(!1),a(!1),xe(g)}};return e.jsxs("div",{className:"flex flex-col gap-2 lg:w-1/2",children:[e.jsx(v,{count:u,text:"Credit Card Info"}),e.jsx("label",{className:"text-2xl font-EBGaramondSemibold text-secondary",children:"Name on Card"}),e.jsx("div",{className:"border-2 border-secondary rounded-md font-EBGaramondRegular text-secondary text-l",children:e.jsx("input",{type:"text",placeholder:"Name",onChange:a=>w({...m,nameOnCard:a.target.value}),className:"w-full outline-none bg-transparent py-1 px-3 placeholder:text-secondary"})}),e.jsx("label",{className:"text-2xl font-EBGaramondSemibold text-secondary",children:"Card Number"}),e.jsx("div",{className:"border-2 border-secondary rounded-md font-EBGaramondRegular text-secondary text-2xl",children:e.jsx(B,{className:"w-full outline-none bg-transparent py-1.5 px-3 placeholder:text-secondary"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full",children:[e.jsx("label",{className:"text-2xl font-EBGaramondSemibold text-secondary",children:"CVC"}),e.jsx("div",{className:"border-2 border-secondary rounded-md font-EBGaramondRegular text-secondary text-2xl",children:e.jsx(F,{className:"w-full outline-none bg-transparent py-1.5 px-3 placeholder:text-secondary"})})]}),e.jsxs("div",{className:"w-full",children:[e.jsx("label",{className:"text-2xl font-EBGaramondSemibold text-secondary",children:"Expiry"}),e.jsx("div",{className:"border-2 border-secondary rounded-md font-EBGaramondRegular text-secondary text-2xl",children:e.jsx($,{className:"w-full outline-none bg-transparent py-1.5 px-3 placeholder:text-secondary"})})]})]}),e.jsx("label",{className:"text-2xl font-EBGaramondSemibold text-secondary",children:"Coupon Code"}),e.jsxs("div",{className:"border-2 border-secondary rounded-md font-EBGaramondRegular text-secondary text-l flex flex-row",children:[e.jsx("input",{type:"text",placeholder:"Coupon Code",onKeyDown:N,value:m.coupon,onChange:a=>w({...m,coupon:a.target.value}),className:"w-full outline-none bg-transparent py-1 px-3 placeholder:text-secondary"}),e.jsx("button",{onClick:a=>E(a),className:"border border-secondary text-secondary rounded-full px-4 py-0.5 m-2 hover:bg-secondary hover:text-white",children:"Apply"})]}),e.jsx("div",{className:"mt-10",children:e.jsx("button",{disabled:C,type:"submit",onClick:a=>q(a),className:" cursor-pointer disabled:opacity-50 transition-all duration-200 bg-secondary inline px-10 py-3 rounded-xl font-EBGaramondRegular text-2xl text-primary",children:"Purchase"})})]})},ge=se("pk_live_51LzqUCADJ1tN1mO2gsLvmDGlzHHbe7yqGbN9MSO5074CxwRuLeP80YSNrdNbVrnLw7rjUJqPZFejuWxa8Bw1G4hF00QGHW7UgV"),be=[{type:"text",placeholder:"Shipping Address*",key:"address",rowIndex:0,isAddress:!0},{type:"text",placeholder:"Billing Address*",key:"billing_address",rowIndex:1,isAddress:!0},{type:"text",placeholder:"City*",key:"city",rowIndex:2},{type:"text",placeholder:"State*",key:"state",rowIndex:3},{type:"text",placeholder:"Zip*",key:"zip",rowIndex:3}],je=[{type:"text",placeholder:"First Name*",key:"first_name",rowIndex:0},{type:"text",placeholder:"Last Name*",key:"last_name",rowIndex:0},{type:"text",placeholder:"Email*",key:"email",rowIndex:1},{type:"text",placeholder:"Phone Number*",key:"phone_number",rowIndex:2}],we=({groupCreative:t,userId:l="guest"})=>{const[s,i]=n.useState(0),[c,u]=n.useState(0),[f,p]=n.useState(0),[x,o]=n.useState({address:"",city:"",state:"",zip:"",b
1illing_address:""}),[d,h]=n.useState({first_name:"",last_name:"",email:"",phone_number:""}),{data:C,isLoading:j,isError:m,refetch:w}=ae(t.id);n.useEffect(()=>{const y=re(parseInt(s)||0,c.amount_off||0,c.percent_off||0,!1,1);p(y)},[s,c]);const A=(y,N)=>{h({...d,[N]:y})},R=(y,N)=>{o({...x,[N]:y})},k=async()=>{const y=`${I}/group-creatives/order/create_order/`,N={address:x,groupCreative:t.id,copies:s,order_by:l,first_name:d.first_name,last_name:d.last_name,email:d.email,phone_number:d.phone_number,billing_address:x.billing_address};try{const{data:E,status:T}=await _.post(y,N);w(t.id),u(0)}catch(E){console.error("Error submitting the order:",E)}};return e.jsx("div",{children:e.jsxs("div",{className:"flex h-screen flex-col lg:flex-row justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 font-EBGaramondRegular text-secondary",children:[e.jsx("p",{className:"text-4xl font-PlayfairRegular py-4",children:"Order & Reserve"}),e.jsx("p",{className:"text-2xl font-PlayfairRegular",children:"Next Print Date: January 11th, 2025"}),e.jsx("div",{className:"border-[3px] rounded-2xl relative border-secondary flex justify-between",children:e.jsxs("div",{className:"p-5",children:[e.jsxs("p",{className:"font-bold text-xl",children:["Price per copy: $",ne]}),e.jsxs("p",{className:"font-bold text-xl",children:["Total Amount: $",f]})]})}),e.jsx("form",{children:e.jsxs("div",{className:"w-full flex flex-col lg:flex-row justify-between text-xl gap-10 text-[#757E8C]",children:[e.jsxs("div",{className:"flex flex-col gap-y-2 w-full lg:w-1/2",children:[e.jsx(v,{count:1,text:"Copies"}),e.jsx(le,{type:"number",placeholder:"Number of copies",value:s,onChangeValue:i,label:"Number of copies",min:0}),e.jsx(v,{count:2,text:"User Info"}),e.jsx(D,{formFields:je,onChange:A}),e.jsx(v,{count:3,text:"Address"}),e.jsx(D,{formFields:be,onChange:R})]}),e.jsx(oe,{stripe:ge,children:e.jsx(he,{setUIAfterCoupon:u,copies:s,userData:d,onSubmit:k,headingCount:4,updatedPrice:f,groupCreative:t})})]})})]}),e.jsx("div",{children:e.jsx(fe,{isLoading:j,contributorsData:C,totalText:"Total Lifebooks Ordered",numberText:"Books Ordered"})})]})})},Ne=({message:t})=>e.jsx("div",{className:"fixed z-100 h-screen w-screen",children:e.jsx("div",{className:"flex w-full h-full justify-center items-center m-auto",children:e.jsx("p",{className:"text-5xl text-secondary font-PlayfairRegular",children:t})})}),Ce=[{type:"text",label:"First Name",key:"firstName",rowIndex:0},{type:"text",label:"Last Name",key:"lastName",rowIndex:0},{type:"text",label:"Email",key:"email",rowIndex:1},{type:"text",label:"Confirm Email",key:"confirmEmail",rowIndex:2},{type:"password",label:"Password",key:"password",rowIndex:3},{type:"password",label:"Confirm Password",key:"confirmPassword",rowIndex:4}],Ee=({groupCreative:t,setCurrentStage:l})=>{const[s,i]=n.useState({firstName:"",lastName:"",email:"",confirmEmail:"",password:"",confirmPassword:"",role:ie.user}),c=(f,p)=>{i({...s,[p]:f})},u=async()=>{if(!Object.values(s).every(o=>o.trim()!=="")){r.error("Please fill in all fields.");return}if(s.email!==s.confirmEmail){r.error("Email and Confirm Email not same.");return}if(s.password!==s.confirmPassword){r.error("Password and Confirm Password not same.");return}const p=`${I}/core/auth/new-user/`,x={userData:{email:s.email,password:s.password,first_name:s.firstName,last_name:s.lastName,role:s.role},groupCreative:t.id};try{const{data:o,status:d}=await _.post(p,x);d==200?(r.success(o.detail),localStorage.setItem("userId",o.user),l(1)):r.error(o.detail)}catch(o){r.error(o),console.error("Error submitting the order:",o)}};return e.jsxs("div",{className:"flex flex-col lg:flex-row w-full",children:[e.jsxs("div",{className:"flex flex-col text-secondary font-PlayfairRegular gap-8 w-full lg:w-1/2",children:[e.jsxs("p",{className:"text-2xl lg:text-3xl",children:["Join the ",t==null?void 0:t.name," Lifebook Creative and Contribute to ",t==null?void 0:t.remembered_full_name,"âs Lifebook"]}),e.jsx(D,{formFields:Ce,onChange:c}),e.jsx(P,{text:"Continue",onClick:u})]}),e.jsx("div",{className:"hidden lg:flex w-full lg:w-1/2 flex justify-center items-center m-auto",children:e.jsx(U,{imageUrl:pe,width:400,height:500})})]})},Se="/assets/animation_family_together-b614cb7b.svg",_e=({groupCreative:t,setCurrentStage:l,OnGuestOrderClick:s})=>{const i=()=>{s()};return e.jsxs("div",{className:"flex flex-col lg:flex-row py-8 gap-8 lg:gap-0",children:[e.jsxs("div",{className:"flex flex-col text-secondary font-PlayfairRegular gap-8 w-full lg:w-1/2",children:[e.jsxs("p",{className:"text-2xl lg:text-3xl",children:["Thank you for joining ",t==null?void 0:t.remembered_full_name,"âs Lifebook Creative. The next contributing window opens on [insert date], and we will notify you when you can begin adding your contributions to ",t==null?void 0:t.name,"âs Lifebook."]}),e.jsx(P,{text:"Request to Purchase the Current Volume",onClick:i})]}),e.jsx("div",{className:"w-[98%] lg:w-1/2 flex justify-center items-center m-auto",children:e.jsx(U,{imageUrl:Se,width:400,height:400})})]})},M=[{title:"Sign up",element:t=>e.jsx(Ee,{...t})},{title:"Order Now",element:t=>e.jsx(_e,{...t})}],Ie=({groupCreative:t,OnGuestOrderClick:l})=>{const[s,i]=n.useState(0);return e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(de,{allStages:M,currentStage:s}
1),M[s].element({groupCreative:t,setCurrentStage:i,OnGuestOrderClick:l})]})},b=Object.freeze({INITIAL:"initial",GUEST_ORDER:"guestOrder",JOIN:"join",ERROR:"error"}),Oe=()=>{const[t,l]=ue(),s=t.get("group_id"),[i,c]=n.useState(b.INITIAL),[u,f]=n.useState(),[p,x]=n.useState(!0),[o,d]=n.useState();n.useEffect(()=>{(async()=>{const{data:m,status:w}=await _.get(`${I}/group-creatives/${s}`);w==200?(f(m),x(!1),c(b.INITIAL)):(x(!1),c(b.ERROR),d("Error retrieving group creative"))})()},[s]);const h=()=>{c(b.GUEST_ORDER)},C=()=>{c(b.JOIN)};return e.jsxs("div",{className:"flex flex-col p-12",children:[e.jsx("div",{className:"hidden md:flex",children:e.jsx(ce,{})}),p?e.jsx("div",{className:"w-full h-full flex justify-center items-center m-auto",children:e.jsx(me,{})}):i==b.INITIAL?e.jsx(ye,{groupCreative:u,OnGuestOrderClick:h,onSignUpClick:C}):i==b.GUEST_ORDER?e.jsx(we,{groupCreative:u,userId:localStorage.getItem("userId")||"guest"}):i==b.JOIN?e.jsx(Ie,{groupCreative:u,OnGuestOrderClick:h}):e.jsx(Ne,{message:o||"Something went wrong"})]})};export{b as QRFlowPage,Oe 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.