frontend converted to ts

This commit is contained in:
QkoSad
2023-07-25 20:40:02 +03:00
parent 1e64a910cc
commit 3bf4e9fc56
60 changed files with 3584 additions and 7 deletions
+39
View File
@@ -0,0 +1,39 @@
import React, { useState } from 'react';
import { addComment } from '../../actions/post';
import { useAppDispatch } from '../../utils/hooks';
const CommentForm = ({ postId }: { postId: string }) => {
const [text, setText] = useState('');
const dispatch = useAppDispatch();
return (
<div className='post-form'>
<div className='bg-primary p'>
<h3>Leave a Comment</h3>
</div>
<form
className='form my-1'
onSubmit={async (e) => {
e.preventDefault();
await dispatch(addComment(postId, { text }));
setText('');
}}
>
<textarea
name='text'
cols={30}
rows={5}
placeholder='Comment the post'
value={text}
onChange={e => setText(e.target.value)}
required
/>
<input type='submit' className='btn btn-dark my-1' value='Submit' />
</form>
</div>
);
};
export default CommentForm