import { io, Socket } from 'socket.io-client';

let socket: Socket | null = null;

export function getPosDraftSocket(userId: string) {
  if (!socket) {
    socket = io({
      path: '/api/pos-draft-socket',
      transports: ['websocket'],
    });
    socket.on('connect', () => {
      socket?.emit('auth', { userId });
    });
  }
  return socket;
}
