2021-09-26 13:36:23 +09:00
|
|
|
// Component
|
2021-09-25 21:51:35 +09:00
|
|
|
import Group from './Group';
|
2021-09-24 16:47:45 +09:00
|
|
|
|
2021-09-26 13:36:23 +09:00
|
|
|
// Data fetching
|
|
|
|
import useSwr from 'swr'
|
|
|
|
|
|
|
|
const fetcher = (url) => fetch(url).then((res) => res.json())
|
|
|
|
|
2021-09-24 16:47:45 +09:00
|
|
|
function App (props) {
|
|
|
|
const uuid = props;
|
2021-09-26 13:36:23 +09:00
|
|
|
const { data, error } = useSwr(
|
2021-12-11 06:42:23 +09:00
|
|
|
uuid.uuid ? `https://api.ashcon.app/mojang/v2/user/${uuid.uuid}` : null,
|
2021-09-26 13:36:23 +09:00
|
|
|
fetcher
|
|
|
|
)
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<>エラーが発生しました。</>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
if (!data) {
|
|
|
|
return (
|
|
|
|
<>読み込み中...</>
|
|
|
|
)
|
|
|
|
} else {
|
2021-09-24 17:43:07 +09:00
|
|
|
return (
|
2021-09-26 13:36:23 +09:00
|
|
|
<>
|
|
|
|
<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 inline">{data.username}</p>
|
|
|
|
<Group uuid={uuid.uuid} />
|
|
|
|
</div>
|
|
|
|
</>
|
2021-09-24 17:43:07 +09:00
|
|
|
)
|
2021-09-26 13:36:23 +09:00
|
|
|
}
|
|
|
|
}
|
2021-09-24 16:47:45 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|