updating to have statuses for rooms
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
|||||||
} from "firebase/firestore";
|
} from "firebase/firestore";
|
||||||
import { Collections } from "../../services/collections";
|
import { Collections } from "../../services/collections";
|
||||||
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
|
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
|
||||||
import Room, { RoomType } from "../../models/room";
|
import Room, { RoomStatus, RoomType } from "../../models/room";
|
||||||
import { useAuth } from "../../contexts/authContext";
|
import { useAuth } from "../../contexts/authContext";
|
||||||
import { Radio } from "antd";
|
import { Radio } from "antd";
|
||||||
import RoomCard from "../RoomCard";
|
import RoomCard from "../RoomCard";
|
||||||
@@ -158,7 +158,7 @@ export default function DashboardRoom() {
|
|||||||
(room) => room.type == RoomType.recurring
|
(room) => room.type == RoomType.recurring
|
||||||
);
|
);
|
||||||
const archivedRooms = allRooms.filter(
|
const archivedRooms = allRooms.filter(
|
||||||
(room) => room.type == RoomType.archived
|
(room) => room.status == RoomStatus.archived
|
||||||
);
|
);
|
||||||
|
|
||||||
function getRoomContent() {
|
function getRoomContent() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
useKeyboardContext,
|
useKeyboardContext,
|
||||||
} from "../../contexts/keyboardContext";
|
} from "../../contexts/keyboardContext";
|
||||||
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
|
import { useTeamDashboardContext } from "../../contexts/teamDashboardContext";
|
||||||
import Room, { RoomType } from "../../models/room";
|
import Room, { RoomStatus, RoomType } from "../../models/room";
|
||||||
import RoomService from "../../services/roomService";
|
import RoomService from "../../services/roomService";
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
@@ -46,6 +46,10 @@ export default function CreateRoomModal() {
|
|||||||
newRoom.attachments = [roomAttachment];
|
newRoom.attachments = [roomAttachment];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (roomType == RoomType.now) {
|
||||||
|
newRoom.status = RoomStatus.live;
|
||||||
|
}
|
||||||
|
|
||||||
newRoom.approximateDateTime = roomAppxDateTime;
|
newRoom.approximateDateTime = roomAppxDateTime;
|
||||||
newRoom.link = roomLink;
|
newRoom.link = roomLink;
|
||||||
newRoom.members = [...membersSelected, currUser.uid]; // add currUser to the list of "people"
|
newRoom.members = [...membersSelected, currUser.uid]; // add currUser to the list of "people"
|
||||||
|
|||||||
@@ -208,7 +208,10 @@ export default function RoomCard(props: IRoomCardProps) {
|
|||||||
|
|
||||||
{/* room status and link(s) */}
|
{/* room status and link(s) */}
|
||||||
<span className="flex flex-col items-end justify-between h-full">
|
<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
|
<span
|
||||||
className={`${
|
className={`${
|
||||||
isUserInRoom ? "text-gray-400" : "text-gray-200"
|
isUserInRoom ? "text-gray-400" : "text-gray-200"
|
||||||
|
|||||||
@@ -1,12 +1,33 @@
|
|||||||
import { FaClock } from "react-icons/fa";
|
import { FaClock } from "react-icons/fa";
|
||||||
import { IoTimer } from "react-icons/io5";
|
import { IoTimer } from "react-icons/io5";
|
||||||
import { RoomType } from "../models/room";
|
import { RoomStatus, RoomType } from "../models/room";
|
||||||
|
|
||||||
interface RoomTypeTagProps {
|
interface RoomTypeTagProps {
|
||||||
roomType: RoomType;
|
roomType: RoomType;
|
||||||
|
roomStatus: RoomStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function RoomTypeTag(props: RoomTypeTagProps) {
|
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) {
|
switch (props.roomType) {
|
||||||
case RoomType.now:
|
case RoomType.now:
|
||||||
return (
|
return (
|
||||||
|
|||||||
+7
-1
@@ -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
|
attachments: string[]; // the links themselves (NOT Ids)...there will be duplicate entries in the attachments table which will be created
|
||||||
|
|
||||||
type: RoomType;
|
type: RoomType;
|
||||||
|
status: RoomStatus = RoomStatus.empty;
|
||||||
|
|
||||||
approximateDateTime: string; // vaguely say when the meeting should be...give user pointers
|
approximateDateTime: string; // vaguely say when the meeting should be...give user pointers
|
||||||
|
|
||||||
@@ -30,5 +31,10 @@ export enum RoomType {
|
|||||||
now = "now",
|
now = "now",
|
||||||
scheduled = "scheduled", // one time sort of standard meeting
|
scheduled = "scheduled", // one time sort of standard meeting
|
||||||
recurring = "recurring", //daily standup
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
serverTimestamp,
|
serverTimestamp,
|
||||||
setDoc,
|
setDoc,
|
||||||
} from "firebase/firestore";
|
} from "firebase/firestore";
|
||||||
import Room from "../models/room";
|
import Room, { RoomStatus } from "../models/room";
|
||||||
import { Collections } from "./collections";
|
import { Collections } from "./collections";
|
||||||
|
|
||||||
export default class RoomService {
|
export default class RoomService {
|
||||||
@@ -21,10 +21,20 @@ export default class RoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateMembersInRoom(roomId: string, newMembersInRoom: string[]) {
|
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);
|
const docRef = doc(this.db, Collections.rooms, roomId);
|
||||||
await setDoc(
|
await setDoc(
|
||||||
docRef,
|
docRef,
|
||||||
{ membersInRoom: newMembersInRoom, lastUpdatedDate: serverTimestamp() },
|
{
|
||||||
|
status,
|
||||||
|
membersInRoom: newMembersInRoom,
|
||||||
|
lastUpdatedDate: serverTimestamp(),
|
||||||
|
},
|
||||||
{ merge: true }
|
{ merge: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user