/
home.tsx
131 lines (114 loc) · 5.39 KB
/
home.tsx
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import {
HiArrowTopRightOnSquare,
HiOutlineQuestionMarkCircle,
HiPencil,
HiUserCircle,
} from "react-icons/hi2";
import OpenSaucedLogo from "../assets/opensauced-logo.svg";
import { useAuth } from "../hooks/useAuth";
import { useOpensaucedUserCheck } from "../hooks/useOpensaucedUserCheck";
import { Profile } from "./profile";
import { goTo } from "react-chrome-extension-router";
import AIPRDescription from "./aiprdescription";
import PostOnHighlight from "./posthighlight";
import Help from "./help";
import { OPEN_SAUCED_INSIGHTS_DOMAIN } from "../constants";
const Home = () => {
const { user } = useAuth();
const { currentTabIsOpensaucedUser, checkedUser } = useOpensaucedUserCheck();
return (
<div className="p-4 bg-slate-800">
<div className="grid grid-cols-1 divide-y divide-white/40 divider-y-center-2 min-w-[320px] text-white">
<header className="flex justify-between">
<img
alt="OpenSauced logo"
className="w-[45%]"
src={OpenSaucedLogo}
/>
{user && (
<button
className="flex gap-1 items-center hover:text-orange text-white no-underline"
onClick={() => {
goTo(Profile, { username: user.user_name });
}}
>
{user.user_name}
<img
alt="User avatar"
className="rounded-full w-6 aspect-square border border-orange"
src={`https://github.com/${user.user_name}.png`}
/>
</button>
)}
</header>
<main className="main-content">
<h3 className="text font-medium text-base leading-10">Tools:</h3>
<div className="tools flex flex-col gap-2">
<a
className="flex items-center bg-slate-700 hover:bg-slate-700/70 text-white hover:text-orange no-underline gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
href={`https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/feed`}
rel="noreferrer"
target="_blank"
>
<HiArrowTopRightOnSquare />
Highlights feed
</a>
<a
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
href={`https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/feed`}
rel="noreferrer"
target="_blank"
>
<HiArrowTopRightOnSquare />
Dashboard
</a>
<button
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
onClick={() => {
goTo(AIPRDescription);
}}
>
<HiPencil />
AI Configuration
</button>
<button
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
onClick={() => {
goTo(PostOnHighlight);
}}
>
<HiPencil />
Post Highlight
</button>
{currentTabIsOpensaucedUser && (
<button
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
onClick={() => {
goTo(Profile, { username: checkedUser });
}}
>
<HiUserCircle />
View
{" "}
{checkedUser}
's profile
</button>
)}
</div>
</main>
<footer className="tools flex gap-2">
<button
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-fit rounded-sm font-medium text-sm"
onClick={() => {
goTo(Help);
}}
>
<HiOutlineQuestionMarkCircle />
Help
</button>
</footer>
</div>
</div>
);
};
export default Home;