Skip to content

Commit

Permalink
fix: bug with delete end point
Browse files Browse the repository at this point in the history
  • Loading branch information
thenicekat committed Mar 28, 2024
1 parent 30ee0bc commit bdd1002
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion backend/src/routes/posts.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@ postsRouter.post("/delete", async (req, res) => {
const id = req.body.requestId as string;
const service = req.body.service as string;
const status = req.body.status as string;
const source = req.body.source as string;
const destination = req.body.destination as string;
const costInPoints = parseInt(req.body.costInPoints) as number;

const authorEmail = req.session.email as string;

const delPost = await deletePost({
id,
authorEmail,
status,
service
service,
source,
destination,
costInPoints
});

if (delPost.error) {
Expand Down
8 changes: 6 additions & 2 deletions frontend/app/post/details/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ const PostDetailsPage = ({ params }: Props) => {
const res = await axios.post(siteConfig.server_url + "/post/delete", {
requestId: params.slug,
service: data.service,
status: data.service,
source: data.source,
destination: data.destination,
costInPoints: data.costInPoints
}, {
withCredentials: true,
headers: {
Expand All @@ -126,8 +130,8 @@ const PostDetailsPage = ({ params }: Props) => {
setError("")
setMessage("Post deleted successfully.")
setTimeout(function () {
window.location.href = "/";
}, 1000);
window.location.href = "/";
}, 1000);
} else if (res.status == HttpCodes.UNAUTHORIZED) {
window.location.href = ('/')
}
Expand Down

0 comments on commit bdd1002

Please sign in to comment.