diff --git a/components/CreateParty.tsx b/components/CreateParty.tsx index 53b8ed7..2d5bf48 100644 --- a/components/CreateParty.tsx +++ b/components/CreateParty.tsx @@ -1,6 +1,10 @@ "use client"; +import { useSWRConfig } from "swr"; + export default function CreateParty() { + const { mutate } = useSWRConfig(); + async function createParty() { const res = await fetch("/api/party", { method: "POST", @@ -9,6 +13,8 @@ export default function CreateParty() { if (!res.ok) { throw new Error(await res.json()); } + + mutate("/api/user"); } return ( diff --git a/components/JoinParty.tsx b/components/JoinParty.tsx index d5aa0bc..09b74c1 100644 --- a/components/JoinParty.tsx +++ b/components/JoinParty.tsx @@ -1,8 +1,11 @@ "use client"; import { FormEvent } from "react"; +import { useSWRConfig } from "swr"; export default function JoinParty() { + const { mutate } = useSWRConfig(); + async function onSubmit(event: FormEvent) { event.preventDefault(); @@ -18,6 +21,8 @@ export default function JoinParty() { if (!res.ok) { throw new Error(await res.json()); } + + mutate("/api/user"); } return ( diff --git a/components/Party.tsx b/components/Party.tsx index 10c1f43..bfe1d36 100644 --- a/components/Party.tsx +++ b/components/Party.tsx @@ -58,7 +58,7 @@ export default function Party() {

Mode: {_.startCase(_.toLower(party.mode))}

Players:

- {party.adminId === user.id && } + ); diff --git a/components/StartGame.tsx b/components/StartGame.tsx index 265fe03..59382a4 100644 --- a/components/StartGame.tsx +++ b/components/StartGame.tsx @@ -1,6 +1,10 @@ "use client"; -export default function StartGame() { +export default function StartGame({ visible }: { visible: boolean }) { + if (!visible) { + return; + } + async function startGame() { const res = await fetch("/api/party/start", { method: "POST",