diff --git a/components/Dashboard/Rooms.tsx b/components/Dashboard/Rooms.tsx index 3fd1cff..c9a343e 100644 --- a/components/Dashboard/Rooms.tsx +++ b/components/Dashboard/Rooms.tsx @@ -372,15 +372,19 @@ export default function DashboardRoom() { ROOMS - + + {relativeTimeNextMeeting ? ( diff --git a/components/Modals/CreateOrUpdateRoom.tsx b/components/Modals/CreateOrUpdateRoom.tsx index afcbf26..ed6ddbe 100644 --- a/components/Modals/CreateOrUpdateRoom.tsx +++ b/components/Modals/CreateOrUpdateRoom.tsx @@ -79,14 +79,16 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { props.handleClose(); }; - const handleSubmit = async (e) => { - e.preventDefault(); - + const handleSubmit = async () => { // make sure link, room, and type are selected - if (!roomLink || !roomName) { + if (!roomName) { toast.error("Please fill in room link and name."); return; } + if (!roomLink && !hasGSuite) { + toast.error("must provide room link if you don't have a GSuite"); + return; + } try { const newRoom = new Room(); @@ -95,16 +97,35 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { newRoom.attachments = [roomAttachment]; } + if (hasGSuite) { + // create google meet link based on the room name without spaces + + var slugName = + user.firstName + + "-" + + "room" + + moment(new Date()).format("dddddohmma"); + slugName = slugName.replace(/\s/g, "-"); + + const autoLink = + "https://accounts.google.com/AccountChooser/signinchooser?continue=https://g.co/meet/" + + slugName; + + newRoom.link = autoLink; + } else { + newRoom.link = roomLink; + } + if (roomType == RoomType.now) { // make sure approximate time isn't selected newRoom.approximateDateTime = null; newRoom.status = RoomStatus.live; // automatically add me to the room - newRoom.membersInRoom = [currUser.uid]; + newRoom.membersInRoom = []; // navigate to the new room automatically - window.open(roomLink, "_blank"); + // window.open(roomLink, "_blank"); } else if (roomType == RoomType.scheduled) { // make sure that either appx or time picker is selected, not both if (!dateTimePicker) { @@ -122,7 +143,6 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { newRoom.approximateDateTime = roomAppxDateTime; } - newRoom.link = roomLink; newRoom.members = [...membersSelected]; // add currUser to the list of "people" newRoom.type = roomType; newRoom.description = roomDescription; @@ -133,6 +153,9 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { if (props.updateRoom) { newRoom.id = props.updateRoom.id; newRoom.membersInRoom = props.updateRoom.membersInRoom; + toast.success("updated room"); + } else { + toast.success("created room"); } console.log(newRoom); @@ -142,10 +165,8 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { await roomService.createOrUpdateRoom(newRoom); resetForm(); - - toast.success("done"); } catch (error) { - toast.error("problem creating room"); + toast.error("problem creating/updating room"); console.log(error); } }; @@ -153,7 +174,9 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { function resetForm() { setRoomLink(""); setRoomName( - user.firstName + "'s Room - " + moment(new Date()).format("dddd do") + user.firstName + + "'s Room - " + + moment(new Date()).format("dddd do h:mm a") ); setRoomDescription(""); setMembersSelected([currUser.uid] as string[]); @@ -164,11 +187,13 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { setDateTimePicker(null); setShowMoreDetails(false); + + sethasGSuite(true); } const [roomLink, setRoomLink] = useState(pastedLink ?? ""); const [roomName, setRoomName] = useState( - user.firstName + "'s Room - " + moment(new Date()).format("dddd do") + user.firstName + "'s Room - " + moment(new Date()).format("dddd do h:mm a") ); const [roomDescription, setRoomDescription] = useState(""); @@ -182,6 +207,7 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { const [dateTimePicker, setDateTimePicker] = useState(null); const [showMoreDetails, setShowMoreDetails] = useState(false); + const [hasGSuite, sethasGSuite] = useState(true); function handleSelectMember(value) { // passed in array of selections...userIds @@ -227,20 +253,22 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) { }; function createRoomNow() { - // show modal + console.log("creating room"); - // enter a google meet link automaticall + // reset form for the right values to be in there + // resetForm(); - // create a date based room name + // handleGetAutoGSuiteLink(); - // - - console.log("creating room instantly"); + // submit form + // handleSubmit().then(() => { + // console.log("creating room instantly"); + // }); } const keyMap: KeyMap = { CREATE_ROOM_NOW: { - name: "Stop recording", + name: "create room now", sequence: "q", action: "keyup", }, @@ -260,35 +288,56 @@ export default function CreateOrUpdateRoomModal(props: IModalProps) {
- - Link - {roomLink ? ( - - Please make sure this is valid so that your team can join - properly. - - ) : ( - - + Link + + We'll create a link for you. Don't have a GSuite?{" "} + - )} + + ) : ( + + Link + {roomLink ? ( + + Please make sure this is valid so that your team can join + properly. + + ) : ( + + + Click here to create one + {" "} + and then come back and paste the link for your team.{" "} + + + )} - setRoomLink(e.target.value)} - /> - + setRoomLink(e.target.value)} + /> + + )} Room Name diff --git a/contexts/keyboardContext.tsx b/contexts/keyboardContext.tsx index 80db2bd..6557b37 100644 --- a/contexts/keyboardContext.tsx +++ b/contexts/keyboardContext.tsx @@ -337,9 +337,6 @@ export default function KeyboardContextProvider({ children }) { const handleKeyUp = useCallback( (event) => { - console.log("on key up"); - console.log(event.keyCode); - // if was recording and released R, then stop recording and send message if (event.keyCode == KeyCode.R && selectedTeammate && isRecording) { console.log("stopped recording"); @@ -394,8 +391,6 @@ export default function KeyboardContextProvider({ children }) { return; } - console.log(event.keyCode); - // recording if (event.keyCode == KeyCode.R && !ctrlDown) { if (!audioInputDeviceId) {