diff --git a/public/index.html b/public/index.html
index f5b5090..288f0bb 100644
--- a/public/index.html
+++ b/public/index.html
@@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
-
Dog Shelter
+ Trading License Department
diff --git a/src/components/.newApplication.js.swp b/src/components/.newApplication.js.swp
new file mode 100644
index 0000000..99d8995
Binary files /dev/null and b/src/components/.newApplication.js.swp differ
diff --git a/src/components/application.js b/src/components/application.js
index 2086539..d23ace2 100644
--- a/src/components/application.js
+++ b/src/components/application.js
@@ -1,10 +1,10 @@
import React from 'react';
import { withRouter } from 'react-router';
-import { Image, Row, Col, Typography, Space, Button } from 'antd'
-import ApplicationIcon from './applicationicon';
+import { Image, Row, Col, Typography, Space, Button } from 'antd';
import { status, json } from '../utilities/requestHandlers';
import UserContext from '../contexts/user';
+import {useContext} from 'react';
const { Title, Paragraph } = Typography;
@@ -22,8 +22,15 @@ class Application extends React.Component {
componentDidMount() {
const id = this.props.match.params.id; // available using withRouter()
-
- fetch(`https://animal-hello-3000.codio-box.uk/api/v1/applications/${id}`)
+ const username = this.context.user.username
+ const password = this.context.user.password
+ const url = "https://animal-hello-3000.codio-box.uk/api/v1/applications/${id}"
+ fetch(url, {
+ method: "GET",
+ headers: {
+ "Authorization": "Basic " + btoa(username + ":" + password)
+ },
+ })
.then(status)
.then(json)
.then(application => {
@@ -60,19 +67,13 @@ class Application extends React.Component {
//Error Here!! Change the user.role to a valid verification
let adminSpace =
- if(this.context.user.loggedIn){
if(this.context.user.loggedIn){
adminSpace =
- }
}
- if (!application) {
- return
Loading applications...
- }
-
return( //add {adminSpace} here
@@ -84,7 +85,7 @@ class Application extends React.Component {
Company Registration Number: {application.crn}Address: {application.address}Email: {application.email}
- Funded in: {application.dateFunded}
+ Founded in: {application.dateFunded}Created In: {application.dateCreated}Status: {application.status}
diff --git a/src/components/applicationcard.js b/src/components/applicationcard.js
index 944528c..e40bf22 100644
--- a/src/components/applicationcard.js
+++ b/src/components/applicationcard.js
@@ -1,6 +1,5 @@
import React from 'react';
import { Card } from 'antd';
-import ApplicationIcon from './applicationicon';
import NavImage from './navimage';
import {Link} from "react-router-dom";
diff --git a/src/components/applicationicon.js b/src/components/applicationicon.js
deleted file mode 100644
index 09f9905..0000000
--- a/src/components/applicationicon.js
+++ /dev/null
@@ -1,90 +0,0 @@
-import React from 'react';
-
-import LikeOutlined from '@ant-design/icons/LikeOutlined';
-import LikeFilled from '@ant-design/icons/LikeFilled';
-
-import { status, json } from '../utilities/requestHandlers';
-
-/**
- * @typedef {"filled" | "outlined"} theme
- * @typedef {"like"} iconType
- */
-
-/**
- * Determine the icon to be displayed
- *
- * @param {theme} theme - design of icon
- * @param {iconType} iconType - icon to show
- * @returns {Object} - the correct Ant Design icon component
- */
-function getIcon (theme, iconType) {
- let Icon;
-
- if (theme === 'filled') {
- Icon = LikeFilled
- } else if (theme === 'outlined') {
- Icon = LikeOutlined
- }
- return Icon;
-}
-
-class ApplicationIcon extends React.Component {
- constructor(props){
- super(props);
- this.state = {
- selected: props.selected,
- count: 0
- };
- this.onClick = this.onClick.bind(this);
- }
-
- onClick(){
- if (this.props.viewOnly) {
- console.log('This icon is view only: preventing update');
- return;
- }
- //reverse the selected state with every click
- this.setState({selected: !this.state.selected});
- }
-
- componentDidMount() {
- if (!this.props.countLink) return; // prevent fetch on parent mount
- fetch(this.props.countLink)
- .then(status)
- .then(json)
- .then(count => {
- this.setState({count:count})
- })
- .catch(err => {
- console.log(`${this.props.type} icon error for application ${this.props.id}`)
- });
- }
-
- componentDidUpdate(prevProps, prevState){
- if (prevState.selected !== this.state.selected) {
- //run the handler passed in by the parent component
- this.props.handleToggle(this.state.selected);
- }
- }
-
- render(){
- const theme = this.state.selected ? 'filled' : 'outlined';
- const iconType = this.props.type;
- const Icon = getIcon(theme, iconType);
-
- //return a span that contains the desired icon
- //and a space then the counter
- //if the icon is clicked we will run onClick handler
-
- return (
-
-
- {this.state.count}
-
- );
- }
-}
-
-export default ApplicationIcon;
diff --git a/src/components/editApplication.js b/src/components/editApplication.js
index f881180..af8b668 100644
--- a/src/components/editApplication.js
+++ b/src/components/editApplication.js
@@ -1,4 +1,4 @@
-import {Form, Input, Button, Row,Col} from 'antd'
+import {Form, Input, Button, Row, Col, Select} from 'antd'
import { Redirect } from 'react-router-dom'
import {status,json} from '../utilities/requestHandlers'
import UserContext from '../contexts/user'
@@ -15,8 +15,7 @@ class EditApplication extends React.Component{
constructor(props){
super(props)
this.state={
- imageURL:null,
- redirect:null
+ imageURL:null
}
this._onFinish =this._onFinish.bind(this)
this._onCancel =this._onCancel.bind(this)
@@ -41,26 +40,25 @@ class EditApplication extends React.Component{
values={companyName:companyName,crn:crn,address:address,email:email,dateFunded:dateFunded}
console.log("Befpre IF -statement ")
console.log(values)
- //Change listing_to_update for the one used in the TLD backend
- values.id=this.context.Listing_to_update.ID
+ values.id=this.context.ID
if (!companyName===true) {
- values.companyName=this.context.Listing_to_update.companyName
+ values.companyName=this.context.companyName
}
if (!crn===true) {
- values.crn=this.context.Listing_to_update.crn
+ values.crn=this.context.crn
}
if (!address===true) {
- values.address=this.context.Listing_to_update.address
+ values.address=this.context.address
}
if (!email===true) {
- values.email=this.context.Listing_to_update.email
+ values.email=this.context.email
}
if (!dateFunded===true) {
- values.dateFunded=this.context.Listing_to_update.dateFunded
+ values.dateFunded=this.context.dateFunded
}
console.log("after if statement")
console.log(values)
- this.context.updateListing(values)
+ this.context.application(values)
const formData= new FormData
formData.append('id',values.id)
@@ -69,8 +67,8 @@ class EditApplication extends React.Component{
formData.append('address',values.address)
formData.append('email',values.email)
formData.append('dateFunded',values.dateFunded)
- if (this.state.upload) {
- formData.append('upload',this.state.upload,this.state.upload.name)
+ if (this.state.imageURL) {
+ formData.append('imageURL',this.state.imageURL)
}
@@ -84,40 +82,44 @@ class EditApplication extends React.Component{
.then(status)
.then(json)
.then(()=>{
- this.setState({redirect:`/{this.context.Listing_to_update.id}`})
- alert("Successfully updated listing")
+ this.setState({redirect:`/{this.context.id}`})
+ alert("Successfully updated application")
})
.catch(console.error())
}
render(){
- if (this.state.redirect) {
- return
- }
return(
<>