forked from AdaGold/inspiration-board
-
Notifications
You must be signed in to change notification settings - Fork 45
Michelle - Edges - Inspiration Board #40
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
Open
kangazoom
wants to merge
10
commits into
Ada-C10:master
Choose a base branch
from
kangazoom:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f622a6b
got hardcoded components to show
kangazoom 757f28b
fixed fields to include text, not name
kangazoom d6c05d0
set up emoji unicode feature so we can see them pretty emojis
kangazoom 214bb08
moved card data around and didmount to prep for axios
kangazoom f13da72
basic get concept working for axios + added check for valid emoji names
kangazoom 316f3aa
got cards to show up from get api and formatting
kangazoom 94a1674
set up enzyme+jest
kangazoom e388f33
added card test/snapshot --> passing
kangazoom f7c853d
added newcardform test/snapshot --> passing
kangazoom bc79279
delete card working; reload issue though
kangazoom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,26 +8,123 @@ import NewCardForm from './NewCardForm'; | |
| import CARD_DATA from '../data/card-data.json'; | ||
|
|
||
| class Board extends Component { | ||
| constructor() { | ||
| super(); | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.emojiLibrary = require('emoji-dictionary'); | ||
|
|
||
|
|
||
| this.state = { | ||
| cards: [], | ||
| }; | ||
| } | ||
|
|
||
| emojify = (emojiTextName) => { | ||
| let validEmojiCheck = this.emojiLibrary.names.includes(emojiTextName) | ||
| return validEmojiCheck ? this.emojiLibrary.getUnicode(emojiTextName) : emojiTextName | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| const GET_CARDS_URL = 'https://inspiration-board.herokuapp.com/boards/mightymichelle/cards'; | ||
|
|
||
| axios.get(GET_CARDS_URL) | ||
| .then((response) => { | ||
| this.setState({ | ||
| cards: response.data | ||
| }); | ||
| }) | ||
| .catch((error) => { | ||
| this.setState({ | ||
| error: error.message | ||
| }); | ||
| }); | ||
| // | ||
| // | ||
| // | ||
| // this.setState({ | ||
| // cards: fetchCardData() | ||
| // }); | ||
| } | ||
|
|
||
| deleteCard = (cardID) => { | ||
| axios.delete(`https://inspiration-board.herokuapp.com/cards/${cardID}`) | ||
| .then((response) => { | ||
| let card = this.state.cards.find((card) => card.id === response.data.card.id); | ||
| let updatedCardCollection = this.state.cards.filter(element => element !== card); | ||
|
|
||
| this.setState({cards: updatedCardCollection}); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, weird, the list of cards isn't immediately updating for me after deleting a card... I haven't looked into debugging this though |
||
| }) | ||
| .catch((error) => { | ||
| console.log(error.message); | ||
| }) | ||
| } | ||
|
|
||
|
|
||
| // addCard = (newCard) => { | ||
| // const cards = this.state.cards; | ||
| // | ||
| // cards.push(newCard) | ||
| // this.setState({cards: cards}) | ||
| // } | ||
|
|
||
| // collectCards = () => { | ||
| // const cardsToAdd = | ||
| // | ||
| // cardsToAdd.forEach((card) => { | ||
| // let cards = this.state.cards; | ||
| // | ||
| // cards.push(card); | ||
| // }); | ||
| // this.setState({cards: cardsToAdd}) | ||
| // | ||
| // } | ||
|
|
||
|
|
||
|
|
||
|
|
||
| render() { | ||
| let cards = this.state.cards | ||
|
|
||
| let cardCollection = cards.map((card) => { | ||
|
|
||
| // console.log(cards[i]) | ||
|
|
||
| // console.log(card.card.id) | ||
|
|
||
|
|
||
| let formattedCard = { | ||
| // key: i, | ||
| id: card.card.id, | ||
| text: card.card.text, | ||
| emoji: this.emojify(card.card.emoji), | ||
| deleteCardCB: this.deleteCard | ||
| } | ||
|
|
||
| console.log(formattedCard) | ||
|
|
||
| return <Card card={formattedCard} | ||
| /> | ||
|
|
||
|
|
||
| }); | ||
|
|
||
|
|
||
| return ( | ||
| <div> | ||
| Board | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| {cardCollection} | ||
| </div> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| Board.propTypes = { | ||
| // const fetchCardData = () => { | ||
| // return [{text: 'u go grl', emoji: 'heart_eyes'}, | ||
| // {text: 'you can do itttt', emoji: 'grinning'}] | ||
| // } | ||
|
|
||
|
|
||
| }; | ||
| // Board.propTypes = { | ||
| // | ||
| // }; | ||
|
|
||
| export default Board; | ||
| export default Board; | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from 'react'; | ||
| import NewCardForm from '../NewCardForm'; | ||
| import { shallow } from 'enzyme'; | ||
|
|
||
| describe('NewCardForm', () => { | ||
| it('will match the NewCardForm snapshot', () => { | ||
|
|
||
| const wrapper = shallow( | ||
| <NewCardForm/> | ||
| ); | ||
|
|
||
| expect(wrapper).toMatchSnapshot(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`card will match the Card Snapshot 1`] = ` | ||
| <div | ||
| className="card" | ||
| key="1" | ||
| > | ||
| <p> | ||
| Text: " | ||
| testing is fun! | ||
| " | ||
| </p> | ||
| <p> | ||
| Emoji: | ||
| </p> | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`NewCardForm will match the NewCardForm snapshot 1`] = ` | ||
| <div> | ||
| hi | ||
| </div> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import React from 'react'; | ||
| import Card from '../Card'; | ||
| import { shallow } from 'enzyme'; | ||
|
|
||
|
|
||
| describe('card', () => { | ||
| it('will match the Card Snapshot', () => { | ||
| const cardTester = { | ||
| id: 1, | ||
| text: 'testing is fun!' | ||
| } | ||
| const wrapper = shallow( | ||
| <Card card={cardTester}/> | ||
| ); | ||
|
|
||
| expect(wrapper).toMatchSnapshot(); | ||
| }) | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import Enzyme from 'enzyme'; | ||
| import {configure} from 'enzyme'; | ||
| import Adapter from 'enzyme-adapter-react-16'; | ||
|
|
||
| Enzyme.configure({ adapter: new Adapter() }); | ||
| configure({ adapter: new Adapter() }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice if you used the
props passed intoBoardfromApp--urlandboardName!