Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ampers: Angela Poland #30

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nonfunctional delete button on every card
  • Loading branch information
AngelaPoland committed Jun 11, 2018
commit 6388f24116bd5b167bb7722a49da1d3de97f0bb6
33 changes: 29 additions & 4 deletions src/components/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,54 @@ class Board extends Component {
super(props);

this.state = {
cards: CARD_DATA["cards"],
cards: [],
};
}

componentDidMount = () => {
console.log('Component did mount was called')

axios.get('https://inspiration-board.herokuapp.com/boards/angelap/cards')
.then((response) => {
this.setState({ cards: response.data });
console.log(response.data)
})
.catch((error) => {
console.log('Error is happening');
console.log(error);
this.setState({ error: error.message});
return error;

});
}

renderCards = () => {
console.log('Rendering cards')
const cardList = this.state.cards.map((card, index) => {
return (
<Card
key={index}
text={card.text}
emoji={card.emoji}
text={card["card"].text}
emoji={card["card"].emoji}
/>
);
});
return cardList;
}

deleteCard = (card) => {
const cards = this.state.cards;

cards.delete(card);
this.setState({
cards,
});
}

render() {
return (
<div>
<section className="board">

{this.renderCards()}
</section>
</div>
Expand Down
17 changes: 9 additions & 8 deletions src/components/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class Card extends Component {
<div className="card__content">
<p className="card__content-text">{this.props.text}</p>
<p className="card__content-emoji">{this.displayEmoji()}</p>
<button className="card__delete">Delete</button>
</div>
</div>
</div>
)
)
}
}
}

Card.propTypes = {
text: PropTypes.string.isRequired,
emoji: PropTypes.string,
};
Card.propTypes = {
text: PropTypes.string.isRequired,
emoji: PropTypes.string,
};

export default Card;
export default Card;