(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[279],{5279:(e,t,r)=>{"use strict";r.d(t,{J:()=>n});var o=r(5125),a=r(2115);let l="https://george-fx.github.io/yummer-api/",s={GET_OFFERS:"".concat(l,"offers.json"),GET_DISHES:"".concat(l,"dishes.json"),GET_PROMOCODES:"".concat(l,"promocodes.json")},n={useGetDish:e=>{let[t,r]=(0,a.useState)(null),[l,n]=(0,a.useState)(!0),d=async()=>{n(!0);try{var t;let a=await o.A.get(s.GET_DISHES),l=(null!=(t=a.data.dishes)?t:a.data).find(t=>t.id===e);return r(l||null),n(!1),l}catch(e){throw n(!1),console.error("Error fetching dishes:",e),e}};return(0,a.useEffect)(()=>{d()},[e]),{dish:t,isLoading:l}},useFormField:e=>{let[t,r]=(0,a.useState)(e);return{form:t,setForm:r,handleChangeField:(e,o)=>{let a=window.prompt("Enter your ".concat(o),t[e]);null!==a&&r(t=>({...t,[e]:a}))}}},useGetDishes:()=>{let[e,t]=(0,a.useState)([]),[r,l]=(0,a.useState)(!0),n=async()=>{l(!0);try{let e=await o.A.get(s.GET_DISHES);if(!e.data)throw Error("No data in response");let r=e.data.dishes||e.data||[];t(r)}catch(e){throw console.error("API request failed:",e),e}finally{l(!1)}};return(0,a.useEffect)(()=>{n()},[]),{dishes:e,loading:r}},useBodyColor:e=>{(0,a.useEffect)(()=>{let t=document.body.style.backgroundColor;return document.body.style.backgroundColor=e,()=>{document.body.style.backgroundColor=t}},[e])},useGetOffers:()=>{let[e,t]=(0,a.useState)([]),[r,l]=(0,a.useState)(!0),n=async()=>{l(!0);try{let e=await o.A.get(s.GET_OFFERS);if(!e.data)throw Error("No data in response");let r=e.data.offers||e.data||[];t(r)}catch(e){throw console.error("API request failed:",e),e}finally{l(!1)}};return(0,a.useEffect)(()=>{n()},[]),{offers:e,loading:r}},useThemeColor:e=>{(0,a.useEffect)(()=>{let t=document.querySelector('meta[name="theme-color"]');t||((t=document.createElement("meta")).setAttribute("name","theme-color"),document.head.appendChild(t));let r=t.getAttribute("content");return t.setAttribute("content",e),()=>{r&&t.setAttribute("content",r)}},[e])},useGetPromocodes:()=>{let[e,t]=(0,a.useState)([]),[r,l]=(0,a.useState)(!0),n=async()=>{l(!0);try{let e=await o.A.get(s.GET_PROMOCODES);if(!e.data)throw Error("No data in response");let r=e.data.promocodes||e.data||[];t(r)}catch(e){throw console.error("API request failed:",e),e}finally{l(!1)}};return(0,a.useEffect)(()=>{n()},[]),{promocodes:e,loading:r}}}},6449:(e,t,r)=>{"use strict";r.d(t,{Checkout:()=>u});var o=r(5155),a=r(63),l=r(2115),s=r(5279),n=r(2800),d=r(8018);let u=()=>{s.J.useThemeColor("#EEF3FC"),s.J.useBodyColor("#EEF3FC");let e=(0,a.useRouter)(),[t,r]=(0,l.useState)(0),u=(0,l.useRef)(null);(0,l.useEffect)(()=>{u.current&&r(u.current.offsetHeight)},[]);let{form:c,handleChangeField:i}=s.J.useFormField({fullName:"",address:"",phoneNumber:"",cardNumber:"",expiryDate:"",cvv:""});return(0,o.jsx)(d.d.MotionWrapper,{children:(0,o.jsxs)(d.d.SafeAreaView,{children:[(0,o.jsx)(d.d.Header,{showGoBack:!0,title:"Checkout"}),(0,o.jsxs)("main",{style:{marginTop:n.A.sizes.headerHeight,marginBottom:t,padding:20,overflowY:"auto"},children:[(0,o.jsxs)("section",{style:{marginBottom:30},children:[(0,o.jsx)("h4",{style:{marginBottom:14,...n.A.typography.h4},children:"Shipping Details"}),(0,o.jsxs)("div",{style:{...n.A.flex.flexColumn,gap:20},children:[(0,o.jsx)(d.d.Input,{label:"Name",placeholder:"Kristin Watson",value:c.fullName,onClickAction:()=>i("fullName","fullName")}),(0,o.jsx)(d.d.Input,{label:"Address",placeholder:"8000 S Kirkland Ave, Chicago, IL 6065...",value:c.address,onClickAction:()=>i("address","address")}),(0,o.jsx)(d.d.Input,{label:"Phone Number",placeholder:"+17123456789",value:c.phoneNumber,onClickAction:()=>i("phoneNumber","phoneNumber")})]})]}),(0,o.jsxs)("section",{style:{marginBottom:20},children:[(0,o.jsx)("h4",{style:{marginBottom:14,...n.A.typography.h4},children:"Card Details"}),(0,o.jsxs)("div",{style:{...n.A.flex.flexColumn,gap:20},children:[(0,o.jsx)(d.d.Input,{label:"Card Number",value:c.cardNumber,placeholder:"7741 ******** 6644",onClickAction:()=>i("cardNumber","Card Number")}),(0,o.jsx)(d.d.Input,{label:"Expiry Date",value:c.expiryDate,placeholder:"01/26",onClickAction:()=>i("expiryDate","MM/YY")}),(0,o.jsx)(d.d.Input,{label:"CVV",value:c.cvv,placeholder:"123",onClickAction:()=>i("cvv","CVV")})]})]}),(0,o.jsx)(d.d.SafeAreaInsetBottom,{})]}),(0,o.jsx)("div",{ref:u,style:{padding:20,backgroundColor:n.A.colors.whiteColor,borderTop:"1px solid #E2E2E2",position:"fixed",bottom:"env(safe-area-inset-bottom)",left:0,right:0},children:(0,o.jsx)(d.d.Button,{label:"Place Order",onClickAction:()=>{e.push(n.A.routes.OrderSuccess)}})})]})})}},6505:(e,t,r)=>{Promise.resolve().then(r.bind(r,6449))}},e=>{e.O(0,[171,385,125,406,18,441,315,358],()=>e(e.s=6505)),_N_E=e.O()}]);