Skip to content

Commit

Permalink
Fix comment form and trim input values
Browse files Browse the repository at this point in the history
  • Loading branch information
syavaYki committed Sep 27, 2024
1 parent b34fe4c commit 6c8956c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/NewCommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export const NewCommentForm: React.FC<Props> = ({
const anyErrorCheck = () => {
const errors = [];

setErrorName(!name);
errors.push(!name);
setErrorName(!name.trim());
errors.push(!name.trim());

setErrorEmail(!email);
errors.push(!email);
setErrorEmail(!email.trim());
errors.push(!email.trim());

setErrorBody(!body);
errors.push(!body);
setErrorBody(!body.trim());
errors.push(!body.trim());

return errors.some(e => e === true);
};
Expand All @@ -49,9 +49,9 @@ export const NewCommentForm: React.FC<Props> = ({
commentClient
.add({
postId: post.id,
name: name,
email: email,
body: body,
name: name.trim(),
email: email.trim(),
body: body.trim(),
})
.then(() => {
setBody('');
Expand Down Expand Up @@ -116,7 +116,7 @@ export const NewCommentForm: React.FC<Props> = ({

<div className="control has-icons-left has-icons-right">
<input
type="text"
type="email"
name="email"
id="comment-author-email"
placeholder="email@test.com"
Expand Down

0 comments on commit 6c8956c

Please sign in to comment.