@restaround/react 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/events.d.ts +4 -0
- package/dist/hooks/category.d.ts +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/ui.css +1 -1
- package/dist/styles/ui.css.map +1 -1
- package/dist/utils/category.d.ts +1 -0
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/index.esm.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils/category.d.ts +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const CATEGORY_SELECTED = "digital_menu_category_select";
|
|
2
|
+
export declare const CATEGORY_SCROLLED = "digital_menu_category_scroll";
|
|
3
|
+
export declare const PRODUCT_DETAILS = "digital_menu_product_details";
|
|
4
|
+
export declare const PRODUCT_ADD_CART = "digital_menu_product_add_cart";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCategoryNameById: (categoryId: number) => string;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import{createContext as a,useContext as i,useState as n,useRef as o,useEffect as l,useMemo as d,memo as c}from"react";import{isEmpty as s,priceFormatter as u,classNames as m}from"@sorocraft/js-utils";import{Row as _,classNames as h,IconLink as g,Tooltip as p,SVGIcon as v,Flex as f,Column as y,Carousel as b,CarouselItem as C,Chip as P,UIElementType as I,IconButton as A,Modal as N,Button as w,Drawer as O,Text as k,Description as L,Container as S,Card as D}from"@sorocraft/ui";import{Phone as T,Whatsapp as z,Instagram as j,Telegram as x,Tiktok as R,Facebook as Q,Wifi as W,MarkerPin as H,Plus as B,Minus as E,Close as q}from"@sorocraft/ui/icons";function Y(e,t){var r={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(r[a[i]]=e[a[i]])}return r}function M(e,t,r,a){return new(r||(r=Promise))((function(i,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function l(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,l)}d((a=a.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var F="PublicMenu-module_container__QLN6U",U="PublicMenu-module_categories__Iy6NC",V="PublicMenu-module_footer__6G3DQ";const $="https://images.restaround.co",G=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"",Z=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/no-photo-128.webp",K=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${$}/${e}`:"https://images.restaround.co/restaround-doodle.webp",X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",J=(e,t,r)=>X.charAt(e>>2)+X.charAt((3&e)<<4|t>>4)+X.charAt((15&t)<<2|r>>6)+X.charAt(63&r),ee="restaround.co",te=[ee,"restaround.az","restaround.ee","restaround.nl"],re=a({}),ae=({children:t,value:r})=>{const a=s(r)?{}:r;return a.currency||a.currency,a.language||a.language,e(re.Provider,{value:s(r)?{}:r,children:t})},ie=()=>i(re);var ne="Header-module_container__tenlF",oe="Header-module_cover__BAWZK",le="Header-module_content__Gx4Al",de="Header-module_logo__4MTCm",ce="Header-module_info__IchYA",se="Header-module_name__30wyw",ue="Header-module_address__WOxXc",me="Header-module_addressText__lUszI",_e="Header-module_social__AoP0z",he="Header-module_links__EeQxg",ge="Header-module_wifiPassword__VWBTa",pe="Header-module_wifiPasswordIcon__Ukn3D";const ve=t=>{const r=Y(t,["priority","blurDataURL","quality","placeholder","fetchPriority"]),{imageTag:a}=ie()||{};if(a){return e(a,Object.assign({},t,{quality:t.quality||100,placeholder:"blur",blurDataURL:(i=235,n=59,o=90,`data:image/gif;base64,R0lGODlhAQABAPAA${J(0,i,n)+J(o,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`)}))}var i,n,o;return e("img",Object.assign({},r))};var fe={container:"Languages-module_container__nJeK1",currentLanguage:"Languages-module_currentLanguage__EFw6Q",options:"Languages-module_options__6jLRm",option:"Languages-module_option__QkVQd",isOpen:"Languages-module_isOpen__eUGbg",flexWide:"Languages-module_flexWide__zQ9jN",slidein:"Languages-module_slidein__C4UHU",fadeInOut:"Languages-module_fadeInOut__U-vhH",heightAnimation:"Languages-module_heightAnimation__gIQkF",fadein:"Languages-module_fadein__vPmsX",floatAnimation:"Languages-module_floatAnimation__L-kPH",bottomSheet:"Languages-module_bottomSheet__-t-q8",slideRightToLeft:"Languages-module_slideRightToLeft__y0l-f"};const ye=()=>{var r;const{language:a,languages:i,onLanguageSelect:o}=ie(),[l,d]=n(!1),c=(null==i?void 0:i.length)>1,s=(null===(r=null==i?void 0:i.filter)||void 0===r?void 0:r.call(i,(({code:e})=>e!==a)))||[],u=e=>`https://images.restaround.co/languages/${e}.svg`;return c?e("div",{className:fe.container,onClick:()=>d(!l),children:t(_,{alignItems:"center",gap:0,children:[e(_,{alignItems:"center",className:h(fe,{options:!0,isOpen:l}),children:s.map((({code:t})=>e("img",{src:u(t),className:fe.option,onClick:()=>(e=>{o&&o(e)})(t),alt:t},t)))}),e("img",{src:u(a),alt:a||"",className:fe.currentLanguage})]})}):null},be=({branch:r,coverImage:a,logoImage:i,name:n,instagram:o,facebook:l,whatsapp:d,telegram:c,tiktok:u})=>{const{address:m,latitude:h,longitude:b,phone:C,wifiPassword:P}=r||{},I=s(r),A=`https://www.google.com/maps/place/${h},${b}`;return t("div",{className:ne,children:[e(ve,{src:a,alt:n,className:oe,width:1024,height:400,priority:!0,sizes:"100vw",fetchPriority:"high",loading:"eager"}),e("div",{className:le,children:e(I?()=>t(y,{fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",children:[e(ve,{src:i,alt:n,className:de,width:96,height:96}),e("div",{className:ce,children:e("h1",{className:se,children:n})})]}):()=>t(f,{direction:"row",gap:1,alignItems:"center",children:[e(f.Item,{children:e(ve,{src:i,alt:n,className:de,width:96,height:96})}),e(f.Item,{shrink:!0,children:e("div",{className:ce,children:t(y,{gap:.25,children:[e("h1",{className:se,children:n}),e("a",{className:ue,href:A,target:"_blank",rel:"noopener noreferrer",children:t(_,{alignItems:"center",gap:.5,children:[e(v,{icon:H,theme:"dark"}),e("span",{className:me,children:m})]})})]})})})]}),{})}),e(ye,{}),!I&&e("div",{className:_e,children:e("div",{className:he,children:e(_,{gap:2,alignItems:"center",children:t(_,{alignItems:"center",justifyContent:"center",gap:.5,children:[!!C&&e(g,{icon:T,href:`tel:+${C}`,size:"sm",shape:"circle",theme:"light"}),!!d&&e(g,{icon:z,href:`https://wa.me/${d}`,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!o&&e(g,{icon:j,href:o,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!c&&e(g,{icon:x,href:c,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!u&&e(g,{icon:R,href:u,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!l&&e(g,{icon:Q,href:l,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!P&&e(p,{hint:P,children:e("div",{className:ge,children:e(v,{icon:W,size:"sm",className:pe})})})]})})})})]})},Ce=({categoryProductMap:t=[],language:r,selectedCategoryId:a,onSelectCategory:i})=>{const n=o({}),d=o(null);return l((()=>{a&&(()=>{var e;const t=null===(e=null==n?void 0:n.current)||void 0===e?void 0:e[a];if(!t||!d.current)return;const r=d.current.clientWidth,i=t.offsetLeft-r/2+t.offsetWidth/2;d.current.scrollTo({left:i,behavior:"smooth"})})()}),[a]),e("div",{className:U,children:e(b,{gap:1,onGetRef:e=>{(null==e?void 0:e.current)&&(d.current=e.current)},children:(t||[]).map((({id:t,translations:o})=>{const{name:l}=o.find((e=>e.language===r))||{};return e(C,{children:e(P,{onClick:()=>(e=>{e!==a&&i(e)})(t),type:I.BORDERED_PRIMARY,active:t===a,children:e("div",{ref:e=>n.current[t]=e,children:l})})},t)}))})})};var Pe="Products-module_container__bF2LF",Ie="Products-module_products__AoDrY",Ae="Products-module_category__Sp7dE",Ne="Products-module_list__LH4v5";const we=a({cart:{},isCartOpen:!1,addProduct:()=>{},updateProduct:()=>{},setIsCartOpen:()=>{}}),Oe=({children:t})=>{const[r,a]=n({}),[i,o]=n(!1),l=(e,t,r)=>{if(s(e)||t<0)return;const{id:i,price:n,vat:o=0}=e;a((e=>{const a=e[i],l=r?((null==a?void 0:a.quantity)||0)+t:t;if(l<=0){const t=e,r=i;t[r];return Y(t,["symbol"==typeof r?r:r+""])}return Object.assign(Object.assign({},e),{[i]:{productId:i,price:n,quantity:l,vat:o}})}))},c=(e,t=1)=>l(e,t,!0),u=(e,t=1)=>l(e,t,!1),m=d((()=>({cart:r,isCartOpen:i,addProduct:c,updateProduct:u,setIsCartOpen:o})),[r,i]);return e(we.Provider,{value:m,children:t})},ke=()=>i(we);var Le={container:"ProductsListItem-module_container__i9tFs",isClickable:"ProductsListItem-module_isClickable__iHHdI",data:"ProductsListItem-module_data__Mb3SF",name:"ProductsListItem-module_name__T1gyJ",description:"ProductsListItem-module_description__oL4CH",price:"ProductsListItem-module_price__V1GRM",image:"ProductsListItem-module_image__h6Wbi",addToCart:"ProductsListItem-module_addToCart__WXrQZ",flexWide:"ProductsListItem-module_flexWide__Ds6LE",slidein:"ProductsListItem-module_slidein__rEzMI",fadeInOut:"ProductsListItem-module_fadeInOut__i1FNq",heightAnimation:"ProductsListItem-module_heightAnimation__2fk7l",fadein:"ProductsListItem-module_fadein__tPTJ6",floatAnimation:"ProductsListItem-module_floatAnimation__vugAV",bottomSheet:"ProductsListItem-module_bottomSheet__-YAdd",slideRightToLeft:"ProductsListItem-module_slideRightToLeft__oXk26"};const Se=(e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}},De=(e,t,r=0)=>e*t*(1+r/100),Te=(e,t,r,a=1)=>{const{price:i,vat:n}=e||{},o=De(i,a,n);return{totalPrice:o,formattedTotalPrice:u(o,t,r)}},ze=({product:r,currency:a,language:i,onClick:n})=>{const{addProduct:o}=ke(),{image160:l,volume:c}=r||{},{name:s,description:u}=d((()=>Se(r,i)),[r,i]),{formattedTotalPrice:h}=d((()=>Te(r,a,i)),[r,a,i]);return t("div",{className:m(Le,{container:!0,isClickable:!!n}),onClick:n,children:[t(_,{justifyContent:"space-between",gap:0,children:[e("div",{className:Le.data,children:t(y,{gap:.25,children:[e("h3",{className:Le.name,children:t(_,{gap:.5,fullWidth:!0,children:[e("span",{children:s}),!!c&&t("span",{children:["(",c,")"]})]})}),e("div",{className:Le.description,children:u}),e("div",{className:Le.price,children:h})]})}),l&&e(ve,{src:G(l),alt:s||"menu",className:Le.image,loading:"lazy",width:160,height:90})]}),e("div",{className:Le.addToCart,children:e(A,{onClick:e=>{e.preventDefault(),e.stopPropagation(),o(r)},icon:B,type:I.DEFAULT})})]})};var je={container:"ProductDetails-module_container__oa07j",content:"ProductDetails-module_content__Db3NC",image:"ProductDetails-module_image__BlMfl",details:"ProductDetails-module_details__zfnlt",name:"ProductDetails-module_name__ganLM",price:"ProductDetails-module_price__W34k9",volume:"ProductDetails-module_volume__RWG5s",description:"ProductDetails-module_description__HBufi",close:"ProductDetails-module_close__4cHZ3",addAction:"ProductDetails-module_addAction__o4T5R",actionTitle:"ProductDetails-module_actionTitle__NIJGW",flexWide:"ProductDetails-module_flexWide__w06FX",slidein:"ProductDetails-module_slidein__N8f4g",fadeInOut:"ProductDetails-module_fadeInOut__hYRtK",heightAnimation:"ProductDetails-module_heightAnimation__hLQyz",fadein:"ProductDetails-module_fadein__QN4mI",floatAnimation:"ProductDetails-module_floatAnimation__dTQbc",bottomSheet:"ProductDetails-module_bottomSheet__HO2S-",slideRightToLeft:"ProductDetails-module_slideRightToLeft__hbtJg"};const xe={en:{viewOrder:"View order",removeFromOrder:"Remove from order",updateOrder:"Update order",addToOrder:"Add to order"},az:{viewOrder:"Şifarişi göstər",removeFromOrder:"Sifarişdən sil",updateOrder:"Sifarişi yenilə",addToOrder:"Sifarişə əlavə et","Your order":"Sifarişiniz",Subtotal:"Ümumi","Empty order":"Boş sifariş","You don't have any items in your order":"Sifarişinizdə heç bir məhsul yoxdur","Add items":"Məhsul əlavə et"},tr:{viewOrder:"Siparişi Görüntüle",removeFromOrder:"Siparişten Kaldır",updateOrder:"Siparişi Güncelle",addToOrder:"Siparişe Ekle","Your order":"Siparişiniz","Empty order":"Boş sipariş","You don't have any items in your order":"Siparişinizde hiç bir ürün yok","Add items":"Ürün ekle",Subtotal:"Toplam"},nl:{viewOrder:"Bestelling bekijken",removeFromOrder:"Uit bestelling verwijderen",updateOrder:"Bestelling bijwerken",addToOrder:"Aan bestelling toevoegen","Your order":"Uw bestelling","Empty order":"Lege bestelling","You don't have any items in your order":"U heeft geen items in uw bestelling","Add items":"Items toevoegen",Subtotal:"Totaal"},et:{viewOrder:"Vaata tellimust",removeFromOrder:"Eemalda tellimusest",updateOrder:"Uuenda tellimust",addToOrder:"Lisa tellimusele","Your order":"Teie tellimus","Empty order":"Tühi tellimus","You don't have any items in your order":"Teie tellimuses pole ühtegi eset","Add items":"Lisa esemeid",Subtotal:"Kokku"},pl:{viewOrder:"Zobacz zamówienie",removeFromOrder:"Usuń z zamówienia",updateOrder:"Zaktualizuj zamówienie",addToOrder:"Dodaj do zamówienia","Your order":"Twoje zamówienie","Empty order":"Puste zamówienie","You don't have any items in your order":"Nie masz żadnych pozycji w zamówieniu","Add items":"Dodaj przedmioty",Subtotal:"Suma"},ru:{viewOrder:"Посмотреть заказ",removeFromOrder:"Удалить из заказа",updateOrder:"Обновить заказ",addToOrder:"Добавить в заказ","Your order":"Ваш заказ","Empty order":"Пустой заказ","You don't have any items in your order":"В вашем заказе нет товаров","Add items":"Добавить товары",Subtotal:"Итого"}},Re=()=>{const{language:e}=ie();return{t:t=>{var r;return(null===(r=xe[e])||void 0===r?void 0:r[t])||t}}},Qe=()=>{const{cart:e}=ke();return Object.values(e||{}).reduce(((e,t)=>e+t.quantity),0)};var We={container:"Quantity-module_container__01ySb",quantityAction:"Quantity-module_quantityAction__wRV2F",quantityValue:"Quantity-module_quantityValue__BBpyw",isDisabled:"Quantity-module_isDisabled__crQCf",sm:"Quantity-module_sm__0Hgp2",md:"Quantity-module_md__hu7a8",lg:"Quantity-module_lg__GA4jn",flexWide:"Quantity-module_flexWide__R95Jw",slidein:"Quantity-module_slidein__5yeWf",fadeInOut:"Quantity-module_fadeInOut__cllco",heightAnimation:"Quantity-module_heightAnimation__dhOgA",fadein:"Quantity-module_fadein__Cof2o",floatAnimation:"Quantity-module_floatAnimation__DSqQr",bottomSheet:"Quantity-module_bottomSheet__5-5iY",slideRightToLeft:"Quantity-module_slideRightToLeft__cjDHk"};const He=({isDecreaseDisabled:r=!1,quantity:a=1,size:i="md",onIncrease:n,onDecrease:o})=>t(_,{className:m(We,{container:!0},[We[i]]),justifyContent:"space-between",gap:0,children:[e("div",{className:m(We,{quantityAction:!0,isDisabled:r}),onClick:o,children:e(v,{icon:E})}),e("div",{className:We.quantityValue,children:a}),e("div",{className:We.quantityAction,onClick:n,children:e(v,{icon:B})})]}),Be=({product:r,onClose:a})=>{const{language:i,currency:c}=ie(),{addProduct:m,updateProduct:h}=ke(),[g,p]=n(1),[v,f]=n(!1),b=o(),{t:C}=Re(),P=(e=>{var t;const{cart:r}=ke();return s(r)||!e?0:(null===(t=r[e])||void 0===t?void 0:t.quantity)||0})(null==r?void 0:r.id),{name:I,description:O}=d((()=>Se(r,i)),[r,i]),{totalPrice:k,formattedTotalPrice:L}=d((()=>Te(r,c,i)),[r,c,i]),S=d((()=>g*k),[g,k]),D=d((()=>u(S,c,i)),[S,c,i]),T=v?0===g:1===g,z=d((()=>C(v?0===g?"removeFromOrder":"updateOrder":"addToOrder")),[v,g]);l((()=>{p(P>0?P:1),f(P>0)}),[P,r]);const j=e=>{-1===e&&T||p((t=>Math.max(0,t+e)))};if(s(r))return null;const{image1024:x,volume:R}=r;return e("div",{className:je.container,onClick:e=>{var t,r;(null===(r=null===(t=null==b?void 0:b.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||a&&a()},children:e(N,{onClose:a,ref:b,noBodyPadding:!0,size:"small",content:t("div",{className:je.content,children:[t(y,{gap:0,children:[x&&e(ve,{src:G(x),width:1024,height:400,alt:I||"product",className:je.image}),t(y,{className:je.details,gap:1,children:[e("h2",{className:je.name,children:I}),t(_,{justifyContent:"space-between",children:[e("div",{className:je.price,children:L}),e("div",{className:je.volume,children:R})]}),e("div",{className:je.description,children:O})]})]}),e("div",{className:je.close,children:e(A,{onClick:a,icon:q})})]}),footer:t(_,{className:je.addToCart,gap:.5,children:[e(He,{isDecreaseDisabled:T,onDecrease:()=>j(-1),onIncrease:()=>j(1),quantity:g}),e(w,{className:je.addAction,label:t(_,{fullWidth:!0,justifyContent:"space-between",children:[e("span",{className:je.actionTitle,children:z}),e("span",{children:D})]}),onClick:()=>{v?h(r,g):m(r,g),a&&a()},size:"xl",fullWidth:!0})]})})})};var Ee="Cart-module_container__3KQtx",qe="Cart-module_content__rkiZa",Ye={container:"CartStepper-module_container__4CF1L",count:"CartStepper-module_count__E-RBg",actionText:"CartStepper-module_actionText__-rVKA",totalPrice:"CartStepper-module_totalPrice__QboRN",isClickable:"CartStepper-module_isClickable__mDptU",flexWide:"CartStepper-module_flexWide__eXxCr",slidein:"CartStepper-module_slidein__d5JQ-",fadeInOut:"CartStepper-module_fadeInOut__pS8nn",heightAnimation:"CartStepper-module_heightAnimation__7-e5Z",fadein:"CartStepper-module_fadein__-Ba0-",floatAnimation:"CartStepper-module_floatAnimation__rq6zX",bottomSheet:"CartStepper-module_bottomSheet__1wHHD",slideRightToLeft:"CartStepper-module_slideRightToLeft__0KLAo"};const Me=({actionText:r,onClick:a})=>{const i=Qe(),{formattedTotalPrice:n}=(()=>{const{cart:e}=ke(),{currency:t,language:r}=ie(),a=Object.values(e||{}).reduce(((e,{price:t,quantity:r,vat:a})=>e+De(t,r,a)),0);return{totalPrice:a,formattedTotalPrice:u(a,t,r)}})();return t(f,{className:m(Ye,{container:!0,isClickable:!!a}),justifyContent:"space-between",alignItems:"center",onClick:a,children:[e(f.Item,{flex:1,children:t(_,{alignItems:"center",children:[e("div",{className:Ye.count,children:i}),e("div",{className:Ye.actionText,children:r})]})}),e(f.Item,{className:Ye.totalPrice,flex:1,children:n})]})},Fe=()=>{const{setIsCartOpen:t}=ke(),{t:r}=Re();return Qe()<=0?null:e("div",{className:Ee,children:e("div",{className:qe,children:e(Me,{onClick:()=>t(!0),actionText:r("viewOrder")})})})};var Ue={container:"CartDrawer-module_container__zvapw",content:"CartDrawer-module_content__ELSiG",flexWide:"CartDrawer-module_flexWide__ySgY-",slidein:"CartDrawer-module_slidein__XC9AW",fadeInOut:"CartDrawer-module_fadeInOut__w9h6X",heightAnimation:"CartDrawer-module_heightAnimation__tBgkj",fadein:"CartDrawer-module_fadein__QNPoQ",floatAnimation:"CartDrawer-module_floatAnimation__nZWoY",bottomSheet:"CartDrawer-module_bottomSheet__m0wy7",slideRightToLeft:"CartDrawer-module_slideRightToLeft__gpixh"},Ve="CartItem-module_container__At7lj",$e="CartItem-module_image__D-zzG",Ge="CartItem-module_data__Lo3Fb",Ze="CartItem-module_name__EksZu",Ke="CartItem-module_price__yJxl6";const Xe=e=>{var t;const{products:r}=ie();return(null===(t=null==r?void 0:r.find)||void 0===t?void 0:t.call(r,(({id:t})=>t===e)))||{}},Je=({productId:t,min:r=1,size:a="md"})=>{const i=(e=>{const{cart:t}=ke(),r=t[e];return(null==r?void 0:r.quantity)||1})(t),n=Xe(t),{updateProduct:o}=ke();return e(He,{isDecreaseDisabled:i===r,onDecrease:()=>o(n,i-1),onIncrease:()=>o(n,i+1),quantity:i,size:a})},et=({item:r})=>{const{productId:a,quantity:i}=r||{},n=Xe(a),{language:o,currency:l}=ie(),{image160:c}=n,{name:s}=d((()=>Se(n,o)),[n,o]),{formattedTotalPrice:u}=d((()=>Te(n,l,o,i)),[n,l,o,i]);return t(_,{className:Ve,gap:1,alignItems:"center",children:[c&&e(ve,{src:G(c),alt:s||"menu",className:$e,loading:"lazy",width:80,height:45}),t("div",{className:Ge,children:[e("div",{className:Ze,children:s}),e("div",{className:Ke,children:u})]}),e(Je,{productId:a,size:"sm",min:0})]})},tt=()=>{const{isCartOpen:r,cart:a,setIsCartOpen:i}=ke(),n=o(),{t:l}=Re(),d=s(a),c=()=>i(!1);return r?e("div",{className:Ue.container,onClick:e=>{var t,r;(null===(r=null===(t=null==n?void 0:n.current)||void 0===t?void 0:t.contains)||void 0===r?void 0:r.call(t,null==e?void 0:e.target))||c()},children:e(O,{ref:n,onClose:c,isOpen:r,title:l("Your order"),content:e("div",{className:Ue.content,children:d?e((()=>t(y,{className:Ue.noItems,fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",gap:0,children:[e(k,{variant:"h2",children:l("Empty order")}),e(L,{text:l("You don't have any items in your order")})]})),{}):e("div",{className:Ue.items,children:Object.keys(a||{}).map((t=>e(et,{item:a[t]},t)))})}),footer:d?e(w,{label:l("Add items"),onClick:c,type:I.PRIMARY,size:"xl",fullWidth:!0}):e(Me,{actionText:l("Subtotal")})})}):null},rt=c((({categoryProductMap:r=[],currency:a,language:i,productBlocksRef:o,containerRef:d,onCategoryInView:c})=>{const[s,u]=n(null);return l((()=>{const e=new IntersectionObserver((e=>{var t;const r=((null===(t=null==d?void 0:d.current)||void 0===t?void 0:t.clientHeight)||1e3)/2;let a=null,i=1/0;e.forEach((e=>{if(e.isIntersecting){const t=e.boundingClientRect,n=t.top+t.height/2,o=Math.abs(n-r);o<i&&(i=o,a=e.target.getAttribute("data-category-id"))}})),a&&c(Number(a))}),{threshold:.5});return Object.entries(o.current||{}).forEach((([t,r])=>{r&&(r.setAttribute("data-category-id",t),e.observe(r))})),()=>{e.disconnect()}}),[o,d]),e(Oe,{children:t("div",{className:Pe,children:[e(y,{children:(r||[]).map((r=>{const{name:n}=((e,t)=>{var r,a;return(null===(a=null===(r=null==e?void 0:e.translations)||void 0===r?void 0:r.find)||void 0===a?void 0:a.call(r,(e=>e.language===t)))||{}})(r,i),{id:l,products:d}=r;return t("div",{className:Ie,ref:e=>o.current[l]=e,"data-category-id":l,children:[e("h2",{className:Ae,children:n}),e("div",{className:Ne,children:e(y,{gap:0,children:(d||[]).map((t=>e(ze,{product:t,currency:a,language:i,onClick:()=>u(t)},t.id)))})})]},l)}))}),e(Be,{product:s,onClose:()=>u(null)}),e(Fe,{}),e(tt,{})]})})}),((e,t)=>e.categoryProductMap===t.categoryProductMap&&e.currency===t.currency&&e.language===t.language));var at="Branches-module_branches__sOuoV",it="Branches-module_list__vYoT2",nt="Branches-module_name__K0Z-4";const ot=({branches:t=[],rootPath:r="",onBranchSelect:a})=>{const i=({children:t,id:i})=>a?e("div",{onClick:()=>a(i),children:t}):e("a",{href:`${r}/${i}`,children:t});return e("div",{className:at,children:e(S,{className:it,children:t.map((({id:t,name:r})=>e(i,{id:t,children:e(D,{noBottomMargin:!0,children:e(f,{justifyContent:"center",alignItems:"center",fullHeight:!0,children:e("h2",{className:nt,children:r})})})},t)))})})},lt=({data:a})=>{var i;const{name:l,coverImage:d,logoImage:c,branches:s=[],branchId:u,language:m,categories:_,products:h,currency:g,instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b,rootPath:C,hostname:P,onBranchSelect:I}=a||{},A=s.length<=1,N=((e,t)=>{const r=t.reduce(((e,t)=>{const r=Number(t.categoryId);return e[r]||(e[r]=[]),e[r].push(t),e}),{});return e.map((e=>Object.assign(Object.assign({},e),{products:r[Number(e.id)]||[]}))).filter((e=>{var t;return(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t.length)>0}))})(_,h),w=(()=>{var e;return A?(null===(e=null==s?void 0:s[0])||void 0===e?void 0:e.id)?s[0]:{}:s.find((e=>e.id===Number(u)))})(),O=A||!(null==w?void 0:w.name)?l:(null==w?void 0:w.name)||"",[k,L]=n(null===(i=null==_?void 0:_[0])||void 0===i?void 0:i.id),S=o({}),D=o(null),T=o(!0),{url:z,domain:j}=((e,t)=>{const r=te.includes(e)?e:ee;return{url:`https://${r}/${t||"en"}`,domain:r}})(P,m);return t("div",{className:F,ref:D,children:[e(be,{branch:w,name:O,coverImage:K(d),logoImage:Z(c),instagram:p,facebook:v,whatsapp:f,telegram:y,tiktok:b}),A||u?t(r,{children:[e(Ce,{categoryProductMap:N,language:m,selectedCategoryId:k,onSelectCategory:e=>M(void 0,void 0,void 0,(function*(){T.current=!1,L(e),(e=>{var t;const r=null===(t=null==S?void 0:S.current)||void 0===t?void 0:t[e];r&&(setTimeout((()=>{r.scrollIntoView({behavior:"smooth",block:"start"})}),100),setTimeout((()=>{T.current=!0}),1e3))})(e)}))}),e(rt,{currency:g,language:m,productBlocksRef:S,containerRef:D,categoryProductMap:N,onCategoryInView:e=>{(null==T?void 0:T.current)&&L(e)}})]}):e(ot,{branches:s,onBranchSelect:I,rootPath:C}),!!P&&e("a",{rel:"noopener",target:"_blank",href:z,className:V,children:j})]})},dt=({data:t})=>e(ae,{value:t,children:e(lt,{data:t})});export{dt as PublicMenu};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import{isEmpty as r,trackEvent as i,priceFormatter as n,classNames as o}from"@sorocraft/js-utils";import{createContext as l,useContext as d,useState as c,useRef as s,useEffect as u,useMemo as m,memo as _}from"react";import{Row as h,classNames as g,IconLink as p,Tooltip as v,SVGIcon as f,Flex as y,Column as b,Carousel as C,CarouselItem as P,Chip as I,UIElementType as A,IconButton as N,Modal as w,Button as O,Drawer as k,Text as L,Description as S,Container as D,Card as T}from"@sorocraft/ui";import{Phone as z,Whatsapp as j,Instagram as x,Telegram as R,Tiktok as Q,Facebook as W,Wifi as H,MarkerPin as B,Plus as E,Minus as q,Close as Y}from"@sorocraft/ui/icons";function M(e,t){var a={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(a[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(a[r[i]]=e[r[i]])}return a}function F(e,t,a,r){return new(a||(a=Promise))((function(i,n){function o(e){try{d(r.next(e))}catch(e){n(e)}}function l(e){try{d(r.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(o,l)}d((r=r.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var $="PublicMenu-module_container__QLN6U",U="PublicMenu-module_categories__Iy6NC",V="PublicMenu-module_footer__6G3DQ";const G="https://images.restaround.co",Z=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${G}/${e}`:"",K=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${G}/${e}`:"https://images.restaround.co/no-photo-128.webp",X=e=>e?e.includes("base64")||e.startsWith("https://")?e:`${G}/${e}`:"https://images.restaround.co/restaround-doodle.webp",J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ee=(e,t,a)=>J.charAt(e>>2)+J.charAt((3&e)<<4|t>>4)+J.charAt((15&t)<<2|a>>6)+J.charAt(63&a),te="restaround.co",ae=[te,"restaround.az","restaround.ee","restaround.nl"],re=l({}),ie=({children:t,value:a})=>{const i=r(a)?{}:a;return i.currency||i.currency,i.language||i.language,e(re.Provider,{value:r(a)?{}:a,children:t})},ne=()=>d(re),oe="digital_menu",le=`${oe}_category_select`,de=`${oe}_category_scroll`,ce=`${oe}_product_details`,se=`${oe}_product_add_cart`,ue=(e,t)=>{var a,r;return(null===(r=null===(a=null==e?void 0:e.translations)||void 0===a?void 0:a.find)||void 0===r?void 0:r.call(a,(e=>e.language===t)))||{}};var me="Header-module_container__tenlF",_e="Header-module_cover__BAWZK",he="Header-module_content__Gx4Al",ge="Header-module_logo__4MTCm",pe="Header-module_info__IchYA",ve="Header-module_name__30wyw",fe="Header-module_address__WOxXc",ye="Header-module_addressText__lUszI",be="Header-module_social__AoP0z",Ce="Header-module_links__EeQxg",Pe="Header-module_wifiPassword__VWBTa",Ie="Header-module_wifiPasswordIcon__Ukn3D";const Ae=t=>{const a=M(t,["priority","blurDataURL","quality","placeholder","fetchPriority"]),{imageTag:r}=ne()||{};if(r){return e(r,Object.assign({},t,{quality:t.quality||100,placeholder:"blur",blurDataURL:(i=235,n=59,o=90,`data:image/gif;base64,R0lGODlhAQABAPAA${ee(0,i,n)+ee(o,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`)}))}var i,n,o;return e("img",Object.assign({},a))};var Ne={container:"Languages-module_container__nJeK1",currentLanguage:"Languages-module_currentLanguage__EFw6Q",options:"Languages-module_options__6jLRm",option:"Languages-module_option__QkVQd",isOpen:"Languages-module_isOpen__eUGbg",flexWide:"Languages-module_flexWide__zQ9jN",slidein:"Languages-module_slidein__C4UHU",fadeInOut:"Languages-module_fadeInOut__U-vhH",heightAnimation:"Languages-module_heightAnimation__gIQkF",fadein:"Languages-module_fadein__vPmsX",floatAnimation:"Languages-module_floatAnimation__L-kPH",bottomSheet:"Languages-module_bottomSheet__-t-q8",slideRightToLeft:"Languages-module_slideRightToLeft__y0l-f"};const we=()=>{var a;const{language:r,languages:i,onLanguageSelect:n}=ne(),[o,l]=c(!1),d=(null==i?void 0:i.length)>1,s=(null===(a=null==i?void 0:i.filter)||void 0===a?void 0:a.call(i,(({code:e})=>e!==r)))||[],u=e=>`https://images.restaround.co/languages/${e}.svg`;return d?e("div",{className:Ne.container,onClick:()=>l(!o),children:t(h,{alignItems:"center",gap:0,children:[e(h,{alignItems:"center",className:g(Ne,{options:!0,isOpen:o}),children:s.map((({code:t})=>e("img",{src:u(t),className:Ne.option,onClick:()=>(e=>{n&&n(e)})(t),alt:t},t)))}),e("img",{src:u(r),alt:r||"",className:Ne.currentLanguage})]})}):null},Oe=({branch:a,coverImage:i,logoImage:n,name:o,instagram:l,facebook:d,whatsapp:c,telegram:s,tiktok:u})=>{const{address:m,latitude:_,longitude:g,phone:C,wifiPassword:P}=a||{},I=r(a),A=`https://www.google.com/maps/place/${_},${g}`;return t("div",{className:me,children:[e(Ae,{src:i,alt:o,className:_e,width:1024,height:400,priority:!0,sizes:"100vw",fetchPriority:"high",loading:"eager"}),e("div",{className:he,children:e(I?()=>t(b,{fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",children:[e(Ae,{src:n,alt:o,className:ge,width:96,height:96}),e("div",{className:pe,children:e("h1",{className:ve,children:o})})]}):()=>t(y,{direction:"row",gap:1,alignItems:"center",children:[e(y.Item,{children:e(Ae,{src:n,alt:o,className:ge,width:96,height:96})}),e(y.Item,{shrink:!0,children:e("div",{className:pe,children:t(b,{gap:.25,children:[e("h1",{className:ve,children:o}),e("a",{className:fe,href:A,target:"_blank",rel:"noopener noreferrer",children:t(h,{alignItems:"center",gap:.5,children:[e(f,{icon:B,theme:"dark"}),e("span",{className:ye,children:m})]})})]})})})]}),{})}),e(we,{}),!I&&e("div",{className:be,children:e("div",{className:Ce,children:e(h,{gap:2,alignItems:"center",children:t(h,{alignItems:"center",justifyContent:"center",gap:.5,children:[!!C&&e(p,{icon:z,href:`tel:+${C}`,size:"sm",shape:"circle",theme:"light"}),!!c&&e(p,{icon:j,href:`https://wa.me/${c}`,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!l&&e(p,{icon:x,href:l,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!s&&e(p,{icon:R,href:s,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!u&&e(p,{icon:Q,href:u,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!d&&e(p,{icon:W,href:d,size:"sm",shape:"circle",theme:"light",target:"_blank"}),!!P&&e(v,{hint:P,children:e("div",{className:Pe,children:e(f,{icon:H,size:"sm",className:Ie})})})]})})})})]})},ke=({categoryProductMap:t=[],language:a,selectedCategoryId:r,onSelectCategory:n})=>{const o=s({}),l=s(null);return u((()=>{r&&(()=>{var e;const t=null===(e=null==o?void 0:o.current)||void 0===e?void 0:e[r];if(!t||!l.current)return;const a=l.current.clientWidth,i=t.offsetLeft-a/2+t.offsetWidth/2;l.current.scrollTo({left:i,behavior:"smooth"})})()}),[r]),e("div",{className:U,children:e(C,{gap:1,onGetRef:e=>{(null==e?void 0:e.current)&&(l.current=e.current)},children:(t||[]).map((({id:t,translations:l})=>{const{name:d}=l.find((e=>e.language===a))||{};return e(P,{children:e(I,{onClick:()=>((e,t)=>{e!==r&&(i(le,{name:t}),n(e))})(t,d),type:A.BORDERED_PRIMARY,active:t===r,children:e("div",{ref:e=>o.current[t]=e,children:d})})},t)}))})})};var Le="Products-module_container__bF2LF",Se="Products-module_products__AoDrY",De="Products-module_category__Sp7dE",Te="Products-module_list__LH4v5";const ze=(e,t)=>{var a,r;return(null===(r=null===(a=null==e?void 0:e.translations)||void 0===a?void 0:a.find)||void 0===r?void 0:r.call(a,(e=>e.language===t)))||{}},je=(e,t,a=0)=>e*t*(1+a/100),xe=(e,t,a,r=1)=>{const{price:i,vat:o}=e||{},l=je(i,r,o);return{totalPrice:l,formattedTotalPrice:n(l,t,a)}},Re=l({cart:{},isCartOpen:!1,addProduct:()=>{},updateProduct:()=>{},setIsCartOpen:()=>{}}),Qe=({children:t})=>{const[a,i]=c({}),[n,o]=c(!1),l=(e,t,a)=>{if(r(e)||t<0)return;const{id:n,price:o,vat:l=0}=e;i((e=>{const r=e[n],i=a?((null==r?void 0:r.quantity)||0)+t:t;if(i<=0){const t=e,a=n;t[a];return M(t,["symbol"==typeof a?a:a+""])}return Object.assign(Object.assign({},e),{[n]:{productId:n,price:o,quantity:i,vat:l}})}))},d=(e,t=1)=>l(e,t,!0),s=(e,t=1)=>l(e,t,!1),u=m((()=>({cart:a,isCartOpen:n,addProduct:d,updateProduct:s,setIsCartOpen:o})),[a,n]);return e(Re.Provider,{value:u,children:t})},We=()=>d(Re);var He={container:"ProductsListItem-module_container__i9tFs",isClickable:"ProductsListItem-module_isClickable__iHHdI",data:"ProductsListItem-module_data__Mb3SF",name:"ProductsListItem-module_name__T1gyJ",description:"ProductsListItem-module_description__oL4CH",price:"ProductsListItem-module_price__V1GRM",image:"ProductsListItem-module_image__h6Wbi",addToCart:"ProductsListItem-module_addToCart__WXrQZ",flexWide:"ProductsListItem-module_flexWide__Ds6LE",slidein:"ProductsListItem-module_slidein__rEzMI",fadeInOut:"ProductsListItem-module_fadeInOut__i1FNq",heightAnimation:"ProductsListItem-module_heightAnimation__2fk7l",fadein:"ProductsListItem-module_fadein__tPTJ6",floatAnimation:"ProductsListItem-module_floatAnimation__vugAV",bottomSheet:"ProductsListItem-module_bottomSheet__-YAdd",slideRightToLeft:"ProductsListItem-module_slideRightToLeft__oXk26"};const Be=({product:a,currency:r,language:n,onClick:l})=>{const{addProduct:d}=We(),{image160:c,volume:s}=a||{},{name:u,description:_}=m((()=>ze(a,n)),[a,n]),{formattedTotalPrice:g}=m((()=>xe(a,r,n)),[a,r,n]);return t("div",{className:o(He,{container:!0,isClickable:!!l}),onClick:l,children:[t(h,{justifyContent:"space-between",gap:0,children:[e("div",{className:He.data,children:t(b,{gap:.25,children:[e("h3",{className:He.name,children:t(h,{gap:.5,fullWidth:!0,children:[e("span",{children:u}),!!s&&t("span",{children:["(",s,")"]})]})}),e("div",{className:He.description,children:_}),e("div",{className:He.price,children:g})]})}),c&&e(Ae,{src:Z(c),alt:u||"menu",className:He.image,loading:"lazy",width:160,height:90})]}),e("div",{className:He.addToCart,children:e(N,{onClick:e=>{e.preventDefault(),e.stopPropagation(),d(a),i(se,{name:u,quantity:1})},icon:E,type:A.DEFAULT})})]})};var Ee={container:"ProductDetails-module_container__oa07j",content:"ProductDetails-module_content__Db3NC",image:"ProductDetails-module_image__BlMfl",details:"ProductDetails-module_details__zfnlt",name:"ProductDetails-module_name__ganLM",price:"ProductDetails-module_price__W34k9",volume:"ProductDetails-module_volume__RWG5s",description:"ProductDetails-module_description__HBufi",close:"ProductDetails-module_close__4cHZ3",addAction:"ProductDetails-module_addAction__o4T5R",actionTitle:"ProductDetails-module_actionTitle__NIJGW",flexWide:"ProductDetails-module_flexWide__w06FX",slidein:"ProductDetails-module_slidein__N8f4g",fadeInOut:"ProductDetails-module_fadeInOut__hYRtK",heightAnimation:"ProductDetails-module_heightAnimation__hLQyz",fadein:"ProductDetails-module_fadein__QN4mI",floatAnimation:"ProductDetails-module_floatAnimation__dTQbc",bottomSheet:"ProductDetails-module_bottomSheet__HO2S-",slideRightToLeft:"ProductDetails-module_slideRightToLeft__hbtJg"};const qe={en:{viewOrder:"View order",removeFromOrder:"Remove from order",updateOrder:"Update order",addToOrder:"Add to order"},az:{viewOrder:"Şifarişi göstər",removeFromOrder:"Sifarişdən sil",updateOrder:"Sifarişi yenilə",addToOrder:"Sifarişə əlavə et","Your order":"Sifarişiniz",Subtotal:"Ümumi","Empty order":"Boş sifariş","You don't have any items in your order":"Sifarişinizdə heç bir məhsul yoxdur","Add items":"Məhsul əlavə et"},tr:{viewOrder:"Siparişi Görüntüle",removeFromOrder:"Siparişten Kaldır",updateOrder:"Siparişi Güncelle",addToOrder:"Siparişe Ekle","Your order":"Siparişiniz","Empty order":"Boş sipariş","You don't have any items in your order":"Siparişinizde hiç bir ürün yok","Add items":"Ürün ekle",Subtotal:"Toplam"},nl:{viewOrder:"Bestelling bekijken",removeFromOrder:"Uit bestelling verwijderen",updateOrder:"Bestelling bijwerken",addToOrder:"Aan bestelling toevoegen","Your order":"Uw bestelling","Empty order":"Lege bestelling","You don't have any items in your order":"U heeft geen items in uw bestelling","Add items":"Items toevoegen",Subtotal:"Totaal"},et:{viewOrder:"Vaata tellimust",removeFromOrder:"Eemalda tellimusest",updateOrder:"Uuenda tellimust",addToOrder:"Lisa tellimusele","Your order":"Teie tellimus","Empty order":"Tühi tellimus","You don't have any items in your order":"Teie tellimuses pole ühtegi eset","Add items":"Lisa esemeid",Subtotal:"Kokku"},pl:{viewOrder:"Zobacz zamówienie",removeFromOrder:"Usuń z zamówienia",updateOrder:"Zaktualizuj zamówienie",addToOrder:"Dodaj do zamówienia","Your order":"Twoje zamówienie","Empty order":"Puste zamówienie","You don't have any items in your order":"Nie masz żadnych pozycji w zamówieniu","Add items":"Dodaj przedmioty",Subtotal:"Suma"},ru:{viewOrder:"Посмотреть заказ",removeFromOrder:"Удалить из заказа",updateOrder:"Обновить заказ",addToOrder:"Добавить в заказ","Your order":"Ваш заказ","Empty order":"Пустой заказ","You don't have any items in your order":"В вашем заказе нет товаров","Add items":"Добавить товары",Subtotal:"Итого"}},Ye=()=>{const{language:e}=ne();return{t:t=>{var a;return(null===(a=qe[e])||void 0===a?void 0:a[t])||t}}},Me=()=>{const{cart:e}=We();return Object.values(e||{}).reduce(((e,t)=>e+t.quantity),0)};var Fe={container:"Quantity-module_container__01ySb",quantityAction:"Quantity-module_quantityAction__wRV2F",quantityValue:"Quantity-module_quantityValue__BBpyw",isDisabled:"Quantity-module_isDisabled__crQCf",sm:"Quantity-module_sm__0Hgp2",md:"Quantity-module_md__hu7a8",lg:"Quantity-module_lg__GA4jn",flexWide:"Quantity-module_flexWide__R95Jw",slidein:"Quantity-module_slidein__5yeWf",fadeInOut:"Quantity-module_fadeInOut__cllco",heightAnimation:"Quantity-module_heightAnimation__dhOgA",fadein:"Quantity-module_fadein__Cof2o",floatAnimation:"Quantity-module_floatAnimation__DSqQr",bottomSheet:"Quantity-module_bottomSheet__5-5iY",slideRightToLeft:"Quantity-module_slideRightToLeft__cjDHk"};const $e=({isDecreaseDisabled:a=!1,quantity:r=1,size:i="md",onIncrease:n,onDecrease:l})=>t(h,{className:o(Fe,{container:!0},[Fe[i]]),justifyContent:"space-between",gap:0,children:[e("div",{className:o(Fe,{quantityAction:!0,isDisabled:a}),onClick:l,children:e(f,{icon:q})}),e("div",{className:Fe.quantityValue,children:r}),e("div",{className:Fe.quantityAction,onClick:n,children:e(f,{icon:E})})]}),Ue=({product:a,onClose:o})=>{const{language:l,currency:d}=ne(),{addProduct:_,updateProduct:g}=We(),[p,v]=c(1),[f,y]=c(!1),C=s(),{t:P}=Ye(),I=(e=>{var t;const{cart:a}=We();return r(a)||!e?0:(null===(t=a[e])||void 0===t?void 0:t.quantity)||0})(null==a?void 0:a.id),{name:A,description:k}=m((()=>ze(a,l)),[a,l]),{totalPrice:L,formattedTotalPrice:S}=m((()=>xe(a,d,l)),[a,d,l]),D=m((()=>p*L),[p,L]),T=m((()=>n(D,d,l)),[D,d,l]),z=f?0===p:1===p,j=m((()=>P(f?0===p?"removeFromOrder":"updateOrder":"addToOrder")),[f,p]);u((()=>{v(I>0?I:1),y(I>0)}),[I,a]);const x=e=>{-1===e&&z||v((t=>Math.max(0,t+e)))};if(r(a))return null;const{image1024:R,volume:Q}=a;return e("div",{className:Ee.container,onClick:e=>{var t,a;(null===(a=null===(t=null==C?void 0:C.current)||void 0===t?void 0:t.contains)||void 0===a?void 0:a.call(t,null==e?void 0:e.target))||o&&o()},children:e(w,{onClose:o,ref:C,noBodyPadding:!0,size:"small",content:t("div",{className:Ee.content,children:[t(b,{gap:0,children:[R&&e(Ae,{src:Z(R),width:1024,height:400,alt:A||"product",className:Ee.image}),t(b,{className:Ee.details,gap:1,children:[e("h2",{className:Ee.name,children:A}),t(h,{justifyContent:"space-between",children:[e("div",{className:Ee.price,children:S}),e("div",{className:Ee.volume,children:Q})]}),e("div",{className:Ee.description,children:k})]})]}),e("div",{className:Ee.close,children:e(N,{onClick:o,icon:Y})})]}),footer:t(h,{className:Ee.addToCart,gap:.5,children:[e($e,{isDecreaseDisabled:z,onDecrease:()=>x(-1),onIncrease:()=>x(1),quantity:p}),e(O,{className:Ee.addAction,label:t(h,{fullWidth:!0,justifyContent:"space-between",children:[e("span",{className:Ee.actionTitle,children:j}),e("span",{children:T})]}),onClick:()=>{f?g(a,p):(_(a,p),i(se,{name:A,quantity:p})),o&&o()},size:"xl",fullWidth:!0})]})})})};var Ve="Cart-module_container__3KQtx",Ge="Cart-module_content__rkiZa",Ze={container:"CartStepper-module_container__4CF1L",count:"CartStepper-module_count__E-RBg",actionText:"CartStepper-module_actionText__-rVKA",totalPrice:"CartStepper-module_totalPrice__QboRN",isClickable:"CartStepper-module_isClickable__mDptU",flexWide:"CartStepper-module_flexWide__eXxCr",slidein:"CartStepper-module_slidein__d5JQ-",fadeInOut:"CartStepper-module_fadeInOut__pS8nn",heightAnimation:"CartStepper-module_heightAnimation__7-e5Z",fadein:"CartStepper-module_fadein__-Ba0-",floatAnimation:"CartStepper-module_floatAnimation__rq6zX",bottomSheet:"CartStepper-module_bottomSheet__1wHHD",slideRightToLeft:"CartStepper-module_slideRightToLeft__0KLAo"};const Ke=({actionText:a,onClick:r})=>{const i=Me(),{formattedTotalPrice:l}=(()=>{const{cart:e}=We(),{currency:t,language:a}=ne(),r=Object.values(e||{}).reduce(((e,{price:t,quantity:a,vat:r})=>e+je(t,a,r)),0);return{totalPrice:r,formattedTotalPrice:n(r,t,a)}})();return t(y,{className:o(Ze,{container:!0,isClickable:!!r}),justifyContent:"space-between",alignItems:"center",onClick:r,children:[e(y.Item,{flex:1,children:t(h,{alignItems:"center",children:[e("div",{className:Ze.count,children:i}),e("div",{className:Ze.actionText,children:a})]})}),e(y.Item,{className:Ze.totalPrice,flex:1,children:l})]})},Xe=()=>{const{setIsCartOpen:t}=We(),{t:a}=Ye();return Me()<=0?null:e("div",{className:Ve,children:e("div",{className:Ge,children:e(Ke,{onClick:()=>t(!0),actionText:a("viewOrder")})})})};var Je={container:"CartDrawer-module_container__zvapw",content:"CartDrawer-module_content__ELSiG",flexWide:"CartDrawer-module_flexWide__ySgY-",slidein:"CartDrawer-module_slidein__XC9AW",fadeInOut:"CartDrawer-module_fadeInOut__w9h6X",heightAnimation:"CartDrawer-module_heightAnimation__tBgkj",fadein:"CartDrawer-module_fadein__QNPoQ",floatAnimation:"CartDrawer-module_floatAnimation__nZWoY",bottomSheet:"CartDrawer-module_bottomSheet__m0wy7",slideRightToLeft:"CartDrawer-module_slideRightToLeft__gpixh"},et="CartItem-module_container__At7lj",tt="CartItem-module_image__D-zzG",at="CartItem-module_data__Lo3Fb",rt="CartItem-module_name__EksZu",it="CartItem-module_price__yJxl6";const nt=e=>{var t;const{products:a}=ne();return(null===(t=null==a?void 0:a.find)||void 0===t?void 0:t.call(a,(({id:t})=>t===e)))||{}},ot=({productId:t,min:a=1,size:r="md"})=>{const i=(e=>{const{cart:t}=We(),a=t[e];return(null==a?void 0:a.quantity)||1})(t),n=nt(t),{updateProduct:o}=We();return e($e,{isDecreaseDisabled:i===a,onDecrease:()=>o(n,i-1),onIncrease:()=>o(n,i+1),quantity:i,size:r})},lt=({item:a})=>{const{productId:r,quantity:i}=a||{},n=nt(r),{language:o,currency:l}=ne(),{image160:d}=n,{name:c}=m((()=>ze(n,o)),[n,o]),{formattedTotalPrice:s}=m((()=>xe(n,l,o,i)),[n,l,o,i]);return t(h,{className:et,gap:1,alignItems:"center",children:[d&&e(Ae,{src:Z(d),alt:c||"menu",className:tt,loading:"lazy",width:80,height:45}),t("div",{className:at,children:[e("div",{className:rt,children:c}),e("div",{className:it,children:s})]}),e(ot,{productId:r,size:"sm",min:0})]})},dt=()=>{const{isCartOpen:a,cart:i,setIsCartOpen:n}=We(),o=s(),{t:l}=Ye(),d=r(i),c=()=>n(!1);return a?e("div",{className:Je.container,onClick:e=>{var t,a;(null===(a=null===(t=null==o?void 0:o.current)||void 0===t?void 0:t.contains)||void 0===a?void 0:a.call(t,null==e?void 0:e.target))||c()},children:e(k,{ref:o,onClose:c,isOpen:a,title:l("Your order"),content:e("div",{className:Je.content,children:d?e((()=>t(b,{className:Je.noItems,fullWidth:!0,fullHeight:!0,alignItems:"center",justifyContent:"center",gap:0,children:[e(L,{variant:"h2",children:l("Empty order")}),e(S,{text:l("You don't have any items in your order")})]})),{}):e("div",{className:Je.items,children:Object.keys(i||{}).map((t=>e(lt,{item:i[t]},t)))})}),footer:d?e(O,{label:l("Add items"),onClick:c,type:A.PRIMARY,size:"xl",fullWidth:!0}):e(Ke,{actionText:l("Subtotal")})})}):null},ct=_((({categoryProductMap:a=[],currency:r,language:n,productBlocksRef:o,containerRef:l,onCategoryInView:d})=>{const[s,m]=c(null);return u((()=>{const e=new IntersectionObserver((e=>{var t;const a=((null===(t=null==l?void 0:l.current)||void 0===t?void 0:t.clientHeight)||1e3)/2;let r=null,i=1/0;e.forEach((e=>{if(e.isIntersecting){const t=e.boundingClientRect,n=t.top+t.height/2,o=Math.abs(n-a);o<i&&(i=o,r=e.target.getAttribute("data-category-id"))}})),r&&d(Number(r))}),{threshold:.5});return Object.entries(o.current||{}).forEach((([t,a])=>{a&&(a.setAttribute("data-category-id",t),e.observe(a))})),()=>{e.disconnect()}}),[o,l]),e(Qe,{children:t("div",{className:Le,children:[e(b,{children:(a||[]).map((a=>{const{name:l}=ue(a,n),{id:d,products:c}=a;return t("div",{className:Se,ref:e=>o.current[d]=e,"data-category-id":d,children:[e("h2",{className:De,children:l}),e("div",{className:Te,children:e(b,{gap:0,children:(c||[]).map((t=>e(Be,{product:t,currency:r,language:n,onClick:()=>(e=>{const{name:t}=ze(e,n);i(ce,{name:t}),m(e)})(t)},t.id)))})})]},d)}))}),e(Ue,{product:s,onClose:()=>m(null)}),e(Xe,{}),e(dt,{})]})})}),((e,t)=>e.categoryProductMap===t.categoryProductMap&&e.currency===t.currency&&e.language===t.language));var st="Branches-module_branches__sOuoV",ut="Branches-module_list__vYoT2",mt="Branches-module_name__K0Z-4";const _t=({branches:t=[],rootPath:a="",onBranchSelect:r})=>{const i=({children:t,id:i})=>r?e("div",{onClick:()=>r(i),children:t}):e("a",{href:`${a}/${i}`,children:t});return e("div",{className:st,children:e(D,{className:ut,children:t.map((({id:t,name:a})=>e(i,{id:t,children:e(T,{noBottomMargin:!0,children:e(y,{justifyContent:"center",alignItems:"center",fullHeight:!0,children:e("h2",{className:mt,children:a})})})},t)))})})},ht=({data:n})=>{var o;const{name:l,coverImage:d,logoImage:u,branches:m=[],branchId:_,language:h,categories:g,products:p,currency:v,instagram:f,facebook:y,whatsapp:b,telegram:C,tiktok:P,rootPath:I,hostname:A,onBranchSelect:N}=n||{},w=m.length<=1,O=((e,t)=>{const a=t.reduce(((e,t)=>{const a=Number(t.categoryId);return e[a]||(e[a]=[]),e[a].push(t),e}),{});return e.map((e=>Object.assign(Object.assign({},e),{products:a[Number(e.id)]||[]}))).filter((e=>{var t;return(null===(t=null==e?void 0:e.products)||void 0===t?void 0:t.length)>0}))})(g,p),k=(()=>{var e;return w?(null===(e=null==m?void 0:m[0])||void 0===e?void 0:e.id)?m[0]:{}:m.find((e=>e.id===Number(_)))})(),L=w||!(null==k?void 0:k.name)?l:(null==k?void 0:k.name)||"",[S,D]=c(null===(o=null==g?void 0:g[0])||void 0===o?void 0:o.id),T=s({}),z=s(null),j=s(!0),{url:x,domain:R}=((e,t)=>{const a=ae.includes(e)?e:te;return{url:`https://${a}/${t||"en"}`,domain:a}})(A,h);return t("div",{className:$,ref:z,children:[e(Oe,{branch:k,name:L,coverImage:X(d),logoImage:K(u),instagram:f,facebook:y,whatsapp:b,telegram:C,tiktok:P}),w||_?t(a,{children:[e(ke,{categoryProductMap:O,language:h,selectedCategoryId:S,onSelectCategory:e=>F(void 0,void 0,void 0,(function*(){j.current=!1,D(e),(e=>{var t;const a=null===(t=null==T?void 0:T.current)||void 0===t?void 0:t[e];a&&(setTimeout((()=>{a.scrollIntoView({behavior:"smooth",block:"start"})}),100),setTimeout((()=>{j.current=!0}),1e3))})(e)}))}),e(ct,{currency:v,language:h,productBlocksRef:T,containerRef:z,categoryProductMap:O,onCategoryInView:e=>{if(!(null==j?void 0:j.current))return;const t=((e,t,a)=>{var i;const n=null===(i=null==t?void 0:t.find)||void 0===i?void 0:i.call(t,(({id:t})=>t===e));if(r(n))return"";const{name:o}=ue(n,a);return o})(e,g,h);i(de,{name:t}),D(e)}})]}):e(_t,{branches:m,onBranchSelect:N,rootPath:I}),!!A&&e("a",{rel:"noopener",target:"_blank",href:x,className:V,children:R})]})},gt=({data:t})=>e(ie,{value:t,children:e(ht,{data:t})});export{gt as PublicMenu};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|