-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweetBox.js
More file actions
52 lines (50 loc) · 1.64 KB
/
Copy pathTweetBox.js
File metadata and controls
52 lines (50 loc) · 1.64 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
import React, { useState } from "react";
import "./TweetBox.css";
import {Avatar, Button} from "@mui/material"
import db from "./firebase"
function TweetBox(){
const [tweetMessage, setTweetMessage] = useState("");
const [tweetImage, setTweetImage] = useState("");
const sendTweet = (e) =>{
db.collection("posts").add({
displayName: "Avani",
username: "avbhadw",
verified: true,
text: tweetMessage,
image: tweetImage,
avatar:"https://pbs.twimg.com/profile_images/1359053841161945090/fqjk_8iW_400x400.jpg",
});
setTweetMessage("");
setTweetImage("");
};
return (
<div className="tweetBox">
<form>
<div className="tweetBox__input">
<Avatar src="https://pbs.twimg.com/profile_images/1359053841161945090/fqjk_8iW_400x400.jpg"/>
<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