Commit 1d8c7cf 1 parent 3d796ec commit 1d8c7cf Copy full SHA for 1d8c7cf
File tree 17 files changed +188
-14
lines changed
17 files changed +188
-14
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export default function ChatList() {
8
8
9
9
return (
10
10
< div >
11
- {
11
+ {
12
12
rooms . rooms . map ( ( room ) => {
13
13
return < p > { room . name } </ p >
14
14
} )
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export default function MessageButtonIndicator() {
16
16
getChatRooms ( ) . then ( ( loadedRooms ) => {
17
17
dispatch ( {
18
18
type : CHATROOMS_LOADED ,
19
- rooms : loadedRooms ,
19
+ rooms : loadedRooms . rooms ,
20
+ unreadCount : loadedRooms . unreadCount
20
21
} )
21
22
} ) . catch ( ( error ) => {
22
23
dispatch ( {
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ import { ChatRoom } from "@/types/chat";
4
4
import { auth } from "@/auth" ;
5
5
import executeQuery from "@/db" ;
6
6
7
- export default async function getChatRooms ( ) : Promise < ChatRoom [ ] > {
7
+ export default async function getChatRooms ( ) : Promise < { unreadCount : number , rooms : ChatRoom [ ] } > {
8
8
9
9
const session = await auth ( ) ;
10
10
if ( ! session ) {
11
- return [ ] ;
11
+ return { unreadCount : 0 , rooms : [ ] } ;
12
12
}
13
13
14
14
console . log ( 'Obtention de la liste de discussion.' ) ;
@@ -43,7 +43,7 @@ export default async function getChatRooms(): Promise<ChatRoom[]> {
43
43
roomID : room . roomID ,
44
44
name : room . name ,
45
45
iconPath : room . iconPath ,
46
- unreadCount : room . unreadCount ?? 0 ,
46
+ unreadCount : parseInt ( room . unreadCount ?? '0' ) ,
47
47
lastChat : null /* {
48
48
chatID: room.lastChat.chatID,
49
49
chatRoomID: room.lastChat.chatRoomID,
@@ -60,6 +60,5 @@ export default async function getChatRooms(): Promise<ChatRoom[]> {
60
60
61
61
console . log ( "Liste obtenue : " , rooms ) ;
62
62
63
-
64
- return rooms ;
63
+ return { unreadCount : 0 , rooms : rooms } ;
65
64
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .accounts (
3
+ id serial NOT NULL ,
4
+ " userId" integer NOT NULL ,
5
+ type
6
+ character varying (255 ) NOT NULL ,
7
+ provider character varying (255 ) NOT NULL ,
8
+ " providerAccountId" character varying (255 ) NOT NULL ,
9
+ refresh_token text NULL ,
10
+ access_token text NULL ,
11
+ expires_at bigint NULL ,
12
+ id_token text NULL ,
13
+ scope text NULL ,
14
+ session_state text NULL ,
15
+ token_type text NULL
16
+ );
17
+
18
+ ALTER TABLE
19
+ public .accounts
20
+ ADD
21
+ CONSTRAINT accounts_pkey PRIMARY KEY (id)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .attachements (
3
+ " attachementID" serial NOT NULL ,
4
+ " chatID" integer NOT NULL ,
5
+ author integer NOT NULL ,
6
+ type
7
+ character varying (10 ) NULL ,
8
+ path text NOT NULL ,
9
+ size integer NULL ,
10
+ mime_type character varying (255 ) NULL
11
+ );
12
+
13
+ ALTER TABLE
14
+ public .attachements
15
+ ADD
16
+ CONSTRAINT attachements_pkey PRIMARY KEY (attachementID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .chatreadedby (
3
+ " chatID" integer NOT NULL ,
4
+ " userID" integer NOT NULL
5
+ );
6
+
7
+ ALTER TABLE
8
+ public .chatreadedby
9
+ ADD
10
+ CONSTRAINT chat_readedby_pkey PRIMARY KEY (chatID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .chatrooms (
3
+ " roomID" serial NOT NULL ,
4
+ name character varying (255 ) NULL ,
5
+ " iconPath" text NULL ,
6
+ " unreadCount" integer NULL DEFAULT 0 ,
7
+ " lastChatID" integer NULL
8
+ );
9
+
10
+ ALTER TABLE
11
+ public .chatrooms
12
+ ADD
13
+ CONSTRAINT chatrooms_pkey PRIMARY KEY (roomID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .chatroommembers (
3
+ " roomID" integer NOT NULL ,
4
+ " userID" integer NOT NULL
5
+ );
6
+
7
+ ALTER TABLE
8
+ public .chatroommembers
9
+ ADD
10
+ CONSTRAINT chatroommembers_pkey PRIMARY KEY (roomID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .chats (
3
+ " chatID" serial NOT NULL ,
4
+ " chatRoomID" integer NOT NULL ,
5
+ " sendDate" timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP ,
6
+ author integer NULL ,
7
+ " textContent" text NULL ,
8
+ " responseTo_chatID" integer NULL
9
+ );
10
+
11
+ ALTER TABLE
12
+ public .chats
13
+ ADD
14
+ CONSTRAINT chats_pkey PRIMARY KEY (chatID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .courses (
3
+ " courseID" character varying (255 ) NOT NULL DEFAULT nextval(' "courses_courseID_seq"' ::regclass),
4
+ " courseName" character varying (255 ) NULL ,
5
+ " courseDesc" character varying (255 ) NULL ,
6
+ " courseTeacherID" character varying (255 ) NOT NULL DEFAULT 0 ,
7
+ " courseIcon" character varying (255 ) NULL ,
8
+ " stripeItemID" character varying (255 ) NULL
9
+ );
10
+
11
+ ALTER TABLE
12
+ public .courses
13
+ ADD
14
+ CONSTRAINT courses_pkey PRIMARY KEY (courseID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .courseregistrations (
3
+ " courseRegID" serial NOT NULL ,
4
+ " studentID" character varying (255 ) NOT NULL ,
5
+ " purchaseDate" timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP ,
6
+ " courseProgress" integer NOT NULL DEFAULT 0 ,
7
+ " lastReadChapter" character varying (255 ) NULL ,
8
+ " earnedXP" integer NOT NULL DEFAULT 0 ,
9
+ " isFavorite" boolean NULL DEFAULT true,
10
+ " checkoutSessionID" character varying (255 ) NULL ,
11
+ " courseID" character varying (255 ) NULL ,
12
+ " stripeItemID" character varying (255 ) NULL
13
+ );
14
+
15
+ ALTER TABLE
16
+ public .courseregistrations
17
+ ADD
18
+ CONSTRAINT courseregistrations_pkey PRIMARY KEY (courseRegID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .privatelessons (
3
+ " tutoringID" serial NOT NULL ,
4
+ " stripeItemID" character varying (255 ) NULL ,
5
+ " studentID" character varying (255 ) NULL
6
+ );
7
+
8
+ ALTER TABLE
9
+ public .privatelessons
10
+ ADD
11
+ CONSTRAINT private_lessons_pkey PRIMARY KEY (tutoringID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .progress (
3
+ " progressID" serial NOT NULL ,
4
+ " progressDate" timestamp without time zone NOT NULL DEFAULT now(),
5
+ " progressType" character varying (255 ) NULL ,
6
+ " userID" character varying (255 ) NULL ,
7
+ " courseID" character varying (255 ) NULL ,
8
+ " progressScore" integer NOT NULL DEFAULT 0
9
+ );
10
+
11
+ ALTER TABLE
12
+ public .progress
13
+ ADD
14
+ CONSTRAINT progress_pkey PRIMARY KEY (progressID)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .sessions (
3
+ id serial NOT NULL ,
4
+ " userId" integer NOT NULL ,
5
+ expires timestamp with time zone NOT NULL ,
6
+ " sessionToken" character varying (255 ) NOT NULL
7
+ );
8
+
9
+ ALTER TABLE
10
+ public .sessions
11
+ ADD
12
+ CONSTRAINT sessions_pkey PRIMARY KEY (id)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .users (
3
+ id serial NOT NULL ,
4
+ name character varying (255 ) NULL ,
5
+ email character varying (255 ) NULL ,
6
+ " emailVerified" timestamp with time zone NULL ,
7
+ image text NULL ,
8
+ role character varying (50 ) NULL DEFAULT ' student' ::character varying,
9
+ status character varying (50 ) NULL DEFAULT ' active' ::character varying,
10
+ " stripeCustomerID" character varying (255 ) NULL ,
11
+ " lastViewedChapterURL" character varying (255 ) NULL
12
+ );
13
+
14
+ ALTER TABLE
15
+ public .users
16
+ ADD
17
+ CONSTRAINT users_pkey PRIMARY KEY (id)
Original file line number Diff line number Diff line change
1
+ CREATE TABLE
2
+ public .verification_token (
3
+ identifier text NOT NULL ,
4
+ expires timestamp with time zone NOT NULL ,
5
+ token text NOT NULL
6
+ );
7
+
8
+ ALTER TABLE
9
+ public .verification_token
10
+ ADD
11
+ CONSTRAINT verification_token_pkey PRIMARY KEY (identifier)
You can’t perform that action at this time.
0 commit comments