diff --git a/src/components/Board.js b/src/components/Board.js
index 9222fd88..03d60cae 100644
--- a/src/components/Board.js
+++ b/src/components/Board.js
@@ -16,10 +16,71 @@ class Board extends Component {
};
}
+ componentDidMount() {
+ axios.get('https://inspiration-board.herokuapp.com/boards/ultra_princess/cards')
+ .then((res) => {
+ this.setState({ cards: res.data })
+ })
+ .catch((error) => {
+ alert('hm ur cards didnt load maybe u should refresh lol');
+ });
+ }
+
+ delCard = (id) => {
+ const url = 'https://inspiration-board.herokuapp.com/cards/' + id.toString();
+
+ axios.delete(url)
+ .then(() => {
+ let index;
+ let newState = this.state;
+
+ newState.cards.forEach((card, i) => {
+ if (card.card.id === id) {
+ index = i;
+ }
+ });
+
+ newState.cards.splice(index, 1);
+
+ this.setState(newState);
+ })
+ .catch((e) => {
+ alert('sry could not delete ?? idk tbh..');
+ console.log(e);
+ });
+ }
+
+ addCard = (newCard) => {
+ const url = `https://inspiration-board.herokuapp.com/boards/ultra_princess/cards?text=${newCard.text}&emoji=${newCard.emoji}`;
+
+ axios.post(url)
+ .then((res) => {
+ let newState = this.state;
+ newState.cards.push(res.data);
+
+ this.setState(newState);
+ })
+ .catch((e) => {
+ alert('sry could not add card ?? idk tbh..');
+ console.log(e);
+ });
+ }
+
render() {
+ const cards = this.state.cards.map((e, i) => {
+ return (
+
+ )
+ });
+
return (
-
- Board
+
+ { cards }
+
)
}
diff --git a/src/components/Card.js b/src/components/Card.js
index 6788cc03..827fd2f8 100644
--- a/src/components/Card.js
+++ b/src/components/Card.js
@@ -8,7 +8,11 @@ class Card extends Component {
render() {
return (
- Card
+
+
{ this.props.text }
+
{ this.props.emoji ? emoji.getUnicode(this.props.emoji) : "" }
+
+
)
}
diff --git a/src/components/NewCardForm.js b/src/components/NewCardForm.js
index 47331423..2daa688a 100644
--- a/src/components/NewCardForm.js
+++ b/src/components/NewCardForm.js
@@ -4,3 +4,69 @@ import emoji from 'emoji-dictionary';
import './NewCardForm.css';
const EMOJI_LIST = ["", "heart_eyes", "beer", "clap", "sparkling_heart", "heart_eyes_cat", "dog"]
+
+class NewCardForm extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ text: '',
+ emoji: '',
+ };
+ }
+
+ resetState = () => {
+ this.setState({
+ text: '',
+ emoji: '',
+ });
+ }
+
+ onFormChange = (event) => {
+ const field = event.target.name;
+ const value = event.target.value;
+
+ const updatedState = {};
+ updatedState[field] = value;
+ this.setState(updatedState);
+ }
+
+ onSubmit = (event) => {
+ event.preventDefault();
+ const { text, emoji } = this.state;
+ const newCard = { text: text, emoji: emoji };
+
+ this.props.addCB(newCard);
+ }
+
+ render() {
+ return(
+
+
+ Add a Card!
+
+
+
+ );
+ }
+}
+
+export default NewCardForm;
diff --git a/src/components/NewCardForm.test.js b/src/components/NewCardForm.test.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/components/test/Card.test.js b/src/components/test/Card.test.js
new file mode 100644
index 00000000..9b1965ca
--- /dev/null
+++ b/src/components/test/Card.test.js
@@ -0,0 +1,13 @@
+import React from 'react';
+import Card from '../Card';
+import { shallow } from 'enzyme';
+
+describe('Card', () => {
+ test('that it matches an existing snapshot', () => {
+ const wrapper = shallow(
+
{}} />
+ );
+
+ expect(wrapper).toMatchSnapshot();
+ });
+});
diff --git a/src/components/test/NewCardForm.test.js b/src/components/test/NewCardForm.test.js
new file mode 100644
index 00000000..e1d52c1e
--- /dev/null
+++ b/src/components/test/NewCardForm.test.js
@@ -0,0 +1,13 @@
+import React from 'react';
+import NewCardForm from '../NewCardForm';
+import { shallow } from 'enzyme';
+
+describe('NewCardForm', () => {
+ test('that it matches an existing snapshot', () => {
+ const wrapper = shallow(
+ {}} />
+ );
+
+ expect(wrapper).toMatchSnapshot();
+ });
+});
diff --git a/src/components/test/__snapshots__/Card.test.js.snap b/src/components/test/__snapshots__/Card.test.js.snap
new file mode 100644
index 00000000..6878f4a6
--- /dev/null
+++ b/src/components/test/__snapshots__/Card.test.js.snap
@@ -0,0 +1,217 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Card that it matches an existing snapshot 1`] = `
+ShallowWrapper {
+ Symbol(enzyme.__root__): [Circular],
+ Symbol(enzyme.__unrendered__): ,
+ Symbol(enzyme.__renderer__): Object {
+ "batchedUpdates": [Function],
+ "getNode": [Function],
+ "render": [Function],
+ "simulateError": [Function],
+ "simulateEvent": [Function],
+ "unmount": [Function],
+ },
+ Symbol(enzyme.__node__): Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": ,
+ "className": "card",
+ },
+ "ref": null,
+ "rendered": Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+
+
+
,
+ ,
+ ],
+ "className": "card__content",
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": undefined,
+ "className": "card__content-text",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "p",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "",
+ "className": "card__content-emoji",
+ },
+ "ref": null,
+ "rendered": "",
+ "type": "p",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "del mee",
+ "onClick": [Function],
+ },
+ "ref": null,
+ "rendered": "del mee",
+ "type": "button",
+ },
+ ],
+ "type": "div",
+ },
+ "type": "div",
+ },
+ Symbol(enzyme.__nodes__): Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": ,
+ "className": "card",
+ },
+ "ref": null,
+ "rendered": Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+
+
+
,
+ ,
+ ],
+ "className": "card__content",
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": undefined,
+ "className": "card__content-text",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "p",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "",
+ "className": "card__content-emoji",
+ },
+ "ref": null,
+ "rendered": "",
+ "type": "p",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "del mee",
+ "onClick": [Function],
+ },
+ "ref": null,
+ "rendered": "del mee",
+ "type": "button",
+ },
+ ],
+ "type": "div",
+ },
+ "type": "div",
+ },
+ ],
+ Symbol(enzyme.__options__): Object {
+ "adapter": ReactSixteenAdapter {
+ "options": Object {
+ "enableComponentDidUpdateOnSetState": true,
+ "lifecycles": Object {
+ "componentDidUpdate": Object {
+ "onSetState": true,
+ },
+ "getDerivedStateFromProps": true,
+ "getSnapshotBeforeUpdate": true,
+ "setState": Object {
+ "skipsComponentDidUpdateOnNullish": true,
+ },
+ },
+ },
+ },
+ },
+}
+`;
diff --git a/src/components/test/__snapshots__/NewCardForm.test.js.snap b/src/components/test/__snapshots__/NewCardForm.test.js.snap
new file mode 100644
index 00000000..969d0479
--- /dev/null
+++ b/src/components/test/__snapshots__/NewCardForm.test.js.snap
@@ -0,0 +1,773 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`NewCardForm that it matches an existing snapshot 1`] = `
+ShallowWrapper {
+ Symbol(enzyme.__root__): [Circular],
+ Symbol(enzyme.__unrendered__): ,
+ Symbol(enzyme.__renderer__): Object {
+ "batchedUpdates": [Function],
+ "getNode": [Function],
+ "render": [Function],
+ "simulateError": [Function],
+ "simulateEvent": [Function],
+ "unmount": [Function],
+ },
+ Symbol(enzyme.__node__): Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+
+ Add a Card!
+
,
+ ,
+ ],
+ "className": "new-card-form",
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Add a Card!",
+ "className": "new-card-form__header",
+ },
+ "ref": null,
+ "rendered": "Add a Card!",
+ "type": "h2",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+ ,
+ ,
+ ,
+ ,
+ ],
+ "className": "new-card-form__form",
+ "name": "new-card-form__form",
+ "onSubmit": [Function],
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Text",
+ "className": "new-card-form__form-label",
+ "htmlFor": "text",
+ },
+ "ref": null,
+ "rendered": "Text",
+ "type": "label",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "className": "new-card-form__form-textarea",
+ "name": "text",
+ "onChange": [Function],
+ "placeholder": "text goes here",
+ "value": "",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "textarea",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Emoji",
+ "className": "new-card-form__form-label",
+ "htmlFor": "emoji",
+ },
+ "ref": null,
+ "rendered": "Emoji",
+ "type": "label",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ],
+ "className": "new-card-form__form-select",
+ "name": "emoji",
+ "onChange": [Function],
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "value": "",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "😍",
+ "value": "heart_eyes",
+ },
+ "ref": null,
+ "rendered": "😍",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "🍺",
+ "value": "beer",
+ },
+ "ref": null,
+ "rendered": "🍺",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "👏",
+ "value": "clap",
+ },
+ "ref": null,
+ "rendered": "👏",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "💖",
+ "value": "sparkling_heart",
+ },
+ "ref": null,
+ "rendered": "💖",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "😻",
+ "value": "heart_eyes_cat",
+ },
+ "ref": null,
+ "rendered": "😻",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "🐶",
+ "value": "dog",
+ },
+ "ref": null,
+ "rendered": "🐶",
+ "type": "option",
+ },
+ ],
+ "type": "select",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "className": "new-card-form__form-button",
+ "name": "submit",
+ "type": "submit",
+ "value": "add it",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "input",
+ },
+ ],
+ "type": "form",
+ },
+ ],
+ "type": "div",
+ },
+ Symbol(enzyme.__nodes__): Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+
+ Add a Card!
+
,
+ ,
+ ],
+ "className": "new-card-form",
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Add a Card!",
+ "className": "new-card-form__header",
+ },
+ "ref": null,
+ "rendered": "Add a Card!",
+ "type": "h2",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+ ,
+ ,
+ ,
+ ,
+ ],
+ "className": "new-card-form__form",
+ "name": "new-card-form__form",
+ "onSubmit": [Function],
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Text",
+ "className": "new-card-form__form-label",
+ "htmlFor": "text",
+ },
+ "ref": null,
+ "rendered": "Text",
+ "type": "label",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "className": "new-card-form__form-textarea",
+ "name": "text",
+ "onChange": [Function],
+ "placeholder": "text goes here",
+ "value": "",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "textarea",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "Emoji",
+ "className": "new-card-form__form-label",
+ "htmlFor": "emoji",
+ },
+ "ref": null,
+ "rendered": "Emoji",
+ "type": "label",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": Array [
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ,
+ ],
+ "className": "new-card-form__form-select",
+ "name": "emoji",
+ "onChange": [Function],
+ },
+ "ref": null,
+ "rendered": Array [
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "value": "",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "😍",
+ "value": "heart_eyes",
+ },
+ "ref": null,
+ "rendered": "😍",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "🍺",
+ "value": "beer",
+ },
+ "ref": null,
+ "rendered": "🍺",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "👏",
+ "value": "clap",
+ },
+ "ref": null,
+ "rendered": "👏",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "💖",
+ "value": "sparkling_heart",
+ },
+ "ref": null,
+ "rendered": "💖",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "😻",
+ "value": "heart_eyes_cat",
+ },
+ "ref": null,
+ "rendered": "😻",
+ "type": "option",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "children": "🐶",
+ "value": "dog",
+ },
+ "ref": null,
+ "rendered": "🐶",
+ "type": "option",
+ },
+ ],
+ "type": "select",
+ },
+ Object {
+ "instance": null,
+ "key": undefined,
+ "nodeType": "host",
+ "props": Object {
+ "className": "new-card-form__form-button",
+ "name": "submit",
+ "type": "submit",
+ "value": "add it",
+ },
+ "ref": null,
+ "rendered": null,
+ "type": "input",
+ },
+ ],
+ "type": "form",
+ },
+ ],
+ "type": "div",
+ },
+ ],
+ Symbol(enzyme.__options__): Object {
+ "adapter": ReactSixteenAdapter {
+ "options": Object {
+ "enableComponentDidUpdateOnSetState": true,
+ "lifecycles": Object {
+ "componentDidUpdate": Object {
+ "onSetState": true,
+ },
+ "getDerivedStateFromProps": true,
+ "getSnapshotBeforeUpdate": true,
+ "setState": Object {
+ "skipsComponentDidUpdateOnNullish": true,
+ },
+ },
+ },
+ },
+ },
+}
+`;
diff --git a/src/data/card-data.json b/src/data/card-data.json
index 1f9793ec..73bab014 100644
--- a/src/data/card-data.json
+++ b/src/data/card-data.json
@@ -2,11 +2,12 @@
{
"cards": [
{
- "text": "Make sure you pet a dog this week!"
+ "text": "Make sure you pet a dog this week!",
+ "emoji": "mask"
},
{
- "text": "",
- "Emoji": "heart_eyes"
+ "text": "sparklesparkle this is the way to do the thing ok ok np np",
+ "emoji": "heart_eyes"
},
{
"text": "REST is part of work"