components#Member TypeScript Examples

The following examples show how to use components#Member. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Builder.tsx    From nuzlocke with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
function Builder(): JSX.Element {
  const { t } = useTranslation('builder');
  const team = useStore(
    useCallback(
      (state) => (state?.selectedGame?.value ? state.team[state?.selectedGame?.value] : null),
      []
    )
  );
  const selectedGame = useStore(useCallback((state) => state.selectedGame, []));
  const addTeamMember = useStore(useCallback((state) => state.addTeamMember, []));
  const handlePokemon = (id: number) => {
    addTeamMember(id);
  };

  const panes = [
    {
      menuItem: 'Builder',
      render: () => (
        <Tab.Pane attached={false}>
          <div className={styles.builder}>
            {team?.length > 0 ? (
              <div className={styles.team}>
                {team?.map((poke, i) => {
                  return <Member index={i} key={`team-${poke.id}`} pokemonDetail={poke} />;
                })}
              </div>
            ) : (
              <div className={styles.placeholder}>
                <PokeballSVG />
                <span>{selectedGame ? t('press_plus') : t('please_select', { ns: 'common' })}</span>
              </div>
            )}
            {selectedGame && (
              <PokemonSelector handlePokemon={handlePokemon}>
                <Button
                  circular
                  className={styles.button}
                  data-testid="builder-add"
                  disabled={team?.length === 6}
                  icon="plus"
                  type="button"
                />
              </PokemonSelector>
            )}
          </div>
        </Tab.Pane>
      ),
    },
    {
      menuItem: t('coverage'),
      disabled: !team?.length,
      render: () => (
        <Tab.Pane attached={false}>
          {team?.length > 0 ? (
            <Coverage />
          ) : (
            <div className={styles.builder}>
              <div className={styles.placeholder}>
                <PokeballSVG />
                <span>{selectedGame ? t('press_plus') : t('please_select', { ns: 'common' })}</span>
              </div>
            </div>
          )}
        </Tab.Pane>
      ),
    },
  ];

  return <Tab className={styles.tabs} menu={{ secondary: true }} panes={panes} />;
}