@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.04 kB
JavaScript
import{jsx as i,Fragment as f,jsxs as g}from"react/jsx-runtime";import"./EventBadge.scss";import u from"classnames";import{useEffect as p,useState as v}from"react";import{shouldShowEventFullBadge as h}from"../utils/eventFullBadge";import{calculateTimeUntilStart as S,formatTimeUntilStart as w,getEventStatus as E}from"../utils/eventTime";import{t as e}from"../utils/i18n";const x=({event:n,className:s=""})=>{const[a,c]=v(()=>Date.now());p(()=>{const d=setInterval(()=>{c(Date.now())},1e3);return()=>clearInterval(d)},[]);const r=S(n.startDate,a),t=E(n,a,r),m=()=>{switch(t){case"live":return e("LIVE");case"upcoming":return e("UPCOMING");case"starting-soon":return w(r);case"past":return e("PAST");default:return null}},o=h(n),l=t!=="none"?i("div",{className:u("efp-event-badge",`efp-event-badge--${t}`,{"is-urgent":t==="starting-soon"&&r.isLessThan10Minutes},s),children:m()}):null;return!l&&!o?null:g(f,{children:[l,o&&i("div",{className:u("efp-event-badge","efp-event-badge--full",s),children:e("EVENT IS FULL")})]})};export default x;