From 7d95ade4ce1b3da9b711d578ba7ab9e78e814978 Mon Sep 17 00:00:00 2001 From: Tay Yi Hsuen Date: Mon, 13 Nov 2023 10:08:28 +0800 Subject: [PATCH] Create release 1.1.1 (#249) Fix some bugs related to loading state, match-finding etc --------- Co-authored-by: Ong Jun Xiong Co-authored-by: chunweii <47494777+chunweii@users.noreply.github.com> --- README.md | 9 ++- frontend/src/components/profile/columns.tsx | 10 +-- .../src/components/profile/data-table.tsx | 25 ++++--- frontend/src/components/room/code-editor.tsx | 48 ++++++++----- frontend/src/components/room/video-room.tsx | 24 +++++-- frontend/src/hooks/useCollaboration.tsx | 23 +++--- frontend/src/hooks/useMatch.tsx | 5 +- frontend/src/pages/api/matchHandler.ts | 3 +- frontend/src/pages/api/questionHandler.ts | 10 +-- frontend/src/pages/attempt/[id]/index.tsx | 3 +- frontend/src/pages/interviews/find-match.tsx | 14 +++- frontend/src/pages/interviews/index.tsx | 4 ++ frontend/src/pages/questions/[id]/index.tsx | 10 ++- frontend/src/pages/room/[id].tsx | 54 ++++++++++---- .../src/providers/MatchmakingProvider.tsx | 58 +++++++++++++-- .../collaboration-service/src/db/prisma-db.ts | 15 ++-- .../collaboration-service/src/routes/room.ts | 22 +++--- services/matching-service/src/app.ts | 3 + .../src/controllers/matchingController.ts | 71 ++++++++++++++++++- services/question-service/src/routes/index.ts | 30 +++++++- 20 files changed, 334 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index 5f79a4ca..031fcb93 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,11 @@ your services / frontend. ├── /frontend │ └── /pages for peerprep (NextJs application) ├── /deployment -│ ├── /docker -│ └── /kubernetes +│ ├── /gke-prod-manifests +│ ├── /prod-dockerfiles +│ └── build-export-prod-images.sh +├── /prisma +├── /utils ├── .env (not in git) ├── .env.firebase_emulators_test (not in git) └── README.md (and other root-level files & docs) @@ -137,6 +140,8 @@ Docker and Docker Compose are used to set up a simulated production build (meani containers that will be spun up locally are almost identical to those in the production environment, with the exception of some environment variables). +NOTE: Do not run both Docker and No Docker at the same time. This will cause port conflicts. + 1. **Run yarn docker:build:** From the root repo, run ```bash diff --git a/frontend/src/components/profile/columns.tsx b/frontend/src/components/profile/columns.tsx index 2f0cea8f..73d9cf15 100644 --- a/frontend/src/components/profile/columns.tsx +++ b/frontend/src/components/profile/columns.tsx @@ -1,5 +1,5 @@ -import { Attempt } from "@/types/UserTypes" -import { ColumnDef } from "@tanstack/react-table" +import { Attempt } from "@/types/UserTypes"; +import { ColumnDef } from "@tanstack/react-table"; import { Button } from "../ui/button"; export const columns: ColumnDef[] = [ @@ -16,7 +16,7 @@ export const columns: ColumnDef[] = [ header: "Status", cell: ({ row }) => { const solved = row.getValue("solved") as boolean; - return (solved ?
Solved
: "Unsolved"); + return solved ?
Solved
: "Unsolved"; }, }, { @@ -26,6 +26,8 @@ export const columns: ColumnDef[] = [ const timeCreated = row.getValue("time_created") as Date; return timeCreated.toLocaleString(); }, + enableSorting: true, + sortDescFirst: true, }, { id: "actions", @@ -46,4 +48,4 @@ export const columns: ColumnDef[] = [ ); }, }, -] +]; diff --git a/frontend/src/components/profile/data-table.tsx b/frontend/src/components/profile/data-table.tsx index a9bc6627..da262c2e 100644 --- a/frontend/src/components/profile/data-table.tsx +++ b/frontend/src/components/profile/data-table.tsx @@ -3,7 +3,8 @@ import { flexRender, getCoreRowModel, useReactTable, -} from "@tanstack/react-table" + getSortedRowModel, +} from "@tanstack/react-table"; import { Table, @@ -12,11 +13,11 @@ import { TableHead, TableHeader, TableRow, -} from "@/components/ui/table" +} from "@/components/ui/table"; interface DataTableProps { - columns: ColumnDef[] - data: TData[] + columns: ColumnDef[]; + data: TData[]; } export function DataTable({ @@ -27,7 +28,11 @@ export function DataTable({ data, columns, getCoreRowModel: getCoreRowModel(), - }) + initialState: { + sorting: [{ id: "time_created", desc: true }], + }, + getSortedRowModel: getSortedRowModel(), + }); return (
@@ -41,11 +46,11 @@ export function DataTable({ {header.isPlaceholder ? null : flexRender( - header.column.columnDef.header, - header.getContext() - )} + header.column.columnDef.header, + header.getContext() + )} - ) + ); })} ))} @@ -74,5 +79,5 @@ export function DataTable({
- ) + ); } diff --git a/frontend/src/components/room/code-editor.tsx b/frontend/src/components/room/code-editor.tsx index 4046a112..0dbeb2f5 100644 --- a/frontend/src/components/room/code-editor.tsx +++ b/frontend/src/components/room/code-editor.tsx @@ -37,7 +37,7 @@ type CodeEditorProps = { onChange: React.Dispatch>; onCursorChange?: React.Dispatch>; hasRoom?: boolean; - onSubmitClick?: (param: string) => void; + onSubmitClick?: (param: string, solved: boolean) => void; onLeaveRoomClick?: () => void; }; @@ -72,6 +72,7 @@ export default function CodeEditor({ }: CodeEditorProps) { const [open, setOpen] = React.useState(false); const [value, setValue] = React.useState(""); + const [frameWork, setFrameWork] = React.useState(language); // default to python const [isSubmitting, setIsSubmitting] = React.useState(false); const [monacoInstance, setMonacoInstance] = @@ -114,13 +115,13 @@ export default function CodeEditor({ [onChange, onCursorChange, monacoInstance] ); - const handleOnSubmitClick = async () => { + const handleOnSubmitClick = async (solved: boolean) => { if (isSubmitting) { return; // Do nothing if a submission is already in progress. } setIsSubmitting(true); try { - onSubmitClick(monacoInstance?.getValue() ?? value); + onSubmitClick(monacoInstance?.getValue() ?? value, solved); } catch (error) { console.log(error); } @@ -137,8 +138,8 @@ export default function CodeEditor({ aria-expanded={open} className="w-[240px] justify-between" > - {value - ? languages.find((framework) => framework.value === value) + {frameWork + ? languages.find((framework) => framework.value === frameWork) ?.label : "Select framework..."} @@ -153,14 +154,18 @@ export default function CodeEditor({ { - setValue(currentValue === value ? "" : currentValue); + setFrameWork( + currentValue === frameWork ? "" : currentValue + ); setOpen(false); }} > {framework.label} @@ -183,8 +188,9 @@ export default function CodeEditor({ ) : ( - +
+ + +
)} diff --git a/frontend/src/components/room/video-room.tsx b/frontend/src/components/room/video-room.tsx index 5a322815..e9b24c4b 100644 --- a/frontend/src/components/room/video-room.tsx +++ b/frontend/src/components/room/video-room.tsx @@ -1,16 +1,18 @@ -import React, { useEffect, useRef, useState } from 'react'; +import React, { useContext, useEffect, useRef, useState } from 'react'; import { LocalParticipant, LocalVideoTrack, Participant, RemoteParticipant, RemoteAudioTrack, RemoteVideoTrack, Room, Track } from 'twilio-video'; import { Button } from '../ui/button'; import { Mic, MicOff, Video, VideoOff } from 'lucide-react'; +import { useUser } from '@/hooks/useUser'; +import { AuthContext } from '../../contexts/AuthContext'; interface VideoRoomProps { room: Room | null; className?: string; } -function SingleVideoTrack({ track, userId, isLocal, isMute, toggleMute, isCameraOn, toggleCamera }: +function SingleVideoTrack({ track, userId, displayName, isLocal, isMute, toggleMute, isCameraOn, toggleCamera }: { - track: RemoteVideoTrack | LocalVideoTrack, userId: string, isLocal: boolean, + track: RemoteVideoTrack | LocalVideoTrack, userId: string, displayName: string, isLocal: boolean, isMute: boolean, toggleMute: () => void, isCameraOn: boolean, toggleCamera: () => void }) { @@ -31,7 +33,7 @@ function SingleVideoTrack({ track, userId, isLocal, isMute, toggleMute, isCamera
-

{userId}

+

{displayName}

{isLocal ?