updating to have statuses for rooms

This commit is contained in:
Arjun Patel
2022-01-17 15:46:28 -08:00
parent 9beb53fa8f
commit 5655df9391
6 changed files with 52 additions and 8 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ import {
} from "firebase/firestore";
import { Collections } from "../../services/collections";
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
import Room, { RoomType } from "../../models/room";
import Room, { RoomStatus, RoomType } from "../../models/room";
import { useAuth } from "../../contexts/authContext";
import { Radio } from "antd";
import RoomCard from "../RoomCard";
@@ -158,7 +158,7 @@ export default function DashboardRoom() {
(room) => room.type == RoomType.recurring
);
const archivedRooms = allRooms.filter(
(room) => room.type == RoomType.archived
(room) => room.status == RoomStatus.archived
);
function getRoomContent() {
+5 -1
View File
@@ -7,7 +7,7 @@ import {
useKeyboardContext,
} from "../../contexts/keyboardContext";
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
import Room, { RoomType } from "../../models/room";
import Room, { RoomStatus, RoomType } from "../../models/room";
import RoomService from "../../services/roomService";
const { Option } = Select;
@@ -46,6 +46,10 @@ export default function CreateRoomModal() {
newRoom.attachments = [roomAttachment];
}
if (roomType == RoomType.now) {
newRoom.status = RoomStatus.live;
}
newRoom.approximateDateTime = roomAppxDateTime;
newRoom.link = roomLink;
newRoom.members = [...membersSelected, currUser.uid]; // add currUser to the list of "people"
+4 -1
View File
@@ -208,7 +208,10 @@ export default function RoomCard(props: IRoomCardProps) {
{/* room status and link(s) */}
<span className="flex flex-col items-end justify-between h-full">
<RoomTypeTag roomType={props.room.type} />
<RoomTypeTag
roomType={props.room.type}
roomStatus={props.room.status}
/>
<span
className={`${
isUserInRoom ? "text-gray-400" : "text-gray-200"
+22 -1
View File
@@ -1,12 +1,33 @@
import { FaClock } from "react-icons/fa";
import { IoTimer } from "react-icons/io5";
import { RoomType } from "../models/room";
import { RoomStatus, RoomType } from "../models/room";
interface RoomTypeTagProps {
roomType: RoomType;
roomStatus: RoomStatus;
}
export default function RoomTypeTag(props: RoomTypeTagProps) {
// show live even if it's some other type because people are in it
if (props.roomStatus == RoomStatus.live) {
return (
<span
className="text-xs bg-red-500
text-white font-bold p-1 rounded-md flex flex-row space-x-2 items-center"
>
<FaClock />
<span>live</span>
</span>
);
} else if (props.roomStatus == RoomStatus.archived) {
return (
<span className="text-gray-700 bg-gray-200 p-1 rounded-md text-xs font-bold flex flex-row items-center space-x-1">
<span>archived</span>
</span>
);
}
// if it's just empty and not empty, then go ahead and show the right type
switch (props.roomType) {
case RoomType.now:
return (
+7 -1
View File
@@ -15,6 +15,7 @@ export default class Room {
attachments: string[]; // the links themselves (NOT Ids)...there will be duplicate entries in the attachments table which will be created
type: RoomType;
status: RoomStatus = RoomStatus.empty;
approximateDateTime: string; // vaguely say when the meeting should be...give user pointers
@@ -30,5 +31,10 @@ export enum RoomType {
now = "now",
scheduled = "scheduled", // one time sort of standard meeting
recurring = "recurring", //daily standup
archived = "archived", // this room is dead or over
}
export enum RoomStatus {
live = "live",
empty = "empty",
archived = "archived", // user marks it over
}
+12 -2
View File
@@ -7,7 +7,7 @@ import {
serverTimestamp,
setDoc,
} from "firebase/firestore";
import Room from "../models/room";
import Room, { RoomStatus } from "../models/room";
import { Collections } from "./collections";
export default class RoomService {
@@ -21,10 +21,20 @@ export default class RoomService {
}
async updateMembersInRoom(roomId: string, newMembersInRoom: string[]) {
// if the room is going to be empty, then change status accordingly
var status: RoomStatus = RoomStatus.live;
if (newMembersInRoom.length == 0) {
status = RoomStatus.empty;
}
const docRef = doc(this.db, Collections.rooms, roomId);
await setDoc(
docRef,
{ membersInRoom: newMembersInRoom, lastUpdatedDate: serverTimestamp() },
{
status,
membersInRoom: newMembersInRoom,
lastUpdatedDate: serverTimestamp(),
},
{ merge: true }
);
}