Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions apps/web/src/components/Chat/RoomsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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) ? (
<Rooms
type="uncontacted-tutors"
selectUncontacted={selectTemporary}
data={rooms.uncontactedTutors.list}
data={Tutorslist}
pending={rooms.uncontactedTutors.query.isPending}
fetching={rooms.uncontactedTutors.query.isFetching}
refetch={rooms.uncontactedTutors.query.refetch}
Expand Down
3 changes: 3 additions & 0 deletions architecture/notes/chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@
- Show count of unread messages
- Show actions menu.
- [ ] Impl. [Message Group](https://www.figma.com/design/4SwhwulDQ3eEDqevWprW9E/LiteSpace?node-id=1648-55795&t=mukSSDJcjSRP07Nw-4) component

```ts
interface Props {
messages: Array<{ text: string[]; createdAt: string }>;
username: string | null;
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
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/locales/ar-eg.json
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@
"chat.create.room.error": "حدث خطا أثناء بدء المحادثة برجاء المحاولة مرة أخرى",
"chat.pinned.title": "المحادثات المثبتة",
"chat.all": "جميع الرسائل",
"chat.search": "ابحث هنا",
"chat.search": "ابحث عن معلم",
"chat.online": "نشط الان",
"chat.offline": "نشط {time}",
"chat.book": "احجز الاّن",
Expand Down