-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathApp.tsx
357 lines (304 loc) · 16.7 KB
/
App.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
import { useEffect, useState } from "react";
import SteamDetails from "./SteamDetails";
import { getLevelByGPQ } from "./utils/getLevelByGPQ";
import axios from "axios";
interface Article {
title: string;
link: string;
pubDate: Date;
description: string;
}
interface UserGitHub {
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
name: string;
company: string;
blog: string;
location: string;
email: string | null;
hireable: boolean;
bio: string;
twitter_username: string;
public_repos: number;
public_gists: number;
followers: number;
following: number;
created_at: string;
updated_at: string;
}
interface Repo {
stargazers_count: number;
language: string;
}
interface LanguagePercentage {
name: string;
percentage: string;
}
interface UserRepos {
repos: Repo[];
totalStars: number;
totalCommits: number;
language: LanguagePercentage;
}
const userGitHub = "Yagasaki7K";
const fetchData = async (
setUserInfo: (userInfo: UserGitHub) => void,
setUserRepos: (userRepos: UserRepos) => void,
github_api_key: string,
setLoading: (loading: boolean) => void
) => {
setLoading(true);
try {
// Fetch user information
const userResponse = await axios.get<UserGitHub>('https://api.github.com/users/' + userGitHub, {
headers: { Authorization: `Bearer ${github_api_key}` }
});
setUserInfo(userResponse.data);
console.log('User Info', userResponse.data);
// Fetch public repositories of the user
const reposResponse = await axios.get<Repo[]>('https://api.github.com/users/' + userGitHub + '/repos?sort=updated', {
headers: { Authorization: `Bearer ${github_api_key}` },
params: { type: 'public' }
});
const repos = reposResponse.data;
// Fetch commits of all repositories of the user
const commitsResponse = await axios.get(`https://api.github.com/search/commits?q=${encodeURIComponent(`author:${userGitHub} is:merge`)}`, {
headers: { Authorization: `token ${github_api_key}`, Accept: 'application/vnd.github.cloak-preview' }
});
const totalCommits = commitsResponse.data.total_count;
// Calculate total stars received
const totalStars = repos.reduce((acc, repo) => acc + repo.stargazers_count, 0);
// Calculate percentage of the most used language
const languages: { [key: string]: number } = repos.reduce((acc, repo) => {
if (repo.language) {
acc[repo.language] = acc[repo.language] ? acc[repo.language] + 1 : 1;
}
return acc;
}, {} as { [key: string]: number });
const totalRepos = repos.length;
const languagePercentageArray: LanguagePercentage[] = [];
for (const language in languages) {
const percentage = ((languages[language] / totalRepos) * 100).toFixed(2);
languagePercentageArray.push({ name: language, percentage: `${percentage}%` });
}
setUserRepos({
repos,
totalStars,
totalCommits,
language: languagePercentageArray[0]
});
} catch (error) {
console.error('Error fetching data:', error);
}
setLoading(false);
};
function App() {
const [userInfo, setUserInfo] = useState<UserGitHub | undefined>();
const [userRepos, setUserRepos] = useState<UserRepos | undefined>();
const [loading, setLoading] = useState(false);
useEffect(() => {
const githubApiKey = import.meta.env.VITE_GITHUB_API_KEY || '';
fetchData(setUserInfo, setUserRepos, githubApiKey, setLoading);
}, []);
// ARTIGO DE BLOG - CONSUMINNDO UM XML - COMENTE SE NÃO QUISER USAR NO SEU PROJETO
const [articles, setArticles] = useState<Article[]>([]);
// ARTIGO DE BLOG - CONSUMINNDO UM XML - COMENTE SE NÃO QUISER USAR NO SEU PROJETO
useEffect(() => {
const fetchArticles = async () => {
try {
const response = await fetch('https://raw.githubusercontent.com/Yagasaki7K/website-yagasaki/refs/heads/main/article.xml'); // Substitua pela URL real
const xmlData = await response.text();
// Usando DOMParser para analisar o XML no navegador
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlData, 'application/xml');
// Acessando os itens do feed RSS
const items = xmlDoc.getElementsByTagName('item');
const fetchedArticles: Article[] = [];
for (let i = 0; i < items.length; i++) {
const item = items[i];
const title = item.getElementsByTagName('title')[0].textContent || '';
const link = item.getElementsByTagName('link')[0].textContent || '';
const pubDate = new Date(item.getElementsByTagName('pubDate')[0].textContent || '');
const description = item.getElementsByTagName('description')[0].textContent || '';
fetchedArticles.push({ title, link, pubDate, description });
}
// Ordena os artigos por data (mais recente primeiro)
fetchedArticles.sort((a, b) => b.pubDate.getTime() - a.pubDate.getTime());
// Seleciona os quatro artigos mais recentes
setArticles(fetchedArticles.slice(0, 4));
} catch (error) {
console.error('Erro ao processar o arquivo XML:', error);
}
};
fetchArticles();
}, []);
const subnick = "Anderson \"Yagasaki\" Marlon";
// BlueLight
// const avatarBorder = "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/570/c6a479fae8979bc9c1a02378e488e3ce06b52cb1.png";
// Cuttie
// const avatarBorder = "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/2855140/4324f3a8e05e1c110fad71443d61c7ba82c4e474.png";
// Halloween
// const avatarBorder = "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/2603600/ba1ce3d28ef75329afe4e784b1b6f9fe863cfae4.png";
// Fire
// const avatarBorder = "https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/items/322330/beaee5e90d93bfafa5f5f55acb23abfd28ad180c.png";
// Summer
const avatarBorder = "https://cdn.fastly.steamstatic.com/steamcommunity/public/images/items/2861720/410eecdbc6f2505e98863ab4200ca454032b40a2.png"
const flag = "br";
// Year of your birthday
const birthday = 1997;
// since your are developer
const sinceExperience = 2020;
const infoSubTitle = "Transforming code into solutions";
const badgeTitle = "Mid Software Developer";
const badgeEXP = "12,649";
const badgeIcon = "https://community.cloudflare.steamstatic.com/public/images/badges/30_steamawardnominations/level04_80.png";
// Default
// const badgeIcon = "/badge_icon.png";
const twitterLink = "https://twitter.com/" + userGitHub;
const awardIconLink = "https://yagasaki.dev/about#awards";
// Default
// const awardIconLink = "/award_icon.svg";
const perfilIconLink = "https://yagasaki.dev/about";
// const urlAvatar = "https://github.com/" + userGitHub + ".png";
const fixedAvatar = "https://cdn.fastly.steamstatic.com/steamcommunity/public/images/items/2861720/0f9367f89fad6b92c96b686442d61bcb86d627f5.gif";
const nickname = userInfo?.name;
const location = userInfo?.location;
const infoTitle = userInfo?.bio;
const githubLink = "https://github.com/" + userGitHub;
console.log(userRepos, userInfo);
return (
loading ? (<p>Loading ...</p>) : (
<SteamDetails>
<div className="background"></div>
<div className="content">
<div className="header">
<div className="avatar">
<img src={fixedAvatar} alt="" />
<img className="border" src={avatarBorder} alt="" />
</div>
<div className="nickname">
<h2>{nickname}</h2>
<div className="subnick">
<p>{subnick}</p>
<p className="city"><img src={"https://community.cloudflare.steamstatic.com/public/images/countryflags/" + flag + ".gif"} /> {location}</p>
</div>
<div className="info">
<p>{infoTitle}</p>
<i>{infoSubTitle}</i>
<a href={githubLink}>View more info</a>
</div>
</div>
<div className="level">
<h2>Nível <span>{new Date().getFullYear() - birthday}</span></h2>
<div className="badge">
<div className="leftContent">
<img src={badgeIcon} alt="BadgeIcon" />
</div>
<div className="rightContent">
<h4>{badgeTitle}</h4>
<p>{badgeEXP} XP</p>
</div>
</div>
<div className="buttons">
<button onClick={() => window.location.href = twitterLink}>Send Friend Request</button>
<a href={awardIconLink} target="_blank" rel="noreferrer">
<img className="award" src="award_icon.svg" alt="" />
</a>
<a href={perfilIconLink} target="_blank" rel="noreferrer">
<img className="avatar" src="equipped_items_icon.svg" alt="" />
</a>
<button onClick={() => window.location.href = githubLink}>...</button>
</div>
</div>
</div>
</div>
<div className="body">
<div className="subgroups">
<div className="group">
<h3>About</h3>
<p><img src="https://github.com/tairosonloa/tairosonloa/blob/main/assets/wave.gif?raw=true" width="15px" /> Hi, I'm <b>Anderson Marlon</b>, a Software Developer with experience building systems and applications scalable in the industries of Chatbot, Artificial Intelligence, Financial Technology (Fintech), Affiliates, Brewery, Health, Journalism, Sustainability, Sales / Entrepreneurship, Podcasts, Advocate, Solutions Tech, Referral Marketing, Government Solutions Assistance and Electronic Sport Scenario & Black Belt Taekwondo @ Campinas Fighters.</p>
<h3>Technologies</h3>
<div className="groupDetails">
<div className="badges">
<img src="/js.png" alt="BadgeIcon" title="Javascript Developer" />
<img src="/ts.png" alt="BadgeIcon" title="Typescript Developer" />
<img src="/nodejs.png" alt="BadgeIcon" title="NodeJS Developer" />
<img src="/bun.png" alt="BadgeIcon" title="Bun Developer" />
<img src="/nestjs.png" alt="BadgeIcon" title="NestJS Experience" />
<img src="/firebase.png" alt="BadgeIcon" title="Firebase Experience" />
<button title="See more on Github" onClick={() => window.location.href = githubLink}>+15</button>
</div>
</div>
{/* Você não precisa copiar esse método, já que estou apenas consumindo um arquivo XML para ler os artigos do meu site */}
{/* Mas caso queira, remova o comentário abaixo dele e utilize de forma estática*/}
{/* CONSUMINNDO DO useEffect - COMENTE SE NÃO QUISER USAR NO SEU PROJETO */}
<h3>Latest Articles on my Blog (PT-BR)</h3>
<div className="groupDetails">
{
articles.map((article, index) => (
<span key={index}>
<a href={article.link} target="_blank" rel="noreferrer">× {article.title}</a>
</span>
))
}
</div>
{/* <h3>Latest Articles on my Blog (PT-BR)</h3>
<div className="groupDetails">
<a href="https://yagasaki.dev/search/" target="_blank" rel="noreferrer">× Como atualizar seu README do Github com as últimas publicações de Blog ou Dev.to</a>
<a href="https://yagasaki.dev/search/" target="_blank" rel="noreferrer">× Fazendo deploy da sua aplicação Web na Vercel</a>
<a href="https://yagasaki.dev/search/" target="_blank" rel="noreferrer">× Análise do Arc Browser, meu substituto do Google Chrome</a>
<a href="https://yagasaki.dev/search/" target="_blank" rel="noreferrer">× TypeScript - Types vs. Interfaces e qual usar escolher no próximo projeto?</a>
</div> */}
</div>
</div>
<div className="sidebar">
<h2>Currently Online</h2>
<div className="links">
<a href="">Badges <span>87</span></a>
<div className="badges">
<img src="/js.png" alt="BadgeIcon" title="Node Developer" />
<img src="/ts.png" alt="BadgeIcon" title="Typescript Developer" />
<img src={"https://community.cloudflare.steamstatic.com/public/images/badges/02_years/steamyears" + (new Date().getFullYear() - sinceExperience) + "_54.png"} alt="BadgeIcon" title="Years of Experience" />
{
getLevelByGPQ(userRepos?.totalCommits)
}
</div>
<a href={githubLink} target="_blank" rel="noreferrer">Public Repositories <span>{userInfo?.public_repos}</span></a>
<a href={githubLink} target="_blank" rel="noreferrer">Total Stars <span>{userRepos?.totalStars}</span></a>
<a href={githubLink} target="_blank" rel="noreferrer">Following <span>{userInfo?.following}</span></a>
<a href={githubLink} target="_blank" rel="noreferrer">Followers <span>{userInfo?.followers}</span></a>
<h2 className="title">Top Repositories</h2>
<div className="links">
<a href="https://github.com/Yagasaki7K/website-steamfolio" className="link" target="_blank" rel="noreferrer">steamfolio</a>
<a href="https://github.com/Yagasaki7K/website-onigirihardcore" className="link" target="_blank" rel="noreferrer">onigirihardcore</a>
<a href="https://github.com/Yagasaki7K/website-essentials" className="link" target="_blank" rel="noreferrer">essentials</a>
<a href="https://github.com/Yagasaki7K/website-findyourpet" className="link" target="_blank" rel="noreferrer">findyourpet</a>
<a href="https://github.com/Yagasaki7K/website-empreguei" className="link" target="_blank" rel="noreferrer">empreguei</a>
</div>
</div>
</div>
</div>
<div className="copyright">
<a href="https://github.com/Yagasaki7K" target="_blank" rel="noreferrer">© 2024 - {new Date().getFullYear()} Anderson "Yagasaki" Marlon </a>
</div>
</SteamDetails>
)
)
}
export default App