(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[879],{1809:(e,t,r)=>{Promise.resolve().then(r.bind(r,2665))},2665:(e,t,r)=>{"use strict";r.d(t,{ShopCategory:()=>u});var o=r(5155),a=r(2115),s=r(5279),n=r(4536),l=r(2800),d=r(8018);let u=e=>{let{category:t}=e,r=t?decodeURIComponent(t):"",{dishes:u,loading:i}=s.J.useGetDishes(),c=u&&u.length>0?u:[],h=(0,a.useMemo)(()=>r?c.filter(e=>{var t;return(null==e||null==(t=e.category)?void 0:t.toLowerCase())===r.toLowerCase()}):[],[c,r]);return i?(0,o.jsx)(d.d.Loader,{}):(0,o.jsx)(d.d.MotionWrapper,{children:(0,o.jsxs)(d.d.SafeAreaView,{children:[(0,o.jsx)(d.d.Header,{showGoBack:!0,showBasket:!0,title:(e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" "):"Shop")(r)}),h&&0!==h.length?(0,o.jsx)("main",{style:{marginTop:l.A.sizes.headerHeight,padding:"18px 20px 20px 20px",overflowY:"auto"},children:(0,o.jsx)("ul",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:15},children:h.map(e=>(0,o.jsx)(n.l.ShopItem,{dish:e},e.id))})}):null]})})}},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),d=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)(()=>{d()},[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}}}}},e=>{e.O(0,[171,385,125,406,18,155,441,315,358],()=>e(e.s=1809)),_N_E=e.O()}]);