Skip to content

Commit

Permalink
Merge pull request #42 from ShubhaMahobia/40-refactoring-doctor-model…
Browse files Browse the repository at this point in the history
…-and-appointment-model

Refactor authenticationController.js and UserDoctorModel.js to update…
  • Loading branch information
ShubhaMahobia authored Apr 14, 2024
2 parents f95ab3a + d208c17 commit 6501af8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions controller/authenticationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ exports.signUpDoctor = async (req, res) => {
address: req.body.address,
degree: req.body.degree,
breifDescription: req.body.breifDescription,
daysAvailable: req.body.daysAvailable,
latitude: req.body.latitude,
longitude: req.body.longitude,
});
Expand All @@ -119,21 +118,22 @@ exports.signUpDoctor = async (req, res) => {
});
}
await doctor.save();
const timeSlots = [];

const timeSlots = [];
const startHour = new Date(`2024-01-01T${req.body.startTimeHour}:00Z`);
const endHour = new Date(`2024-01-01T${req.body.endTimeHour}:00Z`);
let currentTime = new Date(startHour);
console.log(currentTime);
while (currentTime < endHour) {
const startTime = new Date(currentTime);
const endTime = new Date(currentTime.getTime() + 30 * 60000); // 30 minutes later
timeSlots.push({ startTime, endTime });
currentTime = new Date(currentTime.getTime() + 30 * 60000);
}
console.log(timeSlots);
const schedule = new Schedule({
docId: req.body.firebaseUserId,
timeSlots: timeSlots,
daysAvailable: req.body.daysAvailable,
});
await schedule.save(); //Saving command for saving user to database
return res.status(200).json({
Expand Down
7 changes: 1 addition & 6 deletions model/UserDoctorModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const DoctorUserSchema = new mongoose.Schema({

profilePicture: {
type: String,
required: true,
required: false,
},

address: {
Expand All @@ -67,11 +67,6 @@ const DoctorUserSchema = new mongoose.Schema({
type: String,
required: true,
},

daysAvailable: {
type: [Number],
required: true,
},
//Adding these field to save exact address of the user by their location and we can update if we want in future.
longitude: {
type: String,
Expand Down
11 changes: 11 additions & 0 deletions model/timeslotModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ const scheduleSchema = new mongoose.Schema({
unique: true,
},
timeSlots: [timeSlotSchema],
daysAvailable: {
type: {
Monday: Boolean,
Tuesday: Boolean,
Wednesday: Boolean,
Thursday: Boolean,
Friday: Boolean,
Saturday: Boolean,
},
required: true,
},
});

const Schedule = mongoose.model("Schedule", scheduleSchema);
Expand Down

0 comments on commit 6501af8

Please sign in to comment.