@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 4.41 kB
JavaScript
import{jsx as o,Fragment as b,jsxs as u}from"react/jsx-runtime";import"./Booth.scss";import{observer as p,useLocalStore as _}from"mobx-react-lite";import{useEffect as y,useRef as x}from"react";import l from"../../data";import c,{uiState as i}from"../../store";import{RegularBooth as N,SpecialBooth as S}from"../../store/BoothStore";import C from"../../tools/settings";import{t as E}from"../../utils/i18n";import T from"../../utils/useHeatmapOverlay";import{LevelBadge as I}from"../";import L from"../EntityItemContainer";import j from"../Schedule";import H from"../SidebarActions";import{BoothOnHold as A}from"./BoothOnHold";import{BoothReserved as M}from"./BoothReserved";import{BoothWithoutExhibitor as k}from"./BoothWithoutExhibitor";const U=p(()=>{const d=x(),e=_(()=>({get booth(){return i.selectedBooth},get regular(){return this.booth instanceof N?this.booth:null},get special(){return this.booth instanceof S?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||E("Reserve")},get descriptionCombined(){return this.booth.description||l.reserveInstructions||""}}));y(()=>{if(e.booth.schedule?.length){const t=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))<t)){const n=r.find(s=>(s.endDate?new Date(s.endDate):new Date(s.startDate))>t);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(t){const r=parseInt(t);c.clickExhibitor(c.exhibitorStore.exhibitors.find(g=>g.id===r))}function B(t){c.selectEventItem(t,!0)}function D(){e.booth.exhibitors.length===0&&(e.booth.bookmarkedDirectly=!e.booth.bookmarkedDirectly)}const F=o("div",{className:"booth__bar",children:e.title});let a=null;const h=e.booth.layer?.description,{heatmapBar:w}=T(e.booth),m=e.booth.exhibitors.sort((t,r)=>+!!r.featured-+!!t.featured).map(t=>o(L,{onClick:v,id:t.id.toString(),featured:t.featured,kind:"exhibitor",image:t.logo,title:t.name,bookmarked:t.bookmarked,visited:t.visited,additionalInfo:t.booths.map(r=>({type:"location",locationName:r.name,level:h||r.layer?.name}))},t.id.toString()));if(l.isRebooking)a=o(b,{children:m});else if(e.regular){const t=e.regular;t.onHold?a=o(A,{booth:t,description:"",showBuy:!1,showReserve:!1,isRebooking:!1,level:h}):t.reserved?a=o(M,{}):t.exhibitors.length===0?a=o(k,{booth:t,description:e.descriptionCombined,showBuy:!i.previewMode&&e.showBuy,showReserve:!i.previewMode&&e.showReserve,isRebooking:!1,level:h}):a=o(b,{children:m})}else a=u("div",{className:"booth__content -spec",children:[o(I,{level:h}),o("div",{className:"booth__desc",dangerouslySetInnerHTML:{__html:e.special.description}}),o(b,{children:m})]});return u("div",{className:"booth",children:[u("div",{className:"booth__header",children:[u("div",{className:"booth__header-name",children:[o("div",{className:"booth__header-icon",children:o("i",{className:"icon-booth-solid"})}),o("span",{dir:"auto",children:e.title}),w]}),o("button",{type:"button",onClick:()=>c.searchStore.handleBackAction(),className:"booth__header-close",children:o("i",{className:"icon-close"})})]}),!l.isRebooking&&C.wayfinding&&!i.isGuidedToursActive&&o("div",{className:"exhibitor__directions",style:{paddingLeft:15,paddingRight:15},children:o(H,{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&&o(k,{showBuy:!1,description:e.descriptionCombined,showReserve:!1,booth:e.regular,isRebooking:l.isRebooking,level:h}),!!e.booth.schedule?.length&&o(j,{isSessions:!0,showBooths:!0,events:[...e.booth.schedule].sort((t,r)=>new Date(t.startDate).getTime()-new Date(r.startDate).getTime()),onEventClick:B})]})});export default p(()=>!i.menu&&i.selectedBooth?o(U,{}):null);