Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:ARKultur/naboo into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximePayant committed Jan 4, 2024
2 parents 7413b70 + 6b44d5c commit d3f7f11
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
50 changes: 41 additions & 9 deletions src/routes/customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ customer_router.post("/register", async (req, res) => {
password: req.body.password,
email: req.body.email
});
*/
*/
const customer = await prisma.customers.create({
data: {
username: req.body.username,
Expand Down Expand Up @@ -352,6 +352,38 @@ customer_router.patch("/", authenticateTokenCustomer, async (req, res) => {
}
});

customer_router.delete("/", authenticateTokenCustomer, async (req, res) => {
try {
/*
const customer = await User.findOne({
where:{
email: req.email
}
})
*/
const customer = await prisma.customers.findFirst({
where: {
email: req.email
}
})

if (customer) {
//await customer.destroy()
await prisma.customers.delete({
where: {
id: customer.id
}
});
res.send("succesfully deleted")
} else {
res.status(404).send("customer not found");
}
} catch (error) {
console.error(error)
res.sendStatus(500)
}
})

customer_router.get("/all", authenticateToken, async (req, res) => {
//const customers = await Customer.findAll();
const customers = await prisma.customers.findMany();
Expand All @@ -362,12 +394,12 @@ customer_router.get("/", authenticateTokenCustomer, async (req, res) => {
try {
const email = req.email;
/*
const customer = await Customer.findOne({
where: {
email: email
}
})
*/
const customer = await Customer.findOne({
where: {
email: email
}
})
*/
const customer = await prisma.customers.findUnique({
where: {
email: email,
Expand All @@ -392,7 +424,7 @@ customer_router.post("/", authenticateTokenAdm, async (req, res) => {
password: req.body.password,
email: req.body.email
});
*/
*/
const customer = await prisma.customers.create({
data: {
username: req.body.username,
Expand All @@ -407,6 +439,6 @@ customer_router.post("/", authenticateTokenAdm, async (req, res) => {
}
});

customer_router.post("/:id", authenticateToken, async (req, res) => {});
customer_router.post("/:id", authenticateToken, async (req, res) => { });

export default customer_router;
2 changes: 1 addition & 1 deletion src/routes/organisations.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ orga_router.get('/:id', authenticateTokenAdm, async (req, res) => {
const id = req.params.id;
const users = await prisma.user.findMany({
where: {
OrganisationId: id
OrganisationId: parseInt(id)
}
})
return res.send(users)
Expand Down

0 comments on commit d3f7f11

Please sign in to comment.