Skip to content

Commit

Permalink
Add room options
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafadalga committed Oct 10, 2023
1 parent b57f89d commit 48f67e2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/_components/game/RoomOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useRouter } from "next/navigation";
import { doc, DocumentReference, getFirestore, updateDoc } from "firebase/firestore";
import useLoader from "@/_store/useLoader";

export default function RoomOptions({ id }: { id: string }) {
const { push } = useRouter();
const db = getFirestore();
const loader = useLoader();
const docRef: DocumentReference = doc(db, "rooms", id);


const handleExit = async () => {
loader.onOpen();
await updateDoc(docRef, {
"isGameCompleted": true,
})
loader.onClose();
push("/");
}
return (
<div className="m-20 flex justify-center gap-3">
<button
onClick={handleExit}
className="w-24 xs:w-32 sm:w-40 text-[10px] xs:text-xs lg:text-sm text-white bg-purple-600 hover:bg-purple-700 focus:outline-none border border-white font-medium rounded-lg px-5 py-2 sm:py-2.5">
Exit
</button>
</div>
);
};

0 comments on commit 48f67e2

Please sign in to comment.