import React, { Component } from "react";
import { View } from "react-native";

import { MakietyTalii } from "../../dane/Makiety";
import Talia from "./Talia";
import TworzenieTalii from "./TworzenieTalii";

export default class EkranTalii extends Component {
  static displayName = "EkranTalii";

  constructor(props) {
    super(props);
    this.state = { talie: MakietyTalii };
  }

  stworzWidokTalii() {
    if (!this.state.talie) {
      return null;
    }

    return this.state.talie.map(talia => {
      return <Talia talia={talia} ilosc={talia.karty.length} key={talia.id} />;
    });
  }

  render() {
    return (
      <View>
        {this.stworzWidokTalii()}
        <TworzenieTalii />
      </View>
    );
  }
}
