(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[620],{3751:(e,t,r)=>{"use strict";r.d(t,{Home:()=>c});var o=r(5155);r(2115),r(5223);var s=r(63),a=r(6204),n=r(5279),d=r(4536),i=r(2800),l=r(8018);let c=()=>{let e=(0,s.useRouter)(),{dishes:t,loading:r}=n.J.useGetDishes(),{offers:c,loading:u}=n.J.useGetOffers();return r||u?(0,o.jsx)(l.d.Loader,{}):(0,o.jsx)(l.d.MotionWrapper,{children:(0,o.jsxs)(l.d.SafeAreaView,{children:[(0,o.jsx)(l.d.Header,{showBasket:!0,showBurger:!0,title:"Yummer",showUser:!0,titleStyle:{fontWeight:500}}),(0,o.jsxs)("main",{style:{overflowY:"auto",marginTop:i.A.sizes.headerHeight,marginBottom:i.A.sizes.tabBarHeight,paddingTop:20,paddingBottom:20},children:[(0,o.jsxs)("section",{style:{marginBottom:40},children:[(0,o.jsx)(l.d.BlockHeading,{title:"Hot offers",href:i.A.routes.offers,containerStyle:{marginBottom:15}}),(0,o.jsx)(a.RC,{spaceBetween:16,slidesPerView:"auto",pagination:{clickable:!0},mousewheel:!0,style:{paddingLeft:20,paddingRight:20},children:null==c?void 0:c.map(t=>(0,o.jsx)(a.qr,{style:{width:"auto"},children:(0,o.jsx)("img",{src:t.image,alt:t.title,style:{width:"100%",maxWidth:300,height:"auto",borderRadius:5,objectFit:"cover"},onClick:()=>{e.push(i.A.routes.dish+"?id=".concat(t.dishId))}})},t.id))})]}),(0,o.jsxs)("section",{children:[(0,o.jsx)(l.d.BlockHeading,{title:"Recommended",href:"/shop/recommended",containerStyle:{marginBottom:16}}),(0,o.jsx)("ul",{style:{...i.A.flex.flexColumn,paddingLeft:20,paddingRight:20,gap:14},children:null==t?void 0:t.filter(e=>e.isRecommended).map(e=>(0,o.jsx)(d.l.RecommendedItem,{dish:e},e.id))})]})]}),(0,o.jsx)(l.d.BottomTabBar,{}),(0,o.jsx)(l.d.SafeAreaInsetBottom,{})]})})}},4780:(e,t,r)=>{Promise.resolve().then(r.bind(r,3751))},5223:()=>{},5279:(e,t,r)=>{"use strict";r.d(t,{J:()=>d});var o=r(5125),s=r(2115);let a="https://george-fx.github.io/yummer-api/",n={GET_OFFERS:"".concat(a,"offers.json"),GET_DISHES:"".concat(a,"dishes.json"),GET_PROMOCODES:"".concat(a,"promocodes.json")},d={useGetDish:e=>{let[t,r]=(0,s.useState)(null),[a,d]=(0,s.useState)(!0),i=async()=>{d(!0);try{var t;let s=await o.A.get(n.GET_DISHES),a=(null!=(t=s.data.dishes)?t:s.data).find(t=>t.id===e);return r(a||null),d(!1),a}catch(e){throw d(!1),console.error("Error fetching dishes:",e),e}};return(0,s.useEffect)(()=>{i()},[e]),{dish:t,isLoading:a}},useFormField:e=>{let[t,r]=(0,s.useState)(e);return{form:t,setForm:r,handleChangeField:(e,o)=>{let s=window.prompt("Enter your ".concat(o),t[e]);null!==s&&r(t=>({...t,[e]:s}))}}},useGetDishes:()=>{let[e,t]=(0,s.useState)([]),[r,a]=(0,s.useState)(!0),d=async()=>{a(!0);try{let e=await o.A.get(n.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{a(!1)}};return(0,s.useEffect)(()=>{d()},[]),{dishes:e,loading:r}},useBodyColor:e=>{(0,s.useEffect)(()=>{let t=document.body.style.backgroundColor;return document.body.style.backgroundColor=e,()=>{document.body.style.backgroundColor=t}},[e])},useGetOffers:()=>{let[e,t]=(0,s.useState)([]),[r,a]=(0,s.useState)(!0),d=async()=>{a(!0);try{let e=await o.A.get(n.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{a(!1)}};return(0,s.useEffect)(()=>{d()},[]),{offers:e,loading:r}},useThemeColor:e=>{(0,s.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,s.useState)([]),[r,a]=(0,s.useState)(!0),d=async()=>{a(!0);try{let e=await o.A.get(n.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{a(!1)}};return(0,s.useEffect)(()=>{d()},[]),{promocodes:e,loading:r}}}}},e=>{e.O(0,[992,171,385,125,204,406,18,155,441,315,358],()=>e(e.s=4780)),_N_E=e.O()}]);