(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[959],{3593:(e,t,r)=>{"use strict";r.d(t,{Search:()=>c});var o=r(5155);r(2115),r(5223);var a=r(63),s=r(6204),n=r(5279),l=r(4536),i=r(2800),d=r(8018);let c=()=>{let e=(0,a.useRouter)(),{dishes:t}=n.J.useGetDishes(),r=t?Array.from(new Set(t.map(e=>e.category))):[];return(0,o.jsx)(d.d.MotionWrapper,{children:(0,o.jsxs)(d.d.SafeAreaView,{children:[(0,o.jsx)(d.d.Header,{title:"Search",showUser:!0,showBasket:!0}),(0,o.jsxs)("main",{style:{marginTop:i.A.sizes.headerHeight,height:"100%",overflowY:"auto",marginBottom:i.A.sizes.tabBarHeight},children:[(0,o.jsx)("div",{style:{marginBottom:30},children:(0,o.jsx)(s.RC,{spaceBetween:10,slidesPerView:"auto",pagination:{clickable:!0},mousewheel:!0,style:{paddingLeft:20,paddingRight:20,paddingTop:18},children:null==r?void 0:r.map(t=>(0,o.jsx)(s.qr,{style:{width:"auto"},children:(0,o.jsx)("button",{style:{borderRadius:5,padding:10,userSelect:"none",backgroundColor:i.A.colors.whiteColor,marginBottom:8,...i.A.flex.columnCenterCenter},onClick:r=>{r.stopPropagation(),e.push("/shop-category/".concat(encodeURIComponent(t)))},children:(0,o.jsx)("span",{style:{fontSize:14,textAlign:"center",fontWeight:600,color:i.A.colors.textColor},children:t})})},t.id))})}),(0,o.jsxs)("section",{children:[(0,o.jsx)(d.d.BlockHeading,{title:"Popular Dishes",href:"/shop/popular",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.isPopular).map(e=>(0,o.jsx)(l.l.PopularItem,{dish:e},e.id))})]})]}),(0,o.jsx)(d.d.BottomTabBar,{}),(0,o.jsx)(d.d.SafeAreaInsetBottom,{})]})})}},5223:()=>{},5279:(e,t,r)=>{"use strict";r.d(t,{J:()=>l});var o=r(5125),a=r(2115);let s="https://george-fx.github.io/yummer-api/",n={GET_OFFERS:"".concat(s,"offers.json"),GET_DISHES:"".concat(s,"dishes.json"),GET_PROMOCODES:"".concat(s,"promocodes.json")},l={useGetDish:e=>{let[t,r]=(0,a.useState)(null),[s,l]=(0,a.useState)(!0),i=async()=>{l(!0);try{var t;let a=await o.A.get(n.GET_DISHES),s=(null!=(t=a.data.dishes)?t:a.data).find(t=>t.id===e);return r(s||null),l(!1),s}catch(e){throw l(!1),console.error("Error fetching dishes:",e),e}};return(0,a.useEffect)(()=>{i()},[e]),{dish:t,isLoading:s}},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,s]=(0,a.useState)(!0),l=async()=>{s(!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{s(!1)}};return(0,a.useEffect)(()=>{l()},[]),{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,s]=(0,a.useState)(!0),l=async()=>{s(!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{s(!1)}};return(0,a.useEffect)(()=>{l()},[]),{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,s]=(0,a.useState)(!0),l=async()=>{s(!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{s(!1)}};return(0,a.useEffect)(()=>{l()},[]),{promocodes:e,loading:r}}}},8085:(e,t,r)=>{Promise.resolve().then(r.bind(r,3593))}},e=>{e.O(0,[992,171,385,125,204,406,18,155,441,315,358],()=>e(e.s=8085)),_N_E=e.O()}]);