Skip to content

Commit

Permalink
temp remove rc
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerkrewson committed Jul 28, 2024
1 parent f844963 commit 0384375
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ const Home = ({ loading }) => {
const router = useRouter();
const [newGameLoading, setNewGameLoading] = useState(false);
const t = useI18n();
// const onNewGame = async (e) => {
// e.preventDefault();
// setNewGameLoading(true);
const onNewGame = async (e) => {
e.preventDefault();
setNewGameLoading(true);

// try {
// const res = await fetch(window.location.origin + "/new", {
// method: "POST",
// headers: {
// Accept: "application/json",
// "Content-Type": "application/json",
// },
// body: JSON.stringify({ name }),
// });
try {
const res = await fetch(window.location.origin + "/new", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ name }),
});

// if (res.status === 200) {
// const { gameCode } = await res.json();
// router.push("/" + gameCode);
// } else if (res.status === 423) {
// const { minutes } = await res.json();
// setNewGameLoading(false);
if (res.status === 200) {
const { gameCode } = await res.json();
router.push("/" + gameCode);
} else if (res.status === 423) {
const { minutes } = await res.json();
setNewGameLoading(false);

// Swal.fire(lockedMessage(minutes));
// } else {
// throw res.status + " " + res.statusText;
// }
// } catch (error) {
// console.error(error);
// Swal.fire(error);
// setNewGameLoading(false);
// }
// };
Swal.fire(lockedMessage(minutes));
} else {
throw res.status + " " + res.statusText;
}
} catch (error) {
console.error(error);
Swal.fire(error);
setNewGameLoading(false);
}
};

return (
<div className="main-menu">
Expand All @@ -62,16 +62,14 @@ const Home = ({ loading }) => {
{!loading && (
<>
<div className="button-container">
<Link href="https://rocketcrab.com/join">
<Link href="/join">
<button id="btn-join-game" className="btn-large">
{t("ui.join game")}
</button>
</Link>
<Link href="https://rocketcrab.com/transfer/tk-spyfall">
<button id="btn-new-game" className="btn-large">
{t("ui.new game")}
</button>
</Link>
<button id="btn-new-game" className="btn-large" onClick={onNewGame}>
{t("ui.new game")}
</button>
</div>
<p>Powered by 🚀🦀</p>
<div className="button-container-vertical">
Expand Down

0 comments on commit 0384375

Please sign in to comment.