diff --git a/src/components/account.js b/src/components/account.js
index 625bb32..47dda3e 100644
--- a/src/components/account.js
+++ b/src/components/account.js
@@ -1,5 +1,6 @@
import React from 'react';
import UserContext from '../contexts/user';
+import { Image } from 'antd'
import {useContext} from 'react';
@@ -36,6 +37,7 @@ function Account(props) {
return (
<>
Account
+
Username: {user.username}
Email: {user.email}
{Object.keys(profile).map(key => {key}: {profile[key]} )}
diff --git a/src/components/dog.js b/src/components/dog.js
index 1622652..c2da5ec 100644
--- a/src/components/dog.js
+++ b/src/components/dog.js
@@ -4,9 +4,13 @@ import { Image, Row, Col, Typography, Space, Button } from 'antd'
import DogIcon from './dogicon';
import { status, json } from '../utilities/requestHandlers';
+import UserContext from '../contexts/user';
+
const { Title, Paragraph } = Typography;
class Dog extends React.Component {
+
+ static contextType = UserContext;
constructor(props) {
super(props);
@@ -61,20 +65,20 @@ class Dog extends React.Component {
}
render() {
- const user = this.state.user;
const dog = this.state.dog;
- /*
+
//Error Here!! Change the user.role to a valid verification
let adminSpace =
- if(user.role == 'admin'){
+ if(this.context.user.loggedIn){
+ if(this.context.user.loggedIn){
adminSpace =
Delete dog
- Update dog
+ Update dog
}
- */
-
- if (!this.state.dog) {
+ }
+
+ if (!dog) {
return Loading dogs...
}
@@ -85,18 +89,21 @@ class Dog extends React.Component {
);
- return( //add {adminSpace here
+ return( //add {adminSpace} here //Add shelter name and breed
-
+
{dog.name}
- {dog.about}
+ About: {dog.about}
+ Breed: {dog.breedsID}
+ Shelter: {dog.sheltersID}
{icons}
+ {adminSpace}
diff --git a/src/components/editDog.js b/src/components/editDog.js
index a38930d..0e9543d 100644
--- a/src/components/editDog.js
+++ b/src/components/editDog.js
@@ -33,46 +33,32 @@ class EditDog extends React.Component {
handleBreedChange=event=>{
this.setState({
- breed: event.target.value
+ name: event.target.value
})
}
handleAgeChange=event=>{
this.setState({
- age: event.target.value
+ about: event.target.value
})
}
-
- handleSizeChange=event=>{
- this.setState({
- size: event.target.value
- })
- }
-
- handleDescriptionChange=event=>{
- this.setState({
- description: event.target.value
- })
- }
-
+
handleImageChange=event=>{
this.setState({
- selectedFile: event.target.files[0],
+ imageURL: event.target.files[0],
loaded: 0,
})
}
onClickHandler = () => {
const data = new FormData()
- if(this.state.selectedFile){data.append('upload', this.state.selectedFile)}
- if(this.state.breed){data.append('breed', this.state.breed)}
- if(this.state.age){data.append('age', this.state.age)}
- if(this.state.size){data.append('size', this.state.size)}
- if(this.state.description){data.append('description', this.state.description)}
+ if(this.state.imageURL){data.append('upload', this.state.imageURL)}
+ if(this.state.name){data.append('name', this.state.name)}
+ if(this.state.about){data.append('about', this.state.about)}
axios.put(`https://animal-hello-3000.codio-box.uk/api/v1/dogs/${this.state.dogID}`, data, {
auth: {
- username: 'daniel',
- password: 'abc'
+ username: 'joe',
+ password: '1234'
},
headers: {
'content-type': 'multipart/form-data'
@@ -88,18 +74,12 @@ class EditDog extends React.Component {
return (
+
-
+
-
-
-
-
-
diff --git a/src/components/home.js b/src/components/home.js
index c026eee..fc2abaa 100644
--- a/src/components/home.js
+++ b/src/components/home.js
@@ -16,14 +16,14 @@ function Home(props) {
return (
diff --git a/src/components/messages.js b/src/components/messages.js
index 22d56ea..9407d2b 100644
--- a/src/components/messages.js
+++ b/src/components/messages.js
@@ -1,11 +1,45 @@
-import React from 'react';
+import react, { useContext } from 'react'
+import {Form, Input, Button} from 'antd'
+import { Redirect } from 'react-router-dom'
+import {status,json} from '../utilities/requestHandlers'
+import UserContext from '../contexts/user'
+const { TextArea } = Input
+// Form formating :
+const formItemLayout = {
+ labelCol: { xs: { span: 24 }, sm: { span: 6 } },
+ wrapperCol: { xs: { span: 24 }, sm: { span: 12 } }
+ }
+const tailFormItemLayout = {
+wrapperCol: { xs: { span: 24, offset: 0 }, sm: { span: 16, offset: 6 } },
+}
+function _onFinish(values) {
+ const {msg}=values
+ console.log(`Recieved values ${values}`)
+}
+/**
+ * Contact form regarding specifique a lisiting
+ */
function Messages(props) {
- return (
- <>
- This is where the messages page is displayed
- >
- );
+ const context = useContext(UserContext)
+ console.log(context)
+ const _form =(
+
+
+
+
+ Contact
+ {/* {buttons} */}
+
+
+ )
+ return(
+
+ )
}
export default Messages;
\ No newline at end of file
diff --git a/src/components/nav.js b/src/components/nav.js
index 500c1ba..92fecdc 100644
--- a/src/components/nav.js
+++ b/src/components/nav.js
@@ -6,6 +6,7 @@ import UserContext from '../contexts/user';
function Nav(props) {
const context = useContext(UserContext);
+ //Change the new dog section for admins only!!
return (
<>
@@ -15,7 +16,7 @@ function Nav(props) {
Register
Messages
Account
- Add Dog
+ Add Dog
Logout
>
diff --git a/src/components/newDog.js b/src/components/newDog.js
index fd1966e..d9ae760 100644
--- a/src/components/newDog.js
+++ b/src/components/newDog.js
@@ -25,46 +25,32 @@ class NewDog extends React.Component {
}
handleBreedChange=event=>{
this.setState({
- breed: event.target.value
+ name: event.target.value
})
}
handleAgeChange=event=>{
this.setState({
- age: event.target.value
+ about: event.target.value
})
}
-
- handleSizeChange=event=>{
- this.setState({
- size: event.target.value
- })
- }
-
- handleDescriptionChange=event=>{
- this.setState({
- description: event.target.value
- })
- }
-
+
handleImageChange=event=>{
this.setState({
- selectedFile: event.target.files[0],
+ imageURL: event.target.files[0],
loaded: 0,
})
}
onClickHandler = () => {
const data = new FormData()
- data.append('upload', this.state.selectedFile)
- data.append('breed', this.state.breed)
- data.append('age', this.state.age)
- data.append('size', this.state.size)
- data.append('description', this.state.description)
+ data.append('upload', this.state.imageURL)
+ data.append('name', this.state.name)
+ data.append('about', this.state.about)
axios.post("https://animal-hello-3000.codio-box.uk/api/v1/dogs", data, {
auth: {
- username: 'daniel',
- password: 'abc'
+ username: 'joe',
+ password: '1234'
},
headers: {
'content-type': 'multipart/form-data'
@@ -79,18 +65,12 @@ class NewDog extends React.Component {
return (
+
-
+
-
-
-
-
-