diff --git a/client/components/badges/visibility-control/index.tsx b/client/components/badges/visibility-control/index.tsx index ec6c9f67..2fbcd9dc 100644 --- a/client/components/badges/visibility-control/index.tsx +++ b/client/components/badges/visibility-control/index.tsx @@ -38,7 +38,7 @@ const VisibilityControl = ({ postId, visibility, setVisibility }: Props) => { setPasswordModalVisible(false) } }, - [setToast] + [postId, setToast, setVisibility] ) const onSubmit = useCallback( @@ -63,7 +63,7 @@ const VisibilityControl = ({ postId, visibility, setVisibility }: Props) => { } const submitPassword = useCallback( - (password) => onSubmit("protected", password), + (password: string) => onSubmit("protected", password), [onSubmit] ) diff --git a/client/components/new-post/index.tsx b/client/components/new-post/index.tsx index 244d16ad..8171d17a 100644 --- a/client/components/new-post/index.tsx +++ b/client/components/new-post/index.tsx @@ -110,7 +110,7 @@ const Post = ({ setSubmitting(false) } }, - [docs, router, setToast, title] + [description, docs, router, setToast, title] ) const [isSubmitting, setSubmitting] = useState(false) @@ -192,7 +192,7 @@ const Post = ({ ) const onChangeDescription = useCallback( - (e: ChangeEvent) => { + (e: ChangeEvent) => { setDescription(e.target.value) }, [setDescription] diff --git a/client/components/post-page/index.tsx b/client/components/post-page/index.tsx index e9ec19ef..7496b09f 100644 --- a/client/components/post-page/index.tsx +++ b/client/components/post-page/index.tsx @@ -166,9 +166,15 @@ const PostPage = ({ post: initialPost, isProtected }: Props) => { content={content} /> ))} - {isOwner && - - } + {isOwner && ( + + + + )} diff --git a/server/src/routes/posts.ts b/server/src/routes/posts.ts index 6de9b281..c83e7f36 100644 --- a/server/src/routes/posts.ts +++ b/server/src/routes/posts.ts @@ -403,7 +403,6 @@ posts.delete("/:id", jwt, async (req: UserJwtRequest, res, next) => { } }) - posts.put( "/:id", jwt, @@ -415,7 +414,7 @@ posts.put( visibility: Joi.string() .custom(postVisibilitySchema, "valid visibility") .required(), - password: Joi.string().optional(), + password: Joi.string().optional() } }), async (req: UserJwtRequest, res, next) => { @@ -427,7 +426,7 @@ posts.put( ) } - const { visibility, password } = req.body; + const { visibility, password } = req.body let hashedPassword: string = "" if (visibility === "protected") { @@ -437,14 +436,14 @@ posts.put( .digest("hex") } - const { id } = req.params; + const { id } = req.params const post = await Post.findByPk(id, { include: [ { model: User, as: "users", attributes: ["id"] - }, + } ] }) @@ -453,7 +452,9 @@ posts.put( } if (!isUserAuthor(post)) { - return res.status(403).json({ error: "This post does not belong to you" }) + return res + .status(403) + .json({ error: "This post does not belong to you" }) } await Post.update(