-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: notification-resident relation working
Co-authored-by: Kathleen Xiong <[email protected]>
- Loading branch information
1 parent
7c90474
commit 1158c81
Showing
8 changed files
with
82 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ class AdminService implements IAdminService { | |
async getAllNotifications(): Promise<NotificationDTO[]>{ | ||
try { | ||
const notifications = await prisma.notification.findMany({ | ||
// include: {residents: true} | ||
include: {residents: true} | ||
}) | ||
if(!notifications) throw new Error(`No residents found.`); | ||
return notifications; | ||
|
@@ -38,9 +38,9 @@ class AdminService implements IAdminService { | |
where : { | ||
id: Number(id) | ||
}, | ||
// include: { | ||
// residents: true | ||
// } | ||
include: { | ||
residents: true | ||
} | ||
}); | ||
if(!notification) throw new Error(`notification id ${id} not found`); | ||
|
||
|
@@ -58,20 +58,28 @@ class AdminService implements IAdminService { | |
newNotification = await prisma.notification.create({ | ||
data: { | ||
message: String(notif_message), | ||
author: { | ||
// connect: {id: this.staffId} | ||
connect: {id: Number(resident_id)} | ||
}, | ||
// residents: { | ||
// connect: { | ||
// id: Number(resident_id), | ||
// }, | ||
// author: { | ||
// // connect: {id: this.staffId} | ||
// connect: {id: Number(resident_id)} | ||
// // create: { | ||
// // first_name: "TOM", | ||
// // last_name: "BOB", | ||
// // email: "[email protected]", | ||
// // credits: 1.0, | ||
// // date_joined: "2011-10-05T14:48:00.000Z", | ||
// // display_name: "Display_Name" | ||
// // } | ||
// }, | ||
residents: { | ||
connect: { | ||
id: Number(resident_id), | ||
}, | ||
|
||
// } | ||
} | ||
}, | ||
// include: { | ||
// residents: true | ||
// } | ||
include: { | ||
residents: true | ||
} | ||
}) | ||
|
||
// ASK WILLIAM ABOUT ADDING THINGS TO THE LIST OF RESIDENTS IN NOTIFICATION | ||
|
@@ -97,7 +105,7 @@ class AdminService implements IAdminService { | |
where: { | ||
date_left: null //check how we are implementing date_left | ||
}, | ||
// include : { notifications: true } | ||
include : { notifications: true } | ||
}) | ||
|
||
if(!residents) throw new Error(`No residents found.`); | ||
|
@@ -119,18 +127,18 @@ class AdminService implements IAdminService { | |
newNotification = await prisma.notification.create({ | ||
data: { | ||
message: String(notif_message), | ||
author: { | ||
connect: {id: this.staffId} | ||
}, | ||
// author: { | ||
// connect: activeResidents.map(resident => ({ | ||
// id: resident.id | ||
// })) | ||
// } | ||
// connect: {id: this.staffId} | ||
// }, | ||
residents: { | ||
connect: activeResidents.map(resident => ({ | ||
id: resident.id | ||
})) | ||
} | ||
}, | ||
// include: { | ||
// residents: true | ||
// } | ||
include: { | ||
residents: true | ||
} | ||
}) | ||
|
||
// let resident: Prisma.residentUncheckedCreateInput; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters