import { For } from "solid-js";
import { Dialog } from "./miwi/src/Dialog";
import { Txt } from "./miwi/src/Txt";
import { Game, Player } from "./Model";
import { popPage } from "./miwi/src/Nav";

export function SwapPlayerGameDialog(props: { player: Player }) {
  return (
    <Dialog>
      <Txt>Swap Game</Txt>
      <For
        each={Game.allDocs.filter((game) => game.id !== props.player.game?.id)}
      >
        {(game) => (
          <Txt
            widthGrows
            alignLeft
            onClick={() => {
              props.player.game = game;
              popPage();
            }}
          >
            {game.name}
          </Txt>
        )}
      </For>
    </Dialog>
  );
}
