Repository navigation
Expand file tree
/
Copy pathTweetBox.js
More file actions
55 lines (51 loc) · 1.5 KB
/
Copy pathTweetBox.js
File metadata and controls
55 lines (51 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useState } from "react";
import "./TweetBox.css";
import { Avatar, Button } from "@material-ui/core";
import db from "./firebase";
function TweetBox() {
const [tweetMessage, setTweetMessage] = useState("");
const [tweetImage, setTweetImage] = useState("");
const sendTweet = (e) => {
e.preventDefault();
db.collection("posts").add({
displayName: "Emmanuel Youpil",
username: "youpilz",
verified: true,
text: tweetMessage,
image: tweetImage,
avatar:
"https://images-na.ssl-images-amazon.com/images/I/61RM2-y6iCL._AC_UX569_.jpg",
});
setTweetMessage("");
setTweetImage("");
};
return (
<div className="tweetBox">
<form>
<div className="tweetBox__input">
<Avatar src=" https://i.pinimg.com/originals/ca/76/0b/ca760b70976b52578da88e06973af542.jpg" />
<input
onChange={(e) => setTweetMessage(e.target.value)}
value={tweetMessage}
placeholder="What's happening"
/>
</div>
<input
className="tweetBox_imageInput"
onChange={(e) => setTweetImage(e.target.value)}
value={tweetImage}
placeholder="Enter image URL"
type="text"
/>
<Button
onClick={sendTweet}
type="submit"
className="tweetBox__tweetButton"
>
Tweet
</Button>
</form>
</div>
);
}
export default TweetBox;