import { NavigateFunction } from 'react-router-dom';
import { useGameStore } from '../store/gameStore';
import { emit } from './socket';

export function leaveGame(navigate: NavigateFunction) {
  emit.leaveGame();
  useGameStore.getState().reset();
  localStorage.removeItem('bridzik_player');
  navigate('/', { replace: true });
}
