0
0
mirror of https://github.com/yude-jp/yude.jp synced 2024-12-22 20:20:09 +09:00

Add group badge @ /minecraft/players/[uuid]

This commit is contained in:
yude 2021-09-25 21:51:35 +09:00
parent 967c0f77af
commit 365559158d
Signed by: yude
GPG Key ID: EB0FE5D925C4A968
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,34 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import useTranslation from 'next-translate/useTranslation'
import { useRouter } from 'next/router'
function App (props) {
const uuid = props;
const router = useRouter()
const { locale, locales, defaultLocale, pathname } = router
const { t, lang } = useTranslation("common")
const [data, setData] = useState({ hits: [] });
useEffect(() => {
const fetchData = async () => {
const result = await axios(
'https://minecraft.yude.jp/group/' + uuid.uuid,
);
setData(result.data);
};
fetchData();
}, []);
if (data === undefined){
console.log("[Minecraft: PlayersBio] データの取得に失敗しました。 / Failed to retrieve data.")
return <p></p>
}else {
if (data.toString() == "staff") {
return <span class="inline-flex items-center justify-center px-3 py-2 text-base font-bold leading-none text-indigo-100 bg-indigo-700 rounded ml-3">Staff</span>
} else {
return <></>
}
};
}
export default App;

View File

@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
import Group from './Group';
function App (props) {
const uuid = props;
@ -28,7 +29,8 @@ function App (props) {
return (
<div className='has-tooltip'>
<span className='tooltip rounded shadow-lg p-1 bg-gray-100 text-red-500 -mt-8 font-mono text-sm'>UUID: {uuid.uuid}</span>
<p className="text-2xl">{data.username}</p>
<p className="text-2xl inline">{data.username}</p>
<Group uuid={uuid.uuid} />
</div>
)
}