import { Box, Button, IconButton, Typography } from "@mui/material"; import React from "react"; import PhoneIcon from "@mui/icons-material/Phone"; import AddIcon from "@mui/icons-material/Add"; import UserLite from "../../../../api-bodies/UserLite"; import UserStatus from "../../../../api-bodies/UserStatus"; import { useAppSelector, useAppDispatch } from "../../../../redux/hooks"; import { selectUserStatus, selectMeeting, } from "../../../../redux/slices/meetingsAndUserStatusSlice"; import { selectFavorites, addFavorite, removeFavorite, } from "../../../../redux/slices/favoritesSlice"; import RemoveIcon from "@mui/icons-material/Remove"; import { MeetingStatus } from "../../../../utils"; import { selectManager, selectMe } from "../../../../redux/slices/usersSlice"; import axios from "../../../../api/axios"; import NewMeeting from "../../../../api-bodies/NewMeeting"; interface Props { contactInfo: UserLite; } const UpperBody: React.FC = ({ contactInfo }) => { const dispatch = useAppDispatch(); const userStatus: UserStatus = useAppSelector((state) => selectUserStatus(state, contactInfo.uuid) ); const me = useAppSelector(selectMe); const favoritesUuids = useAppSelector(selectFavorites); const detailedMeeting = useAppSelector((state) => selectMeeting(state, userStatus.inMeeting ? userStatus.meetingId : null) ); const managerId = useAppSelector(selectManager); const meetingStatus: MeetingStatus = managerId === contactInfo.uuid ? MeetingStatus.NOT_AVAILABLE : userStatus && userStatus.inMeeting ? MeetingStatus.IN_MEETING : MeetingStatus.NOT_IN_MEETING; const startCall = async () => { const newMeeting: NewMeeting = { startTime: "2022-03-30T23:40:00Z", duration: 30, topic: `Meeting with ${contactInfo.name}`, registrantIds: [contactInfo.uuid], }; try { const response = await axios.post( `/users/${me}/meetings`, JSON.stringify(newMeeting) ); window.open(response.data.joinUrl, "_blank")?.focus(); } catch (e) { console.log(e); } }; return ( {contactInfo.name} {!favoritesUuids.includes(contactInfo.uuid) ? ( ) : ( )} {meetingStatus} {detailedMeeting ? ( {detailedMeeting.topic} ) : null} ); }; export default UpperBody;