feat(join): add leave room button when there is no opponent yet

This commit is contained in:
Yael Arturo Chavoya Andalón
2024-09-30 16:36:04 -06:00
committed by Sparsh Goenka
parent e285fa4801
commit 0b5f513520
2 changed files with 17 additions and 6 deletions

View File

@@ -6,6 +6,11 @@
import { Users } from 'lucide-svelte';
let gameState = new State();
function leaveRoom() {
gameState.socket.emit('leave');
gameState = new State();
}
</script>
<div class="min-h-screen bg-base-300 py-8 px-4 sm:px-6 lg:px-8">
@@ -40,10 +45,7 @@
</div>
<button
class="btn btn-error text-xl"
onclick={() => {
gameState.socket.emit('leave');
gameState = new State();
}}>Leave</button
onclick={leaveRoom}>Leave</button
>
</div>
{/if}
@@ -73,6 +75,7 @@
roomCode={gameState.room}
createRoom={() => gameState.createRoom()}
joinRoom={(code) => gameState.joinRoom(code)}
leaveRoom={leaveRoom}
/>
{/if}
</div>