diff --git a/apps/web/src/components/Chat/RoomsPanel.tsx b/apps/web/src/components/Chat/RoomsPanel.tsx index e80c6ed3d..238aad1f2 100644 --- a/apps/web/src/components/Chat/RoomsPanel.tsx +++ b/apps/web/src/components/Chat/RoomsPanel.tsx @@ -17,6 +17,7 @@ import { isEmpty } from "lodash"; import { ITutor, IUser } from "@litespace/types"; import { useUser } from "@litespace/headless/context/user"; import { useOnError } from "@/hooks/error"; +import { useTutors } from "@litespace/headless/tutor"; const RoomsPanel: React.FC<{ selectedRoom: number | UncontactedTutorRoomId | null; @@ -39,6 +40,19 @@ const RoomsPanel: React.FC<{ ); const { rooms, keyword, update } = useRoomManager(isStudent); + const Tutors = useTutors(); + + const Tutorslist = useMemo(() => { + const allTutors = + (Tutors.query.data?.pages.flatMap( + (page) => page.list + ) as unknown as ITutor.FullUncontactedTutorInfo[]) ?? []; + + const contactedIds = + rooms.all.list?.map((room) => room.otherMember.id) ?? []; + return allTutors.filter((tutor) => !contactedIds.includes(tutor.id)); + }, [Tutors.query.data, rooms.all.list]); + useOnError({ type: "query", keys: rooms.pinned.keys, @@ -140,13 +154,11 @@ const RoomsPanel: React.FC<{ /> ) : null} - {user?.role === IUser.Role.Student && - rooms.uncontactedTutors.list && - !isEmpty(rooms.uncontactedTutors.list) ? ( + {user?.role === IUser.Role.Student && !isEmpty(Tutorslist) ? ( ; @@ -17,10 +18,12 @@ image: string | null; } ``` + - It should accept username, image, and a list of messages. - It should has two variants `sender` or `receiver` - It should sort message by their time and render them accordingly. - Renedered message date should be the time for the **oldest** message. + - [ ] Render pinned and all rooms - [ ] Render current room messages using the `useMessages` (packages/luna/src/hooks/chat.ts) hook - [ ] Reflect selected room diff --git a/packages/ui/src/locales/ar-eg.json b/packages/ui/src/locales/ar-eg.json index 5401782a1..31bed0316 100644 --- a/packages/ui/src/locales/ar-eg.json +++ b/packages/ui/src/locales/ar-eg.json @@ -636,7 +636,7 @@ "chat.create.room.error": "حدث خطا أثناء بدء المحادثة برجاء المحاولة مرة أخرى", "chat.pinned.title": "المحادثات المثبتة", "chat.all": "جميع الرسائل", - "chat.search": "ابحث هنا", + "chat.search": "ابحث عن معلم", "chat.online": "نشط الان", "chat.offline": "نشط {time}", "chat.book": "احجز الاّن",