update modal cleaner now and see the data and all
This commit is contained in:
@@ -196,7 +196,7 @@ export default function DashboardRoom() {
|
||||
}
|
||||
|
||||
// pass this to the modal for use
|
||||
setSelectedUpdateRoom(roomsMap[roomId]);
|
||||
setSelectedUpdateRoom(roomsMap.get(roomId));
|
||||
|
||||
// call the keyboard context to show the modal
|
||||
handleModalType(ShowModalType.createRoom);
|
||||
|
||||
@@ -24,6 +24,25 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) {
|
||||
const { teamUsers, team } = useTeamDashboardContext();
|
||||
const { pastedLink, handleModalType, showModalType } = useKeyboardContext();
|
||||
|
||||
// handle when we want to update a room and props changes
|
||||
// prefill with existing stuff
|
||||
useEffect(() => {
|
||||
console.log("change in props");
|
||||
|
||||
if (props.updateRoom) {
|
||||
setRoomLink(props.updateRoom.link);
|
||||
setRoomName(props.updateRoom.name);
|
||||
setRoomDescription(props.updateRoom.description);
|
||||
if (props.updateRoom.attachments && props.updateRoom.attachments[0]) {
|
||||
setRoomAttachment(props.updateRoom.attachments[0]);
|
||||
}
|
||||
setMembersSelected(props.updateRoom.members);
|
||||
setRoomType(props.updateRoom.type);
|
||||
setRoomAppxDateTime(props.updateRoom.approximateDateTime);
|
||||
}
|
||||
}, [props.updateRoom]);
|
||||
|
||||
// update state when user does ctrl + v
|
||||
useEffect(() => {
|
||||
// todo: check if link is valid google meet link? again?
|
||||
setRoomLink(pastedLink);
|
||||
@@ -62,7 +81,11 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) {
|
||||
newRoom.createdByUserId = currUser.uid;
|
||||
newRoom.teamId = team.id;
|
||||
|
||||
await roomService.createRoom(newRoom);
|
||||
if (props.updateRoom) {
|
||||
newRoom.id = props.updateRoom.id;
|
||||
}
|
||||
|
||||
await roomService.createOrUpdateRoom(newRoom);
|
||||
|
||||
resetForm();
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ export default function RoomCard(props: IRoomCardProps) {
|
||||
isUserInRoom ? "text-gray-400" : "text-gray-200"
|
||||
} text-xs text-right mb-auto`}
|
||||
>
|
||||
on and off all day
|
||||
{props.room.approximateDateTime}
|
||||
</span>
|
||||
|
||||
{/* room attachments */}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ export default class Room {
|
||||
|
||||
membersInRoom: string[] = [];
|
||||
|
||||
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;
|
||||
status: RoomStatus = RoomStatus.empty;
|
||||
|
||||
@@ -13,11 +13,17 @@ import { Collections } from "./collections";
|
||||
export default class RoomService {
|
||||
private db: Firestore = getFirestore();
|
||||
|
||||
async createRoom(room: Room) {
|
||||
const roomDocRef = await addDoc(collection(this.db, Collections.rooms), {
|
||||
...room,
|
||||
createdDate: serverTimestamp(),
|
||||
});
|
||||
async createOrUpdateRoom(room: Room) {
|
||||
if (room.id) {
|
||||
//update
|
||||
await this.updateRoom(room);
|
||||
} else {
|
||||
//create
|
||||
const roomDocRef = await addDoc(collection(this.db, Collections.rooms), {
|
||||
...room,
|
||||
createdDate: serverTimestamp(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async updateMembersInRoom(roomId: string, newMembersInRoom: string[]) {
|
||||
|
||||
Reference in New Issue
Block a user