Skip to content

Commit

Permalink
Merge pull request #16 from FS-38/feature-login
Browse files Browse the repository at this point in the history
update conselor
  • Loading branch information
muhammadsaman77 authored Dec 4, 2023
2 parents 2344a25 + eb15c5f commit 6acab7c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions API_INCARE.http
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ localhost:3000/conselors/getconselor
localhost:3000/conselors/655f061f96f7992755471037

### POST SAVESCHEDULE
localhost:3000/conselors
localhost:3000/conselors/save
{
"status": "OK",
"message": "Successfully Saved the Counselor's Schedule",
Expand All @@ -54,7 +54,7 @@ localhost:3000/conselors/656248ff8001959e7f7f811d
}

### POST CREATEANSWER
localhost:3000/quizzes/quiz
localhost:3000/hasilquizzes/quiz
{
"message": "Your Response is Accepted",
"data": {
Expand Down
21 changes: 11 additions & 10 deletions controllers/conselor.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ const getConselor = async (req, res) => {
};

const registConselor = async (req, res) => {
const header = req.headers.authorization;
let {spesialisasi, deskripsi} = req.body
let {user_id, spesialisasi, deskripsi} = req.body

const token = header.split(" ")[1]
const decoded = jwt.verify(token, "treasure");
const userId = decoded.id;

if(!userId || !spesialisasi || !deskripsi) {
if(!user_id || !spesialisasi || !deskripsi) {
return res.status(400).json({
message: "all fields are required"
})
}

const newConselor = ({userId, spesialisasi, deskripsi});
const newConselor = ({
user_id: user_id,
spesialisasi: spesialisasi,
deskripsi: deskripsi
});
try {
await Conselor.create(newConselor);

Expand Down Expand Up @@ -78,17 +78,18 @@ const getConselorById = async (req, res) => {

const saveSchedule = async (req, res) => {
let data = req.body;
const { id } = req.params;

const { conselor_id, day, time } = data;
const { day, time } = data;

if (!conselor_id || !day || !time) {
if (!day || !time) {
return res.status(400).json({
message: "all fields are required",
});
}

try {
const konselor = await Conselor.findById(conselor_id);
const konselor = await Conselor.findById(id);

if (!konselor) {
return res.status(400).json({
Expand Down
4 changes: 2 additions & 2 deletions models/Conselor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const ConselorSchema = new Schema(
rate: [rateSchema],
schedule: [
{
day: String,
time: String,
day: Array,
time: Array,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions routes/conselor-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const route = express.Router();

route.post("/", saveSchedule)
route.post("/asconselor", registConselor)
route.post("/:id", saveSchedule)
route.get("/getconselor", getConselor)
route.get("/:id", getConselorById)
route.put("/price", updatePrice)
Expand Down

0 comments on commit 6acab7c

Please sign in to comment.