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
+36
View File
@@ -0,0 +1,36 @@
import React, { useState } from "react";
import { addPost } from "../../actions/post";
import { useAppDispatch } from "../../utils/hooks";
const PostForm = () => {
const [text, setText] = useState("");
const dispatch = useAppDispatch();
return (
<div className="post-form">
<div className="bg-primary p">
<h3>Say Something...</h3>
</div>
<form
className="form my-1"
onSubmit={async (e) => {
e.preventDefault();
await dispatch(addPost({ text }));
setText("");
}}
>
<textarea
name="text"
cols={30}
rows={5}
placeholder="Create a 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 PostForm;