Skip to content

Commit

Permalink
resolve eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
YehiaFarghaly committed Oct 6, 2023
1 parent 1184073 commit db88b3b
Show file tree
Hide file tree
Showing 12 changed files with 2,335 additions and 198 deletions.
2,157 changes: 2,144 additions & 13 deletions clinic/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions clinic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
"version": "1.0.0",
"description": "",
"main": "./src/app.js",
"type" : "module",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint . --fix"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.50.0"
"eslint": "^8.50.0",
"eslint-plugin-react": "^7.33.2"
},
"dependencies": {
"axios": "^1.5.1",
Expand Down
69 changes: 35 additions & 34 deletions clinic/src/api/clinic.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
import ClinicService from "../service/clinic-service.js";
import ClinicService from '../service/clinic-service.js';
import { EMPTY_SIZE, ERROR_STATUS_CODE, NOT_FOUND_STATUS_CODE, OK_STATUS_CODE } from '../utils/Constants.js';

export const clinic = (app) =>{
const service = new ClinicService();
export const clinic = (app) => {
const service = new ClinicService();

app.get('/all-packages', async (req,res)=>{
const allPackages = await service.getAllPackages();
if(allPackages.length > 0){
res.status(200).json({allPackages});
}else{
res.status(404).json({message:"patients not found"});
}
});
app.get('/all-packages', async (req,res) => {
const allPackages = await service.getAllPackages();
if(allPackages.length > EMPTY_SIZE){
res.status(OK_STATUS_CODE).json({ allPackages });
}else{
res.status(NOT_FOUND_STATUS_CODE).json({ message:'patients not found' });
}
});

app.post('/new-package', async (req, res)=>{
app.post('/new-package', async (req, res) => {

const {name, price, discountOfDoctor, discountOfMedicin, discountOfFamily} = req.body;
console.log({name});
const { name, price, discountOfDoctor, discountOfMedicin, discountOfFamily } = req.body;
console.log({ name });

const data = await service.createNewPackage(name, price, discountOfDoctor, discountOfMedicin, discountOfFamily);
if(data){
res.status(200).json({data});
}else{
res.status(500);
}
});
const data = await service.createNewPackage(name, price, discountOfDoctor, discountOfMedicin, discountOfFamily);
if(data){
res.status(OK_STATUS_CODE).json({ data });
}else{
res.status(ERROR_STATUS_CODE);
}
});

app.patch('/edit-package', async (req,res)=>{
// app.patch('/edit-package', async (req,res) => {

});
// });

app.delete('/remove-package/:id', async (req,res)=>{
const id = req.params.id;
try{
console.log(id);
const deletedPackage = await service.deletePackage(id);
res.status(200).json({deletedPackage});
}catch(err){
res.status(500).json({err : err.message});
}
});
app.delete('/remove-package/:id', async (req,res) => {
const id = req.params.id;
try{
console.log(id);
const deletedPackage = await service.deletePackage(id);
res.status(OK_STATUS_CODE).json({ deletedPackage });
}catch(err){
res.status(ERROR_STATUS_CODE).json({ err : err.message });
}
});

}
};
24 changes: 12 additions & 12 deletions clinic/src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import express from "express";
import mongoose from "mongoose";
import express from 'express';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import { clinic } from "./api/clinic.js";
import { clinic } from './api/clinic.js';
import { PORT } from './utils/Constants.js';



Expand All @@ -11,13 +12,12 @@ const app = express();
const mongoURL = process.env.MONGO_URI;

const connect = async () => {
try {
await mongoose.connect(mongoURL);
console.log("Database connected");
} catch (err) {
console.error("Error connecting to the database:", err);
process.exit(1);
}
try {
await mongoose.connect(mongoURL);
console.log('Database connected');
} catch (err) {
console.error('Error connecting to the database:', err);
}
};

await connect();
Expand All @@ -26,8 +26,8 @@ app.use(express.json());

clinic(app);

const port = process.env.PORT || 8001;
const port = process.env.PORT || PORT;

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
console.log(`Server is running on port ${port}`);
});
20 changes: 10 additions & 10 deletions clinic/src/database/models/Admin.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import mongoose from "mongoose";
import UserSchema from "./UserSchema.js";
import mongoose from 'mongoose';
import UserSchema from './UserSchema.js';

const Admin = mongoose.Schema({
userData: {
type: UserSchema,
required: true
},
mainAdmin: {
type: Boolean
},
//....
userData: {
type: UserSchema,
required: true
},
mainAdmin: {
type: Boolean
},
//....
});

const AdminModel = mongoose.model('Admin', Admin);
Expand Down
38 changes: 19 additions & 19 deletions clinic/src/database/models/Appointment.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import mongoose from "mongoose";
import mongoose from 'mongoose';


const Appointment = mongoose.Schema({
patientId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Patient',
required: true
},
doctorId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Doctor',
required: true
},
date: {
type: Date,
required: true
},
status: {
type: String,
},
//.....
patientId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Patient',
required: true
},
doctorId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Doctor',
required: true
},
date: {
type: Date,
required: true
},
status: {
type: String,
},
//.....
});

const AppointmentModel = mongoose.model('Appointment', Appointment);
Expand Down
44 changes: 22 additions & 22 deletions clinic/src/database/models/Doctor.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import mongoose from "mongoose";
import UserSchema from "./UserSchema.js";
import mongoose from 'mongoose';
import UserSchema from './UserSchema.js';

const Doctor = mongoose.Schema({
userData: {
type: UserSchema,
required: true
},
speciality: {
type: String,
required: true
},
hourlyRate: {
type: Number,
required: true
},
affiliation: {
type: String,
required: true
},
educationalBackground: {
type: String,
required: true
}
userData: {
type: UserSchema,
required: true
},
speciality: {
type: String,
required: true
},
hourlyRate: {
type: Number,
required: true
},
affiliation: {
type: String,
required: true
},
educationalBackground: {
type: String,
required: true
}
});

const DoctorModel = mongoose.model('Doctor', Doctor);
Expand Down
42 changes: 21 additions & 21 deletions clinic/src/database/models/HealthPackage.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import mongoose from "mongoose";
import mongoose from 'mongoose';


const HealthPackage = mongoose.Schema({
price: {
type: Number,
required: true
},
name: {
type: String,
required: true
},
discountOfDoctor: {
type : Number,
required: true
},
discountOfMedicin: {
type : Number,
required: true
},
discountOfFamily: {
type : Number,
required: true
}
price: {
type: Number,
required: true
},
name: {
type: String,
required: true
},
discountOfDoctor: {
type : Number,
required: true
},
discountOfMedicin: {
type : Number,
required: true
},
discountOfFamily: {
type : Number,
required: true
}
});

const HealthPackageModel = mongoose.model('HealthPackage', HealthPackage);
Expand Down
46 changes: 23 additions & 23 deletions clinic/src/database/models/UserSchema.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import mongoose from "mongoose";
import mongoose from 'mongoose';

const UserSchema = mongoose.Schema({
name: {
type: String,
required: true
},
name: {
type: String,
required: true
},

userName: {
type: String,
required: true,
unique: true
},
userName: {
type: String,
required: true,
unique: true
},

email: {
type: String,
required: true,
unique: true
},
email: {
type: String,
required: true,
unique: true
},

password: {
type: String,
required: true
},
password: {
type: String,
required: true
},

dateOfBirth: {
type: Date,
required: true
}
dateOfBirth: {
type: Date,
required: true
}
});

export default UserSchema;
Loading

0 comments on commit db88b3b

Please sign in to comment.