diff --git a/src/components/account.js b/src/components/account.js index 96f5cb2..332510d 100644 --- a/src/components/account.js +++ b/src/components/account.js @@ -18,10 +18,10 @@ function Account(props) { const [profile, setProfile] = React.useState({}); if (!user.loggedIn) { - alert("Please log in") +

Please login in order to see your account details

} - if (!profile.username) { + else if (!profile.username) { let headers = new Headers(); headers.append('Authorization', 'Basic ' + btoa(user.username + ":" + user.password)); diff --git a/src/components/admin.js b/src/components/admin.js index c25fd08..dcc2bc1 100644 --- a/src/components/admin.js +++ b/src/components/admin.js @@ -47,4 +47,4 @@ function Admin(props) { ); } -export default Admin; +export default Admin; \ No newline at end of file diff --git a/src/components/application.js b/src/components/application.js index 9fbe510..18da15f 100644 --- a/src/components/application.js +++ b/src/components/application.js @@ -144,8 +144,8 @@ render() { Created In: {application.dateCreated} Status: {application.status}
- - @@ -170,4 +170,4 @@ render() { } } -export default withRouter(Application); +export default withRouter(Application); \ No newline at end of file diff --git a/src/components/applicationcard.js b/src/components/applicationcard.js index 1abcf3b..ae8d606 100644 --- a/src/components/applicationcard.js +++ b/src/components/applicationcard.js @@ -10,7 +10,6 @@ class ApplicationCard extends React.Component { /** Renders all the structure with the data using the application ID */ render() { const imagesrc = "https://animal-hello-3000.codio-box.uk/api/v1/applications" + this.props.image - console.log(this.props.image) const applicationID = this.props.ID; const companyName = this.props.companyName return ( @@ -27,4 +26,4 @@ class ApplicationCard extends React.Component { } } -export default ApplicationCard; +export default ApplicationCard; \ No newline at end of file diff --git a/src/components/homegrid.js b/src/components/homegrid.js index 46b1fe6..9c520c9 100644 --- a/src/components/homegrid.js +++ b/src/components/homegrid.js @@ -54,8 +54,6 @@ class HomeGrid extends React.Component { return (

You have to be a user in order to see applications!

) - }if (!this.state.application) { - return

Loading application...

}else { const applicationList = this.state.applications.map(application => { return ( diff --git a/src/components/login.js b/src/components/login.js index 12c5d97..e6a749b 100644 --- a/src/components/login.js +++ b/src/components/login.js @@ -56,7 +56,6 @@ class LoginForm extends React.Component { .then(json) .then(user => { console.log('Logged in successfully'); - console.log(user); user.password = password; // store in context for future API calls this.context.login(user); alert('Hello ' + username + '!') diff --git a/src/components/nav.js b/src/components/nav.js index 1098a81..921a10c 100644 --- a/src/components/nav.js +++ b/src/components/nav.js @@ -12,23 +12,37 @@ class Nav extends React.Component { static contextType = UserContext; render() { - return ( - <> -
- + if (this.context.user.loggedIn) { + if (this.context.user.role!="user") { + return ( + + Admin + Account + Chat + Logout + + ) + }if (this.context.user.role!="admin") { + return( + + My Application + Add Application + Account + Chat + Logout + + ) + } + }else{ + return( + Home Login Register - Account - My Application - Add Application - Chat - Admin - Logout - - - ) - }; + + ) + } +} }; export default Nav; \ No newline at end of file diff --git a/src/components/newApplication.js b/src/components/newApplication.js index 0fc4856..3791a3a 100644 --- a/src/components/newApplication.js +++ b/src/components/newApplication.js @@ -2,6 +2,7 @@ import React from 'react'; import { status, json } from '../utilities/requestHandlers'; import { Form, Input, Button, Typography, DatePicker } from 'antd'; import UserContext from '../contexts/user'; +import { Link } from "react-router-dom"; const { Title } = Typography; @@ -11,7 +12,7 @@ const nameRule=[ {required:true,message:'Please type the name of the compnay.',whitespace:false, min:5,max:150} ] const crnRule=[ - {required:true, type:'number', message:'Please a valid company reference number.',whitespace:false, min:8,max:8} + {required:true, message:'Please a valid company reference number.',whitespace:false, min:8,max:8} ] const addressRule=[ {required:true,message:'Please enter the address where the company is located.',whitespace:false, min:5,max:32} @@ -60,8 +61,9 @@ class NewApplication extends React.Component { .then(status) .then(json) .then(data => { - this.setState({redirect:'/applications/myapplications'}); //Fix this to redirect to the application page!! - alert("Application added!") + console.log(data) + alert("Application added!") + this.setState({redirect:`/myapplication/${this.context.user.id}`}); }) .catch(err => { alert("Error occurred, try again!") @@ -114,6 +116,7 @@ class NewApplication extends React.Component { + diff --git a/src/components/register.js b/src/components/register.js index 23d386e..db92764 100644 --- a/src/components/register.js +++ b/src/components/register.js @@ -134,9 +134,7 @@ class RegistrationForm extends React.Component { - + );