Skip to content

Commit

Permalink
Changed application card layout
Browse files Browse the repository at this point in the history
novaisea committed Jun 26, 2021
1 parent 15a660d commit 8134ce6
Showing 8 changed files with 24 additions and 37 deletions.
13 changes: 4 additions & 9 deletions src/components/application.js
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 4 additions & 1 deletion src/components/applicationcard.js
Original file line number Diff line number Diff line change
@@ -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 {
<Link to={`/application/${applicationID}`}>
<Card
style={{ width: 320, textAlign: "center", paddingTop: "50px"}}
cover={<p> {`${companyName}`}</p>}
cover={<NavImage src={this.props.imageURL} to={`/applications/${applicationID}`} />}
hoverable={true}>

<Meta title={this.props.companyName} description={this.props.status} />
</Card>
</Link>
);
16 changes: 4 additions & 12 deletions src/components/applicationsForUsers.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion src/components/home.js
Original file line number Diff line number Diff line change
@@ -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)
}

3 changes: 1 addition & 2 deletions src/components/homegrid.js
Original file line number Diff line number Diff line change
@@ -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 {

3 changes: 1 addition & 2 deletions src/components/login.js
Original file line number Diff line number Diff line change
@@ -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{
13 changes: 6 additions & 7 deletions src/components/nav.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
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 {

static contextType = UserContext;

//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 (
<>
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
<Menu.Item key="1" disabled={!this.context.user.loggedIn}><Link to="/">Home</Link></Menu.Item>
<Menu.Item key="8" disabled={!this.context.user.loggedIn}><Link to={`/myapplication/${window.$name}`}>App</Link></Menu.Item>
<Menu.Item key="8" disabled={!this.context.user.loggedIn}><Link to={`/myapplication/${id_user}`}>App</Link></Menu.Item>
<Menu.Item key="2" disabled={this.context.user.loggedIn}><Link to="/login">Login</Link></Menu.Item>
<Menu.Item key="3" disabled={this.context.user.loggedIn}><Link to="/register">Register</Link></Menu.Item>
<Menu.Item key="4" disabled={!this.context.user.loggedIn}><Link to="/messages">Messages</Link></Menu.Item>
6 changes: 3 additions & 3 deletions src/components/newApplication.js
Original file line number Diff line number Diff line change
@@ -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 => {

0 comments on commit 8134ce6

Please sign in to comment.