import Meeting from "./Meeting";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import List from "@mui/material/List";
import { useState, useEffect } from "react";
import { useAppSelector } from "../../redux/hooks";
import { selectMeetings } from "../../redux/slices/meetingsAndUserStatusSlice";
import { selectUsers } from "../../redux/slices/usersSlice";
import { formatTimeFromDate } from "../../utils";
import UserLite from "../../api-bodies/UserLite";
const EmptyMeetingsList: React.FC = () => {
return (
{/*
*/}
No Meetings in Progress
Click the buttons on the right to create a meeting
);
}
const MeetingsList: React.FC = () => {
const meetings = useAppSelector(selectMeetings);
const uuids: string[] = [];
meetings.forEach((meeting) => {
meeting.liveParticipantIds.forEach((uuid) => {
if (!uuids.includes(uuid)) {
uuids.push(uuid);
}
});
});
const participants = useAppSelector((state) => selectUsers(state, uuids));
// const participants: (UserLite | undefined)[] = [];
// uuids.forEach((uuid) => {
// const userLite = useAppSelector((state) =>
// selectUser(state,uuid)
// );
// participants.push(userLite);
// });
const [currentDate, setCurrentDate] = useState(new Date());
useEffect(() => {
setInterval(() => setCurrentDate(new Date()), 1000);
}, []);
let i = 1;
return (
<>
{meetings.map((meeting) => {
const meetingMembers: UserLite[] = [];
participants.forEach((userLite) => {
if (
userLite != undefined &&
meeting.liveParticipantIds.includes(userLite.uuid)
) {
meetingMembers.push(userLite);
}
});
const startDate = new Date(meeting.startTime);
const startDatemil = startDate.getTime();
const endDatemil = startDatemil + meeting.duration * 60000;
const endDate = new Date(endDatemil);
const currentDatemil = currentDate.getTime();
const meetingMembersString = () => {
if (meetingMembers.length > 3) {
return (
"Participants: " +
meetingMembers[0].name +
", " +
meetingMembers[1].name +
", " +
meetingMembers[2].name +
", and " +
(meetingMembers.length - 3).toString() +
" more..."
);
} else {
return (
"Participants: " +
meetingMembers.map((userLite) => " " + userLite.name).toString()
);
}
};
console.log(meetingMembersString);
if ((currentDatemil >= startDatemil && currentDatemil <= endDatemil) || meeting.liveParticipantIds.length > 0) {
const lastMeetingClass = meetings.length == i ? " lastMeeting" : "";
i += 1;
return (
" " + userLite.name + " ")
.toString()}
/>
);
}
})}
{i === 1 ? : <>>}
>
);
}
const MeetingsPanel: React.FC = () => {
return (
);
};
export default MeetingsPanel;