Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update and request api for user #20

Open
dhanendra73984 opened this issue Jun 24, 2023 · 4 comments
Open

update and request api for user #20

dhanendra73984 opened this issue Jun 24, 2023 · 4 comments

Comments

@dhanendra73984
Copy link

No description provided.

@lonebots
Copy link
Owner

lonebots commented Jun 24, 2023

@dhanendra73984 , can you provide more details about the requirement?

@dhanendra73984
Copy link
Author

When I send request from client side for donation/request it doesn't reflect on data base
How you manage user_id hear :I got error in this section that user_id can't find like this
const RequestClassHandler = (app, db) => {
app.post("/request", (req, res) => {
const blood_group = req.body.blood_group;
const unit = req.body.unit;

console.log("bloodgroup : " + blood_group);
//query
const sqlSelect = "SELECT * FROM blood_stocks WHERE blood_group=?";
const sqlInsert =
  "INSERT INTO  user_request(blood_group,unit) VALUES (?,?)";
//
db.query(sqlSelect, [blood_group], (err, result) => {
  if (err) {
    console.log("**ERROR**" + err);
  } else {
    result = JSON.parse(JSON.stringify(result));
    console.log(result[0].unit);
    if (unit <= result[0].unit) {
      //
      db.query(sqlInsert, [blood_group, unit], (err, result) => {
        if (err) {
          console.log("**ERROR ACCEPTING REQUEST!" + err);
        } else {
          res.send({
            message: "REQUEST ACCEPETED COLLECT IT FROM THE BLOOD BANK",
          });
        }
      });
    } else {
      res.send({ message: "INSUFFICIENT STOCKS!" });
    }
  }
});

});
};

export default RequestClassHandler;

@lonebots
Copy link
Owner

currently It is not handled, but you can easily take get it in the response from the login, The code sends valid users details to front end ( even though it is not the best practice to do that ). From there you can use local storage to temporarily store the user_id and other details, If I get time I will consider restructuring the code and implementing some important missing features
in near future 🤞🏻

@dhanendra73984
Copy link
Author

dhanendra73984 commented Jun 24, 2023 via email

@lonebots lonebots changed the title 1.bro can you please provide update and request api for user update and request api for user Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants