diff --git a/src/components/application.js b/src/components/application.js index 89bc774..5a5d66e 100644 --- a/src/components/application.js +++ b/src/components/application.js @@ -1,20 +1,13 @@ import React from 'react'; import { withRouter } from 'react-router'; -import { Image, Row, Col, Typography, Space, Button, Form, Input } from 'antd'; +import { Image, Row, Col, Typography, Space, Button, Form } from 'antd'; import { status, json } from '../utilities/requestHandlers'; -import { Component } from 'react'; import Select from 'react-select'; import UserContext from '../contexts/user'; -import {useContext} from 'react'; const { Title, Paragraph } = Typography; -const formItemLayout = { - labelCol: { xs: { span: 24 }, sm: { span: 6 } }, - wrapperCol: { xs: { span: 24 }, sm: { span: 12 } } -}; - class Application extends React.Component { static contextType = UserContext; @@ -53,6 +46,8 @@ class Application extends React.Component { edit(values){ //Edit application if (this.context.user.loggedIn){ const id = this.props.match.params.id; + const username=this.context.user.username + const password=this.context.user.password console.log(values) const {status}=values values.userID=this.context.user.ID @@ -61,7 +56,7 @@ class Application extends React.Component { method: "PUT", body: data, headers:{ - "Authorization": "Basic " + btoa("andre" + ":" + "12345") + "Authorization": "Basic " + btoa(username + ":" + password) } }) .then(status) diff --git a/src/components/applicationcard.js b/src/components/applicationcard.js index a148406..84b41fa 100644 --- a/src/components/applicationcard.js +++ b/src/components/applicationcard.js @@ -1,5 +1,6 @@ import React from 'react'; import { Card } from 'antd'; +import NavImage from './navimage'; import {Link} from "react-router-dom"; const { Meta } = Card; @@ -15,8 +16,10 @@ class ApplicationCard extends React.Component { {`${companyName}`}

} + cover={} hoverable={true}> + +
); diff --git a/src/components/applicationsForUsers.js b/src/components/applicationsForUsers.js index 2d9a6d7..57aa1ed 100644 --- a/src/components/applicationsForUsers.js +++ b/src/components/applicationsForUsers.js @@ -1,26 +1,15 @@ import React from 'react'; import { withRouter } from 'react-router'; -import { Image, Row, Col, Typography, Space, Button, Form, Input } from 'antd'; +import { Image, Row, Col, Typography } from 'antd'; import { status, json } from '../utilities/requestHandlers'; -import { Component } from 'react'; -import Select from 'react-select'; -import ReactDOM from "react-dom"; - -import ApplicationCard from './applicationcard'; import UserContext from '../contexts/user'; -import {useContext} from 'react'; window.$name = "" const { Title, Paragraph } = Typography; -const formItemLayout = { - labelCol: { xs: { span: 24 }, sm: { span: 6 } }, - wrapperCol: { xs: { span: 24 }, sm: { span: 12 } } -}; - class ApplicationForUsers extends React.Component { static contextType = UserContext; @@ -46,6 +35,8 @@ class ApplicationForUsers extends React.Component { .then(json) .then(application => { window.$id = id; + const id_user = id; + module.exports ={id_user}; this.setState({application:application}) }) .catch(err => { @@ -85,4 +76,5 @@ render() { } + export default withRouter(ApplicationForUsers); diff --git a/src/components/home.js b/src/components/home.js index 299810d..fb86cf3 100644 --- a/src/components/home.js +++ b/src/components/home.js @@ -11,7 +11,7 @@ function Home(props) { const [search, setSearch] = useState(undefined); function searchHandler(value) { - console.log("setting query") + console.log("setting query" + value) setSearch(value) } diff --git a/src/components/homegrid.js b/src/components/homegrid.js index 489503e..695b524 100644 --- a/src/components/homegrid.js +++ b/src/components/homegrid.js @@ -1,10 +1,9 @@ import React from 'react'; -import { Col, Row ,Result, Button } from 'antd'; +import { Col, Row } from 'antd'; import ApplicationCard from './applicationcard'; import { status, json } from '../utilities/requestHandlers'; import { withRouter } from 'react-router-dom'; import UserContext from '../contexts/user'; -import {useContext} from 'react'; class HomeGrid extends React.Component { diff --git a/src/components/login.js b/src/components/login.js index 80cc8e0..ef09add 100644 --- a/src/components/login.js +++ b/src/components/login.js @@ -51,10 +51,9 @@ class LoginForm extends React.Component { console.log('Logged in successfully'); console.log(user); user.password = password; // store in context for future API calls - console.log(user.id); this.context.login(user); alert('Hello ' + username + '!') - if (username === "andre"){ + if (user.role === "admin"){ this.setState({redirect:'/'}); } else{ diff --git a/src/components/nav.js b/src/components/nav.js index dac7d1e..af9c950 100644 --- a/src/components/nav.js +++ b/src/components/nav.js @@ -1,13 +1,10 @@ import React from 'react'; -import {useContext} from 'react'; import { Menu } from 'antd'; import { Link } from "react-router-dom"; import UserContext from '../contexts/user'; import { withRouter } from 'react-router'; -import { status, json } from '../utilities/requestHandlers'; - -import ApplicationForUsers from './applicationsForUsers' +import ApplicationForUsers from './applicationsForUsers' //Not being used class Nav extends React.Component { @@ -15,14 +12,16 @@ class Nav extends React.Component { //Change the new application section for admins only!! render() { - const id = window.$id; - console.log(id) //Find value that corresponds to the userID of the application + const { id_user } = require('./applicationsForUsers.js') + //const id = window.$id; + //console.log(this.context.state.user) //Find value that corresponds to the userID of the application + console.log(this.context.user.id) return ( <>
Home - App + App Login Register Messages diff --git a/src/components/newApplication.js b/src/components/newApplication.js index 46e36cf..882b1d2 100644 --- a/src/components/newApplication.js +++ b/src/components/newApplication.js @@ -1,8 +1,7 @@ import React from 'react' import UserContext from '../contexts/user' -import { Form, Input, Button, Upload, Row,Col, DatePicker } from 'antd' +import { Form, Input, Button, Row,Col, DatePicker } from 'antd' import { status, json } from '../utilities/requestHandlers' -import { Redirect } from 'react-router-dom' const formItemLayout = { labelCol: { xs: { span: 24 }, sm: { span: 6 } }, @@ -77,8 +76,9 @@ class NewApplication extends React.Component{ }) .then(status) .then(json) - .then(()=>{ + .then(application=>{ alert("Successfully added new application") + this.setState({application:application}) this.setState({redirect:"/"})// change this to all users applications pages }) .catch(err => {