2021-09-24 09:15:03 +09:00
|
|
|
// Base layout
|
|
|
|
import Layout from "../../components/Layout"
|
|
|
|
|
|
|
|
// i18n
|
|
|
|
import useTranslation from 'next-translate/useTranslation'
|
|
|
|
|
|
|
|
// React
|
2021-09-24 19:06:26 +09:00
|
|
|
import React, { useState, useEffect } from 'react';
|
2021-09-24 09:15:03 +09:00
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
|
|
|
// Data fetching
|
2021-09-24 19:06:26 +09:00
|
|
|
import axios from 'axios';
|
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-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 { locale, locales, defaultLocale, pathname } = router
|
|
|
|
const { t, lang } = useTranslation("index")
|
|
|
|
const { uuid } = router.query
|
|
|
|
|
2021-09-24 19:06:26 +09:00
|
|
|
const [data, setData] = useState({ hits: [] });
|
|
|
|
|
|
|
|
let playerName = null;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
const result = await axios(
|
|
|
|
'/api/PlayerName/' + uuid,
|
|
|
|
);
|
|
|
|
setData(result.data);
|
|
|
|
|
|
|
|
};
|
|
|
|
fetchData();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
if (data.username === undefined) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Layout title="404 - プレイヤー情報">
|
|
|
|
<Players uuid={uuid} />
|
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
} else {
|
2021-09-24 09:15:03 +09:00
|
|
|
return (
|
|
|
|
<>
|
2021-09-24 19:06:26 +09:00
|
|
|
<Layout title={data.username + " - " + "プレイヤー情報"}>
|
2021-09-24 10:08:30 +09:00
|
|
|
<Players uuid={uuid} />
|
2021-09-24 09:15:03 +09:00
|
|
|
</Layout>
|
|
|
|
</>
|
|
|
|
)
|
2021-09-24 19:06:26 +09:00
|
|
|
}
|
2021-09-24 09:15:03 +09:00
|
|
|
}
|