update modal initial setup
This commit is contained in:
@@ -4,7 +4,7 @@ import { FaAngleDown, FaBell, FaClock, FaPlus, FaLink } from "react-icons/fa";
|
|||||||
import { IoTimer } from "react-icons/io5";
|
import { IoTimer } from "react-icons/io5";
|
||||||
import { BsThreeDots } from "react-icons/bs";
|
import { BsThreeDots } from "react-icons/bs";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import CreateRoom from "../Modals/CreateRoom";
|
import CreateOrUpdateRoom from "../Modals/CreateOrUpdateRoom";
|
||||||
import {
|
import {
|
||||||
ShowModalType,
|
ShowModalType,
|
||||||
useKeyboardContext,
|
useKeyboardContext,
|
||||||
@@ -23,6 +23,7 @@ import Room, { RoomStatus, RoomType } from "../../models/room";
|
|||||||
import { useAuth } from "../../contexts/authContext";
|
import { useAuth } from "../../contexts/authContext";
|
||||||
import { Dropdown, Menu, Radio, Tooltip } from "antd";
|
import { Dropdown, Menu, Radio, Tooltip } from "antd";
|
||||||
import RoomCard from "../RoomCard";
|
import RoomCard from "../RoomCard";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
enum RoomTypeFilter {
|
enum RoomTypeFilter {
|
||||||
team = "team",
|
team = "team",
|
||||||
@@ -44,7 +45,7 @@ lastWeek.setDate(lastWeek.getDate() - 7);
|
|||||||
|
|
||||||
export default function DashboardRoom() {
|
export default function DashboardRoom() {
|
||||||
const { currUser } = useAuth();
|
const { currUser } = useAuth();
|
||||||
const { handleModalType } = useKeyboardContext();
|
const { handleModalType, showModalType } = useKeyboardContext();
|
||||||
const { team } = useTeamDashboardContext();
|
const { team } = useTeamDashboardContext();
|
||||||
|
|
||||||
const [roomsMap, setRoomsMap] = useState<Map<string, Room>>(
|
const [roomsMap, setRoomsMap] = useState<Map<string, Room>>(
|
||||||
@@ -183,10 +184,31 @@ export default function DashboardRoom() {
|
|||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [selectedUpdateRoom, setSelectedUpdateRoom] = useState<Room>(null);
|
||||||
|
|
||||||
|
async function handleUpdateRoom(roomId: string) {
|
||||||
|
console.log("going to update room");
|
||||||
|
|
||||||
|
// get the room details and pass it into the modal
|
||||||
|
if (!roomsMap.has(roomId)) {
|
||||||
|
toast.error("not a valid room to edit");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass this to the modal for use
|
||||||
|
setSelectedUpdateRoom(roomsMap[roomId]);
|
||||||
|
|
||||||
|
// call the keyboard context to show the modal
|
||||||
|
handleModalType(ShowModalType.createRoom);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="p-5 w-full flex flex-col bg-gray-100 bg-opacity-25 rounded-lg shadow-md">
|
<section className="p-5 w-full flex flex-col bg-gray-100 bg-opacity-25 rounded-lg shadow-md">
|
||||||
{/* modal for creating room */}
|
{/* modal for creating room */}
|
||||||
<CreateRoom />
|
<CreateOrUpdateRoom
|
||||||
|
show={showModalType == ShowModalType.createRoom}
|
||||||
|
updateRoom={selectedUpdateRoom}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* header */}
|
{/* header */}
|
||||||
<Tooltip title={" archive rooms to keep your team focused"}>
|
<Tooltip title={" archive rooms to keep your team focused"}>
|
||||||
@@ -252,7 +274,13 @@ export default function DashboardRoom() {
|
|||||||
{/* all rooms */}
|
{/* all rooms */}
|
||||||
<span className="flex flex-row flex-wrap max-h-96 overflow-auto">
|
<span className="flex flex-row flex-wrap max-h-96 overflow-auto">
|
||||||
{getRoomContent().map((room) => {
|
{getRoomContent().map((room) => {
|
||||||
return <RoomCard key={room.id} room={room} />;
|
return (
|
||||||
|
<RoomCard
|
||||||
|
key={room.id}
|
||||||
|
room={room}
|
||||||
|
updateRoomHandler={handleUpdateRoom}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</span>
|
</span>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -12,11 +12,14 @@ import RoomService from "../../services/roomService";
|
|||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
const thisModalType = ShowModalType.createRoom;
|
|
||||||
|
|
||||||
const roomService = new RoomService();
|
const roomService = new RoomService();
|
||||||
|
|
||||||
export default function CreateRoomModal() {
|
interface IModalProps {
|
||||||
|
show: boolean;
|
||||||
|
updateRoom: Room;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CreateOrUpdateRoomModal(props: IModalProps) {
|
||||||
const { currUser } = useAuth();
|
const { currUser } = useAuth();
|
||||||
const { teamUsers, team } = useTeamDashboardContext();
|
const { teamUsers, team } = useTeamDashboardContext();
|
||||||
const { pastedLink, handleModalType, showModalType } = useKeyboardContext();
|
const { pastedLink, handleModalType, showModalType } = useKeyboardContext();
|
||||||
@@ -120,7 +123,7 @@ export default function CreateRoomModal() {
|
|||||||
<Modal
|
<Modal
|
||||||
title="Room Details"
|
title="Room Details"
|
||||||
centered
|
centered
|
||||||
visible={showModalType == thisModalType ? true : false}
|
visible={props.show}
|
||||||
onOk={handleSubmit}
|
onOk={handleSubmit}
|
||||||
onCancel={handleCloseModal}
|
onCancel={handleCloseModal}
|
||||||
>
|
>
|
||||||
@@ -13,9 +13,11 @@ import RoomService from "../services/roomService";
|
|||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import SkeletonLoader from "./Loading/skeletonLoader";
|
import SkeletonLoader from "./Loading/skeletonLoader";
|
||||||
|
import { useKeyboardContext } from "../contexts/keyboardContext";
|
||||||
|
|
||||||
interface IRoomCardProps {
|
interface IRoomCardProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
|
updateRoomHandler: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
const roomService = new RoomService();
|
const roomService = new RoomService();
|
||||||
@@ -188,10 +190,8 @@ export default function RoomCard(props: IRoomCardProps) {
|
|||||||
return <SkeletonLoader />;
|
return <SkeletonLoader />;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleUpdateRoom(e) {
|
async function handleUpdateRoom() {
|
||||||
e.preventDefault();
|
props.updateRoomHandler(props.room.id);
|
||||||
|
|
||||||
console.log("going to update room");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const RoomOptionsMenu = (
|
const RoomOptionsMenu = (
|
||||||
|
|||||||
Reference in New Issue
Block a user