Skip to content

Commit

Permalink
fix: post routes
Browse files Browse the repository at this point in the history
  • Loading branch information
thenicekat committed Mar 26, 2024
1 parent 6423a45 commit 5cbd256
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions backend/src/routes/posts.route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router } from "express";
import { HttpCodes } from "../types/HttpCodes";
import { CustomResponse } from "../types/CustomResponse";
import { createPost, getAllPosts, getMyPosts, getPostDetails,editPost, deletePost } from "../service/posts.service";
import { createPost, getAllPosts, getMyPosts, getPostDetails, editPost, deletePost } from "../service/posts.service";
//import { FRONTEND_URL } from "../constants";
export const postsRouter = Router();

Expand Down Expand Up @@ -92,17 +92,17 @@ postsRouter.post("/create", async (req, res) => {
})

postsRouter.post("/update", async (req, res) => {
const requestId = req.body.requestId as string;
const id = req.body.requestId as string;
const source = req.body.source as string;
const destination = req.body.destination as string;
const service = req.body.service as string;
const costInPoints = parseInt(req.body.costInPoints) as number;
const status= req.body.status as string;
const status = req.body.status as string;

const authorEmail = req.session.email as string;

const edPost = await editPost({
requestId,
id,
authorEmail,
source,
destination,
Expand All @@ -129,13 +129,14 @@ postsRouter.post("/update", async (req, res) => {
})

postsRouter.post("/delete", async (req, res) => {
const requestId = req.body.requestId as string;
const id = req.body.requestId as string;
const service = req.body.service as string;
const status= req.body.status as string;
const status = req.body.status as string;

const authorEmail = req.session.email as string;

const delPost = await deletePost({
requestId,
id,
authorEmail,
status,
service
Expand All @@ -154,7 +155,6 @@ postsRouter.post("/delete", async (req, res) => {
message: "Post Deleted Successfully",
data: delPost.data
}
//res.redirect(FRONTEND_URL+'/user/dashboard');
return res.status(HttpCodes.OK).json(response);
})

Expand Down
4 changes: 2 additions & 2 deletions backend/src/service/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export const editPost = async (post: {
}

export const deletePost = async (post: {
requestId: string,
id: string,
authorEmail: string,
status: string,
service: string
Expand Down Expand Up @@ -242,7 +242,7 @@ export const deletePost = async (post: {
}

let deletePost = await prisma.post.delete({
where: { id: post.requestId },
where: { id: post.id },
})

return {
Expand Down

0 comments on commit 5cbd256

Please sign in to comment.