+
);
}
@@ -95,24 +91,19 @@ export default function Party() {
});
return (
-
-
-
- Code: {party.code.toUpperCase()}
-
-
Mode: {_.startCase(_.toLower(party.mode))}
- {!isAdmin && (
-
- Waiting for party leader to start the party...
-
- )}
-
Players:
-
-
- {isAdmin && }
-
-
+
+ Mode: {_.startCase(_.toLower(party.mode))}
+ {!isAdmin && (
+
+ Waiting for party leader to start the party...
+
+ )}
+ Players:
+
+
+ {isAdmin && }
+
-
+
);
}
diff --git a/components/PartyCard.tsx b/components/PartyCard.tsx
new file mode 100644
index 0000000..4b0e660
--- /dev/null
+++ b/components/PartyCard.tsx
@@ -0,0 +1,16 @@
+export default function PartyCard({
+ children,
+ code,
+}: {
+ children: React.ReactNode;
+ code: string;
+}) {
+ return (
+
+
+
Code: {code.toUpperCase()}
+ {children}
+
+
+ );
+}
diff --git a/components/StartGame.tsx b/components/StartGame.tsx
index 9aac903..9b5b2d6 100644
--- a/components/StartGame.tsx
+++ b/components/StartGame.tsx
@@ -1,16 +1,24 @@
"use client";
+import { useContext } from "react";
+import { ErrorContext } from "./App";
+import { useSWRConfig } from "swr";
+
export default function StartGame() {
+ const { setError } = useContext(ErrorContext);
+ const { mutate } = useSWRConfig();
+
async function startGame() {
const res = await fetch("/api/party/start", {
method: "POST",
});
if (!res.ok) {
- throw new Error(await res.json());
+ setError(await res.json());
+ return;
}
- console.log(await res.json());
+ mutate("/api/user");
}
return (