-
Notifications
You must be signed in to change notification settings - Fork 0
/
Header.js
94 lines (85 loc) · 2.66 KB
/
Header.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { useContext } from "react";
import { FeedDataContext } from "./AppContext";
import Logo from "./Logo";
import axios from "axios";
import { db } from "../firebase/firebaseClient";
import { fetchTopSearches } from "../data/TeneoDataRepo";
const Header = () => {
const { setFeedData } = useContext(FeedDataContext);
const topSearches = fetchTopSearches();
const searchRSS3 = async (query) => {
if (query.trim() !== "") {
setFeedData(null);
axios
.get(
`https://pregod.rss3.dev/v0.4.0/account:${query}@ethereum/notes?limit=1000&exclude_tags=POAP&latest=false`
)
.then(async (res) => {
setFeedData(res.data.list);
if (res.data.list.length > 0) {
let searchInstance = topSearches.find((x) => x.query === query);
// save to top searches
if (!searchInstance) {
await db.collection("top-searches").doc(query).set({
query: query,
count: 1,
});
} else {
await db
.collection("top-searches")
.doc(query)
.update({
count: searchInstance.count + 1,
});
}
}
})
.catch(() => {
setFeedData([]);
});
}
};
return (
<nav
className="navbar navbar-expand-lg navbar-light fixed-top shadow-sm"
id="mainNav"
>
<div className="container px-5">
<Logo />
<input
className="search-bar"
type="text"
placeholder="Search Address / ENS Address"
onKeyUp={(e) => {
if (e.key === "Enter") {
searchRSS3(e.target.value);
}
}}
></input>
<div className="collapse navbar-collapse" id="navbarResponsive">
<ul className="navbar-nav ms-auto me-4 my-3 my-lg-0">
<li className="nav-item">
<a className="nav-link me-lg-3" href="#top-stories">
Top Feeds
</a>
</li>
<li className="nav-item">
<a className="nav-link me-lg-3" href="#feed">
Main Feed
</a>
</li>
</ul>
<a href="https://rss3.io/about" target="_blank">
<button className="btn btn-primary rounded-pill px-3 mb-2 mb-lg-0">
<span className="d-flex align-items-center">
<i className="bi-hexagon me-2" />
<span className="small">Powered by RSS3</span>
</span>
</button>
</a>
</div>
</div>
</nav>
);
};
export default Header;