Skip to content

Commit

Permalink
Notification Done
Browse files Browse the repository at this point in the history
  • Loading branch information
devamdoshi212 committed Nov 24, 2023
1 parent 84bec43 commit f24ff42
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Controller/AthleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ module.exports.goalOfAthletes = async function (req, res) {
let first = new Date(goal.startdate);

while (first.getTime() < new Date(goal.targetdate).getTime()) {
first.setTime(first.getTime() + 60000);
first.setTime(first.getTime() + 3600000);

setReminder(
new Date(first), // Ensure you pass a new Date object to setReminder
Expand Down
43 changes: 21 additions & 22 deletions Controller/ComplaintController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const ComplaintModel = require("../Model/ComplaintModel");
const athleteModel = require("../Model/athleteModel");
const { sendPushNotification } = require("../PushNotification");
const { setReminder } = require("../SetReminder");

module.exports.addComplaint = async function (req, res) {
// console.log("file detail => " + req.file);
Expand Down Expand Up @@ -28,15 +29,15 @@ module.exports.addComplaintApp = async function (req, res) {
let Complaint = new ComplaintModel(req.body);

let data = await Complaint.save();
let Supervisor = await athleteModel
.findOne({ userId: req.body.userId })
.populate("createdBy");
if (Supervisor.createdBy.notificationtoken) {
sendPushNotification(
Supervisor.createdBy.notificationtoken,
"Athlete Raised Complaint",
"Click to View.."
);
if (req.body.level === 0) {
let Supervisor = await athleteModel
.findOne({ userId: req.body.userId })
.populate("createdBy");
if (Supervisor.createdBy !== undefined) {
setReminder(Date.now(), "Click to View..", "Athlete Raised Complaint", [
Supervisor.createdBy,
]);
}
}
console.log(data);

Expand Down Expand Up @@ -93,24 +94,22 @@ module.exports.updateComplaint = async function (req, res) {
if (req.body.status !== undefined) {
Complaint.status = req.body.status;
if (req.body.status === 1) {
if (Complaint.userId.notificationtoken) {
sendPushNotification(
Complaint.userId.notificationtoken,
"Your Complaint Solved",
"Let us know about are you satisfied or not!"
);
}
setReminder(
Date.now(),
"Let us know about are you satisfied or not!",
"Your Complaint Solved",
[Complaint.userId]
);
}
}

if (req.body.level !== undefined) {
Complaint.level = req.body.level;
if (Complaint.userId.notificationtoken) {
sendPushNotification(
Complaint.userId.notificationtoken,
"Your Complaint Forwarded",
"Click here..."
);

if (req.body.level > 0 && Complaint.status === 0) {
setReminder(Date.now(), "Click here...", "Your Complaint Forwarded", [
Complaint.userId,
]);
}
}
try {
Expand Down
1 change: 0 additions & 1 deletion Controller/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const InstructorModel = require("../Model/instructorModel");
const jwt = require("jsonwebtoken");
const { default: mongoose } = require("mongoose");
const athleteModel = require("../Model/athleteModel");
const { sendPushNotification } = require("../PushNotification");
require("dotenv").config();
const { ACCESS_TOKEN_SECRET } = process.env;

Expand Down
6 changes: 2 additions & 4 deletions client-app/screens/Athelte/Complaint.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ const Complaint = ({ navigation }) => {
<TouchableOpacity style={styles.uploadButton} onPress={pickImage}>
<Text style={styles.buttonText}>Upload Photo</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.uploadButton}>
<Text style={styles.buttonText} onPress={handleSubmit}>
Submit
</Text>
<TouchableOpacity style={styles.uploadButton} onPress={handleSubmit}>
<Text style={styles.buttonText}>Submit</Text>
</TouchableOpacity>
</View>
</>
Expand Down
14 changes: 11 additions & 3 deletions client-app/screens/Athelte/ViewComplaint.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ function ViewComplaint({ route, navigation }) {
<Text style={styles.column1}>
{dateBodyTemplate(item.date)}
</Text>
<Text style={styles.column2}>
{RemarkBy(item, data.status, data.level)}
</Text>
<View style={{ flexDirection: "column" }}>
<Text style={styles.column23}>Remarks: {item.remark}</Text>
<Text style={styles.column2}>
{RemarkBy(item, data.status, data.level)}
</Text>
</View>
</View>
))}
</ScrollView>
Expand Down Expand Up @@ -199,6 +202,11 @@ const styles = StyleSheet.create({
width: "25%",
borderRightWidth: 1,
},
column23: {
width: "70%",
marginLeft: "4%",
fontWeight: "bold",
},
column2: {
width: "70%",
marginLeft: "4%",
Expand Down
2 changes: 1 addition & 1 deletion client-app/screens/General/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Main = ({ navigation }) => {
messaging()
.getToken()
.then(async (token) => {
console.log(token);
console.log("token = " + token);
dispatch(NotificationActions.gettoken(token));
// dispatch(setFCM(token));
});
Expand Down
6 changes: 5 additions & 1 deletion client-app/screens/General/RatingReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const RatingReview = ({ complexId }) => {
style={styles.starContainer}
/>
</View>
<Text style={styles.sport}>
{" " + review.createdAt.split("T")[0]}
</Text>
</View>
<Text style={styles.reviewText}>{review.remarks}</Text>
<View style={{ flexDirection: "row" }}>
Expand Down Expand Up @@ -178,12 +181,13 @@ const styles = StyleSheet.create({
helpfulText: {
fontSize: 16,
fontWeight: "bold",
// alignItems: "center",
// color: "#666",
},
helpfulButton1: {
flexDirection: "row",
// alignItems: "center",
marginTop: 10,
// marginTop: 10,
borderWidth: 1,
borderRadius: 5,
padding: 4,
Expand Down
2 changes: 1 addition & 1 deletion client-app/screens/Supervisor/SupervisorMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const SupervisorMain = ({ navigation }) => {
tabBarStyle: { backgroundColor: "#d7a592" }, // Background color of the tab bar
})}
>
<Tab.Screen name="SupervisorQR" component={QR} />
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="SupervisorQR" component={QR} />
<Tab.Screen name="SupervisorProfile" component={SupervisorNavigator} />
</Tab.Navigator>
);
Expand Down
Empty file added eas.json
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f24ff42

Please sign in to comment.