import React, { useMemo, useCallback } from 'react'; import Button from '@custom/shared/components/Button'; import HeaderCapsule from '@custom/shared/components/HeaderCapsule'; import { useCallState } from '@custom/shared/contexts/CallProvider'; import { useParticipants } from '@custom/shared/contexts/ParticipantsProvider'; import { useUIState } from '@custom/shared/contexts/UIStateProvider'; import { ReactComponent as IconLock } from '@custom/shared/icons/lock-md.svg'; import { ReactComponent as IconPlay } from '@custom/shared/icons/play-sm.svg'; import { slugify } from '@custom/shared/lib/slugify'; import { useClassState, PRE_CLASS_LOBBY, CLASS_IN_SESSION } from '../../contexts/ClassStateProvider'; export const Header = () => { const { roomInfo } = useCallState(); const { participantCount, localParticipant } = useParticipants(); const { customCapsule } = useUIState(); const { classType, setClassType } = useClassState(); const capsuleLabel = useCallback(() => { if (!localParticipant.isOwner) return; if (classType === PRE_CLASS_LOBBY) return ( ) if (classType === CLASS_IN_SESSION) return ( ) }, [classType, localParticipant.isOwner, setClassType]); return useMemo( () => (
Daily {roomInfo.privacy === 'private' && } {slugify.revert(roomInfo.name)} {`${participantCount} ${ participantCount === 1 ? 'participant' : 'participants' }`} {classType} {capsuleLabel()} {customCapsule && ( {customCapsule.variant === 'recording' && } {customCapsule.label} )}
), [roomInfo.privacy, roomInfo.name, participantCount, customCapsule, classType, capsuleLabel] ); }; export default Header;