import { LinkType } from "@nirvana/common/models/link"; import { UserStatus } from "@nirvana/common/models/user"; import { Tooltip } from "antd"; import { duration } from "moment"; import { useEffect, useRef } from "react"; import toast from "react-hot-toast"; import { FaCheck, FaEdit, FaExternalLinkAlt, FaGithub, FaImages, FaMicrophone, FaPlay, FaRegClock, FaRocket, } from "react-icons/fa"; import LinkIcon from "../Drawer/LinkIcon"; import UserAvatar, { UserAvatarSizes } from "../UserDetails/UserAvatar"; import { useRecoilValue } from "recoil"; import { allRelevantConversationsAtom } from "../../recoil/main"; import { useRouter } from "next/router"; import Conversation from "@nirvana/common/models/conversation"; import { useAuth } from "../../contexts/authContext"; import { QueryRoutes, Routes } from "@nirvana/common/helpers/routes"; import { MasterAvatarGroupWithUserFetch } from "../UserDetails/MasterAvatarGroup"; const testDrawerItems: { linkType: LinkType; linkName: string; relativeSentTime: string; }[] = [ { linkType: LinkType.googleMeet, linkName: "Gmeet - Meeting Link", relativeSentTime: "5 seconds ago", }, { linkType: LinkType.atlassian, linkName: "Jira Ticket - Ecommerce Plugin", relativeSentTime: "20 minutes ago", }, { linkType: LinkType.github, linkName: "React library for hotkeys", relativeSentTime: "2 hours ago", }, { linkType: LinkType.googleDrive, linkName: "Engineering - Team Drive Folder", relativeSentTime: "last week", }, ]; const testAudioClips: { senderName: string; relativeSentTime: string; duration: number; alreadyPlayed: boolean; isGap?: boolean; isLink?: boolean; }[] = [ { senderName: "John", relativeSentTime: "yesterday", duration: 150, alreadyPlayed: true, }, { senderName: "Moha", relativeSentTime: "5 minutes ago", duration: 600, alreadyPlayed: false, isGap: true, }, { senderName: "Alex", relativeSentTime: "7 hours ago", duration: 10, alreadyPlayed: false, }, { senderName: "Ben", relativeSentTime: "2 hours ago", duration: 300, alreadyPlayed: false, }, { senderName: "Alex", relativeSentTime: "30 minutes ago", duration: 200, alreadyPlayed: false, }, { senderName: "Moha", relativeSentTime: "8 minutes ago", duration: 600, alreadyPlayed: false, isLink: true, }, { senderName: "Moha", relativeSentTime: "5 minutes ago", duration: 600, alreadyPlayed: false, }, ]; export default function ViewConvo(props: { conversationId: string }) { const { currUser } = useAuth(); const allConvosMap = useRecoilValue(allRelevantConversationsAtom); const endOfTimeline = useRef(); const router = useRouter(); useEffect(() => { endOfTimeline.current?.scrollIntoView({ behavior: "smooth" }); }, []); // auth if do not have this conversation in react cache, then we are not authorized // if somehow it's still cached but we were removed, // then authenticate by checking if we are in the array of users for the conversation const convo: Conversation | undefined = allConvosMap.get( props.conversationId ); useEffect(() => { if (!convo || !convo.activeMembers.includes(currUser!.uid)) { toast.error("Not authorized for this conversation"); router.push({ pathname: Routes.home, query: { page: QueryRoutes.convos }, }); } }, []); return ( <>
{/* main timeline view with action buttons on top */}
{/* header */} {convo?.name} {convo?.tldr && ( tldr: {convo?.tldr} )} {convo?.activeMembers.length} members {/* have one row, but just translate it along y downward to put it in it's own place */} {testAudioClips.map((audClip, index) => { if (audClip.isGap) { return ( ... ); } else if (audClip.isLink) { return ( ); } return ( toast(`${audClip.senderName} speaking...`)} key={index} className={`hover:cursor-pointer flex flex-row items-center p-5 h-[5rem] shadow shrink-0 last:animate-pulse last:bg-orange-200 ${ index % 2 == 1 && "translate-y-[4.75rem] border-t-4 border-t-teal-600" } ${index % 2 == 0 && "border-b-4 border-b-teal-600"} ${ audClip.alreadyPlayed ? "bg-slate-100 border" : "bg-sky-100 " }`} style={{ minWidth: "max-content", width: `${Math.round(audClip.duration)}px`, }} > {audClip.senderName} {audClip.relativeSentTime} ); })} {/* stuff for recording and playing action */}
{/* drawer items */}
Shared {/* row of cards drawer items */} {testDrawerItems.map((link) => ( {/* */} {link.linkName} {link.relativeSentTime} ))}
); }