Skip to content

Commit 72709c9

Browse files
committed
firebase push notification setup | reports based on date on teachers dashboard
1 parent dc22e21 commit 72709c9

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

components/student.component.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -861,35 +861,28 @@ const sendNotification = async (message, userTokens) => {
861861
data: {
862862
title: message.title,
863863
body: message.body,
864-
},
865-
fcmOptions: {
866-
link: "https://students.wisechamps.com",
864+
url: message.url,
867865
},
868866
},
869867
android: {
870-
channelId: "default",
871868
priority: "high",
872-
actions: [
873-
{
874-
title: "Join Now",
875-
pressAction: {
876-
id: "view",
877-
},
878-
},
879-
],
869+
notification: {
870+
channelId: "default",
871+
sound: "default",
872+
visibility: "public",
873+
priority: "max",
874+
},
880875
},
881876
apns: {
882877
payload: {
883878
aps: {
884-
contentAvailable: 1,
885879
sound: "default",
886-
category: "reminder",
887-
threadId: "reminder",
888880
},
889881
},
890882
},
891-
priority: "high",
883+
priority: 10,
892884
});
885+
893886
return response;
894887
} catch (error) {
895888
return error;

components/teacher.component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const getTeacherDetailsWithEmail = async (email, pass) => {
5454
};
5555
};
5656

57-
const getDailyReports = async (grade) => {
57+
const getDailyReports = async (grade, date) => {
5858
const zohoToken = await getZohoTokenOptimized();
5959
const zohoConfig = {
6060
headers: {
@@ -64,7 +64,7 @@ const getDailyReports = async (grade) => {
6464
},
6565
};
6666

67-
const date = new Date();
67+
const date = new Date(date);
6868
const year = date.getFullYear();
6969
const month = (date.getMonth() + 1).toString().padStart(2, "0");
7070
const day = date.getDate().toString().padStart(2, "0");

controllers/teachers.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ teacherRouter.post("/", authMiddleware, async (req, res) => {
1818

1919
teacherRouter.post("/report", authMiddleware, async (req, res) => {
2020
try {
21-
const { grade } = req.body;
22-
const data = await getDailyReports(grade);
21+
const { grade, date } = req.body;
22+
const data = await getDailyReports(grade, date);
2323
res.status(200).send(data);
2424
} catch (error) {
2525
// console.log("error---", error);

0 commit comments

Comments
 (0)