2021-09-24 09:15:03 +09:00
|
|
|
// Base layout
|
|
|
|
import Layout from "../../components/Layout"
|
|
|
|
|
|
|
|
// React
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
|
|
|
// Data fetching
|
2021-09-24 10:08:30 +09:00
|
|
|
import Players from '../../components/Minecraft/Players'
|
2021-09-24 19:06:26 +09:00
|
|
|
import PlayerName from '../../components/Minecraft/PlayerName'
|
2021-09-26 12:52:37 +09:00
|
|
|
import useSwr from 'swr'
|
|
|
|
|
|
|
|
const fetcher = (url) => fetch(url).then((res) => res.json())
|
2021-09-24 09:15:03 +09:00
|
|
|
|
2021-09-24 10:08:30 +09:00
|
|
|
export default function UUID() {
|
2021-09-24 09:15:03 +09:00
|
|
|
const router = useRouter()
|
|
|
|
const { uuid } = router.query
|
2021-09-26 12:52:37 +09:00
|
|
|
const { data, error } = useSwr(
|
|
|
|
router.query.id ? `/api/user/${router.query.id}` : null,
|
|
|
|
fetcher
|
|
|
|
)
|
2021-09-24 09:15:03 +09:00
|
|
|
|
2021-09-26 12:52:37 +09:00
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Layout title="エラー - プレイヤー情報">
|
|
|
|
<p className="text-2xl">エラーが発生しました。</p>
|
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2021-09-24 19:06:26 +09:00
|
|
|
|
2021-09-26 12:52:37 +09:00
|
|
|
if (!data) {
|
2021-09-24 19:06:26 +09:00
|
|
|
return (
|
|
|
|
<>
|
2021-09-26 12:52:37 +09:00
|
|
|
<Layout title="読み込み中... - プレイヤー情報">
|
2021-09-24 19:06:26 +09:00
|
|
|
<Players uuid={uuid} />
|
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
)
|
2021-09-26 12:52:37 +09:00
|
|
|
}
|
|
|
|
|
2021-09-24 09:15:03 +09:00
|
|
|
return (
|
|
|
|
<>
|
2021-09-26 12:52:37 +09:00
|
|
|
<Layout title={<PlayerName uuid={uuid.uuid} /> + " - " + "プレイヤー情報"}>
|
2021-09-24 10:08:30 +09:00
|
|
|
<Players uuid={uuid} />
|
2021-09-24 09:15:03 +09:00
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|