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

Feature/posts #19

Open
wants to merge 42 commits into
base: temp/main1
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6438955
added frontend
ovindumandith Apr 29, 2024
1d74fe4
added ReplyModel for frontend
ovindumandith Apr 29, 2024
911570d
made changes to replymodel
ovindumandith Apr 29, 2024
8921b63
changes to frontend
ovindumandith Apr 29, 2024
20c6f4f
made changes to frontend
ovindumandith Apr 30, 2024
3338728
changes made to frontend of posts
ovindumandith Apr 30, 2024
72d0883
made xhanges to frontend
ovindumandith May 1, 2024
047e32e
frontend changes to user profile
ovindumandith May 1, 2024
dad8ca8
added DTO for comments and posts
ovindumandith May 1, 2024
4dd2d53
frontend changes made
ovindumandith May 1, 2024
0282712
added post shre class
ovindumandith May 2, 2024
86134b9
added post shre DTO class
ovindumandith May 2, 2024
7ed3e28
few refinements
ovindumandith May 2, 2024
fe246e2
frontend changes for posts
ovindumandith May 3, 2024
ae70466
Frontend link changes
ovindumandith May 3, 2024
f01a84f
Update README.md
IT21063596 May 7, 2024
5ff8efc
updated backend for posts,like and comments
ovindumandith May 7, 2024
a9545ec
updated backend for posts,like and comments with redux
ovindumandith May 7, 2024
f79e840
updated backend for posts,like and comments with redux and axios
ovindumandith May 8, 2024
b26615b
updated backend for posts,like and comments with redux and clodinary
ovindumandith May 8, 2024
f047549
Merge branch 'feature/posts' of https://github.com/PAF-IT3030/paf-ass…
ovindumandith May 8, 2024
c3f52aa
updated backend for edit posts
ovindumandith May 8, 2024
bffaed4
updated backend for edit posts and adding comments
ovindumandith May 9, 2024
a66c4e1
updated backend for post to pass the image URL to the DB
ovindumandith May 10, 2024
275baa7
updated frontend to send the image to S3 bucket
ovindumandith May 10, 2024
7aea21c
updated frontend to send the image to S3 bucket through .env
ovindumandith May 10, 2024
1ae3c9b
updated backend to modify the post entity
ovindumandith May 10, 2024
be59344
updated backend to modify the post entity
ovindumandith May 10, 2024
11e183d
updated fronted o handle edit of posts
ovindumandith May 10, 2024
4fceba0
updated fronted o handle edit of posts
ovindumandith May 10, 2024
9a0b21b
updated fronted to address the non sterlized values
ovindumandith May 10, 2024
009e5a8
updated fronted to address the non sterlized values
ovindumandith May 10, 2024
d16a42d
updated frontend for error correction in rendering of posts
ovindumandith May 10, 2024
3d7fbce
made api corrections for delete function
ovindumandith May 11, 2024
018cab3
added toaastify for alert functios
ovindumandith May 11, 2024
6156692
mapped backend and frontened to handle update posts
ovindumandith May 11, 2024
822d645
updated gitignore to avoid pushing secret keys
ovindumandith May 11, 2024
895aaac
updated gitignore to avoid pushing secret keys
ovindumandith May 11, 2024
dfb7b3a
updated gitignore to avoid pushing secret keys
ovindumandith May 11, 2024
a9dcc7f
updated gitignore to avoid pushing secret keys
ovindumandith May 11, 2024
52944f5
mapped backend and frontened to handle update posts
ovindumandith May 11, 2024
dfe561c
made cahanges for user profile to display the posts
ovindumandith May 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
made api corrections for delete function
ovindumandith committed May 11, 2024
commit 3d7fbcea19d90ce55ae545db02f8f4dc637f4cc1
16 changes: 7 additions & 9 deletions frontend/src/Components/HomeSection/EditPost.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import React, { useState } from "react";
import { Button, TextField } from "@mui/material";
import { useDispatch } from "react-redux";
import { updatePost } from "../Store/Action";
import { uploadToS3 } from "../Config/awsS3";
import { v4 as uuidv4 } from "uuid";

const EditPost = ({
initialCaption,
initialImageUrl,
@@ -33,8 +26,13 @@ const EditPost = ({
updatedImageUrl = `https://${S3_BUCKET_NAME}.s3.${S3_BUCKET_REGION}.amazonaws.com/${fileName}`;
}

dispatch(updatePost(postId, { caption, imageUrl: updatedImageUrl }));
onSubmit(); // Close the edit form
// Dispatch the updatePost action with the postId and edited post data
await dispatch(
updatePost(postId, { caption, imageUrl: updatedImageUrl })
);

// Call the onSubmit callback to close the edit form
onSubmit();
} catch (error) {
console.error("Error updating post:", error);
}
15 changes: 10 additions & 5 deletions frontend/src/Components/Store/Action.js
Original file line number Diff line number Diff line change
@@ -51,19 +51,25 @@ export const updatePost = (postId, updatedPostData) => {
return async (dispatch) => {
dispatch({ type: UPDATE_POST_REQUEST });
try {
const response = await axios.put(`/posts/${postId}`, updatedPostData);
dispatch({ type: UPDATE_POST_SUCCESS, payload: response.data }); // Assuming response.data contains the updated post data
// Assuming your backend returns the updated post data in the response
const response = await axios.put(`/api/posts/${postId}`, updatedPostData);
// Dispatch UPDATE_POST_SUCCESS with the postId and updated post data
dispatch({
type: UPDATE_POST_SUCCESS,
payload: { postId, post: response.data },
});
} catch (error) {
dispatch({ type: UPDATE_POST_FAILURE, payload: error.message });
}
};
};


export const deletePost = (postId) => {
return async (dispatch) => {
dispatch({ type: DELETE_POST_REQUEST });
try {
await axios.delete(`/posts/${postId}`);
await axios.delete(`/api/posts/${postId}`);
dispatch({ type: DELETE_POST_SUCCESS, payload: postId });
} catch (error) {
const errorMessage = error.response
@@ -74,15 +80,14 @@ export const deletePost = (postId) => {
};
};

// Add deletePostFailure action creator
export const deletePostFailure = (error) => {
const errorMessage = error.response
? error.response.data.message
: "Unknown error";

return {
type: DELETE_POST_FAILURE,
payload: errorMessage, // Store only the error message
payload: errorMessage,
};
};