UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 4.52 kB
import{Fragment as b,jsx as t,jsxs as m}from"react/jsx-runtime";import"./Booth.scss";import{observer as p,useLocalStore as y}from"mobx-react-lite";import{useEffect as _,useRef as x}from"react";import l from"../../data";import c,{uiState as i}from"../../store";import{RegularBooth as N,SpecialBooth as E}from"../../store/BoothStore";import S from"../../tools/settings";import C from"../../tools/track-event";import{t as T}from"../../utils/i18n";import I from"../../utils/useHeatmapOverlay";import{LevelBadge as L}from"../";import j from"../EntityItemContainer";import H from"../Schedule";import A from"../SidebarActionsContainer";import{BoothOnHold as M}from"./BoothOnHold";import{BoothReserved as U}from"./BoothReserved";import{BoothWithoutExhibitor as k}from"./BoothWithoutExhibitor";const F=p(()=>{const d=x(),e=y(()=>({get booth(){return i.selectedBooth},get regular(){return this.booth instanceof N?this.booth:null},get special(){return this.booth instanceof E?this.booth:null},get showReserve(){return!i.kiosk&&this.regular&&(this.regular.price==="0"&&!!this.regular.buyUrl||!!this.regular.reserveUrl)},get showBuy(){return!i.kiosk&&this.regular&&this.regular.buyUrl&&this.regular.price&&this.regular.price!=="0"},get title(){return this.booth.fullName},get reserveTitle(){return l.reserveButtonTerm||T("Reserve")},get descriptionCombined(){return this.booth.description||l.reserveInstructions||""}}));_(()=>{if(e.booth.schedule?.length){const o=new Date,r=[...e.booth.schedule].sort((n,s)=>new Date(n.startDate).getTime()-new Date(s.startDate).getTime());if(r.some(n=>(n.endDate?new Date(n.endDate):new Date(n.startDate))<o)){const n=r.find(s=>(s.endDate?new Date(s.endDate):new Date(s.startDate))>o);if(n&&d.current){const s=d.current.querySelector(`[data-event-id="${n.id}"]`);s&&setTimeout(()=>{const f=d.current.getBoundingClientRect(),R=s.getBoundingClientRect().top-f.top-20;d.current.scrollTop=R},100)}}}},[e.booth.schedule]);function v(o){const r=parseInt(o);c.clickExhibitor(c.exhibitorStore.exhibitors.find(g=>g.id===r))}function B(o){c.selectEventItem(o,!0)}function D(){e.booth.exhibitors.length===0&&(e.booth.bookmarkedDirectly=!e.booth.bookmarkedDirectly,e.booth.bookmarkedDirectly&&C("bookmark",e.booth.name,"booth"))}const O=t("div",{className:"booth__bar",children:e.title});let a=null;const h=e.booth.layer?.description,{heatmapBar:w}=I(e.booth),u=e.booth.exhibitors.sort((o,r)=>+!!r.featured-+!!o.featured).map(o=>t(j,{onClick:v,id:o.id.toString(),featured:o.featured,kind:"exhibitor",image:o.logo?.url,title:o.name,bookmarked:o.bookmarked,visited:o.visited,additionalInfo:o.booths.map(r=>({type:"location",locationName:r.name,level:h||r.layer?.name}))},o.id.toString()));if(l.isRebooking)a=t(b,{children:u});else if(e.regular){const o=e.regular;o.onHold?a=t(M,{booth:o,description:"",showBuy:!1,showReserve:!1,isRebooking:!1,level:h}):o.reserved?a=t(U,{}):o.exhibitors.length===0?a=t(k,{booth:o,description:e.descriptionCombined,showBuy:!i.previewMode&&e.showBuy,showReserve:!i.previewMode&&e.showReserve,isRebooking:!1,level:h}):a=t(b,{children:u})}else a=m("div",{className:"booth__content -spec",children:[t(L,{level:h}),t("div",{className:"booth__desc",dangerouslySetInnerHTML:{__html:e.special.description}}),t(b,{children:u})]});return m("div",{className:"booth",children:[m("div",{className:"booth__header",children:[m("div",{className:"booth__header-name",children:[t("div",{className:"booth__header-icon",children:t("i",{className:"icon-booth-solid"})}),t("span",{dir:"auto",children:e.title}),w]}),t("button",{type:"button",onClick:()=>c.searchStore.handleBackAction(),className:"booth__header-close",children:t("i",{className:"icon-close"})})]}),!l.isRebooking&&S.wayfinding&&!i.isGuidedToursActive&&t("div",{className:"exhibitor__directions",style:{paddingLeft:15,paddingRight:15},children:t(A,{showBookmark:!i.disableBookmarked&&!l.hideBookmarks&&!i.kiosk&&e.booth.exhibitors.length===0,showShare:!1,inBookmark:e.booth.exhibitors.length===0?e.booth.bookmarkedDirectly:!1,onClickBookmark:D,onClickDirections:()=>{c.routeStore.clickRoute(null,e.booth)}})}),a,l.isRebooking&&e.regular&&e.regular.exhibitors.length===0&&t(k,{showBuy:!1,description:e.descriptionCombined,showReserve:!1,booth:e.regular,isRebooking:l.isRebooking,level:h}),!!e.booth.schedule?.length&&t(H,{isSessions:!0,showBooths:!0,events:[...e.booth.schedule].sort((o,r)=>new Date(o.startDate).getTime()-new Date(r.startDate).getTime()),onEventClick:B})]})});export default p(()=>!i.menu&&i.selectedBooth?t(F,{}):null);