+
);
}
diff --git a/src/components/Cards/PinsCard.js b/src/components/Cards/PinsCard.js
index ce7aa77..b49eccd 100644
--- a/src/components/Cards/PinsCard.js
+++ b/src/components/Cards/PinsCard.js
@@ -3,17 +3,16 @@ import { Link } from 'react-router-dom';
export default function PinsCard({ pin }) {
return (
-
-
-
-
{pin.name}
-
- {pin.description}
-
-
- Edit Pin
-
+
+
+
+
{pin.name}
+
{pin.description}
+
-
+
);
}
diff --git a/src/components/Forms/BoardForm.js b/src/components/Forms/BoardForm.js
new file mode 100644
index 0000000..ec813d4
--- /dev/null
+++ b/src/components/Forms/BoardForm.js
@@ -0,0 +1,105 @@
+import React, { Component } from 'react';
+import firebase from 'firebase/app';
+import 'firebase/storage';
+import getUser from '../../helpers/data/authData';
+import { createBoard, updateBoard } from '../../helpers/data/boardData';
+
+export default class BoardForm extends Component {
+ state = {
+ firebaseKey: this.props.board?.firebaseKey || '',
+ name: this.props.board?.name || '',
+ imageUrl: this.props.board?.imageUrl || '',
+ userId: this.props.board?.userId || '',
+ description: this.props.board?.description || '',
+ }
+
+ componentDidMount() {
+ const userId = getUser();
+ this.setState({ userId });
+ }
+
+ handleChange = (e) => {
+ if (e.target.name === 'filename') {
+ this.setState({ imageUrl: '' });
+ const storageRef = firebase.storage().ref();
+ const imagesRef = storageRef.child(`pinterest/${this.state.userId}/${Date.now()}${e.target.files[0].name}`);
+
+ imagesRef.put(e.target.files[0]).then((snapshot) => {
+ snapshot.ref.getDownloadURL().then((imageUrl) => {
+ this.setState({ imageUrl });
+ });
+ });
+ } else {
+ this.setState({
+ [e.target.name]: e.target.value,
+ });
+ }
+ }
+
+ handleSubmit = (e) => {
+ e.preventDefault();
+ this.btn.setAttribute('disabled', 'disabled');
+ if (this.state.firebaseKey === '') {
+ createBoard(this.state)
+ .then(() => {
+ this.props.onUpdate?.();
+ this.setState({ success: true });
+ });
+ } else {
+ updateBoard(this.state)
+ .then(() => {
+ this.props.onUpdate?.(this.props.board.firebaseKey);
+ this.setState({ success: true });
+ });
+ }
+ }
+
+ render() {
+ const { success } = this.state;
+ return (
+ <>
+ { success && (
Your Board was Updated/Created
)
+ }
+
+ >
+ );
+ }
+}
diff --git a/src/components/Modal/index.js b/src/components/Modal/index.js
new file mode 100644
index 0000000..6204767
--- /dev/null
+++ b/src/components/Modal/index.js
@@ -0,0 +1,28 @@
+/* eslint react/no-multi-comp: 0, react/prop-types: 0 */
+
+import React, { useState } from 'react';
+import {
+ Button, Modal, ModalHeader, ModalBody,
+} from 'reactstrap';
+
+const AppModal = (props) => {
+ const { className } = props;
+
+ const [modal, setModal] = useState(false);
+
+ const toggle = () => setModal(!modal);
+
+ return (
+
+
+
+ {props.title}
+ {props.children}
+
+
+ );
+};
+
+export default AppModal;
diff --git a/src/components/MyNavbar/index.js b/src/components/MyNavbar/index.js
index f85cc15..4f5d133 100644
--- a/src/components/MyNavbar/index.js
+++ b/src/components/MyNavbar/index.js
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import firebase from 'firebase/app';
import 'firebase/auth';
-import { Link } from 'react-router-dom';
+import { Link, useHistory } from 'react-router-dom';
import {
Collapse,
Navbar,
@@ -16,54 +16,62 @@ import {
import SearchInput from '../SearchInput';
export default function MyNavbar(props) {
+ const history = useHistory();
const logMeOut = (e) => {
e.preventDefault();
+ history.push('/');
firebase.auth().signOut();
};
const { user } = props;
const [isOpen, setIsOpen] = useState(false);
const toggle = () => setIsOpen(!isOpen);
- return (
+ return user && (
-
- Pinterest
+
+
+ Pinterest
+
-
diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js
new file mode 100644
index 0000000..4cbddba
--- /dev/null
+++ b/src/components/PageHeader/index.js
@@ -0,0 +1,9 @@
+const PageHeader = (props) => (
+
+
+
{props.user?.displayName}
+
{props.user?.providerData[0].email}
+
+);
+
+export default PageHeader;
diff --git a/src/components/SearchInput/index.js b/src/components/SearchInput/index.js
index 2a6ddfd..5799e8e 100644
--- a/src/components/SearchInput/index.js
+++ b/src/components/SearchInput/index.js
@@ -25,9 +25,9 @@ class SearchInput extends Component {
render() {
return (
-