Skip to content

Commit

Permalink
Fixed removing of posts by user
Browse files Browse the repository at this point in the history
  • Loading branch information
pateldivyesh1323 committed Dec 4, 2023
1 parent afed5e4 commit 557d64a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/components/OrgPostCard/OrgPostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,26 @@ export default function OrgPostCard(
e.preventDefault();

try {
let imageUrl = null;
let videoUrl = null;

if (e.target?.postphoto && e.target?.postphoto.files.length > 0) {
imageUrl = postformState.postphoto;
}

if (e.target?.postvideo && e.target?.postvideo.files.length > 0) {
videoUrl = postformState.postvideo;
}
const imageInput = document.getElementById(
'postImageUrl'
) as HTMLInputElement;
const videoInput = document.getElementById(
'postVideoUrl'
) as HTMLInputElement;

const { data } = await updatePostMutation({
variables: {
id: props.id,
title: postformState.posttitle,
text: postformState.postinfo,
...(imageUrl !== null && { imageUrl }),
...(videoUrl !== null && { videoUrl }),
...((postformState.postphoto !== null ||
(imageInput && imageInput.value === '')) && {
imageUrl: postformState.postphoto,
}),
...((postformState.postvideo !== null ||
(videoInput && videoInput.value === '')) && {
videoUrl: postformState.postvideo,
}),
},
});

Expand Down

0 comments on commit 557d64a

Please sign in to comment.