-
Notifications
You must be signed in to change notification settings - Fork 0
/
TweetBox copy.js
59 lines (52 loc) · 1.34 KB
/
TweetBox copy.js
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
56
57
58
59
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: "Owen Lester",
username: "owlester12",
verified: true,
text: tweetMessage,
image: tweetImage,
avatar:
"",
});
setTweetMessage("");
setTweetImage("");
};
return (
<div className="tweetBox">
<form>
<div className="tweetBox__input">
<Avatar src="" />
<input
onChange={(e) => setTweetMessage(e.target.value)}
value={tweetMessage}
placeholder="What's happening?"
type="text"
/>
</div>
<input
value={tweetImage}
onChange={(e) => setTweetImage(e.target.value)}
className="tweetBox__imageInput"
placeholder="Optional: Enter image URL"
type="text"
/>
<Button
onClick={sendTweet}
type="submit"
className="tweetBox__tweetButton"
>
Tweet
</Button>
</form>
</div>
);
}
export default TweetBox;