Skip to content

Commit

Permalink
Final changes
Browse files Browse the repository at this point in the history
novaisea committed Jul 5, 2021
1 parent efd0c16 commit 4594254
Showing 14 changed files with 33 additions and 231 deletions.
181 changes: 1 addition & 180 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.0",
"react-select": "^4.3.1",
"reactstrap": "^8.9.0",
"save": "^2.4.0",
"web-vitals": "^0.2.4"
},
13 changes: 1 addition & 12 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react';
import React from 'react';

import App from './App';

@@ -9,16 +10,4 @@ describe('App', () => {
expect(screen.getByRole('menu')).toBeInTheDocument();
});

test('allows search', () => {
render(<App />);

screen.debug();

fireEvent.change(screen.getByRole('textbox'), {
target: { value: 'JavaScript' },
});

screen.debug();
});

});
14 changes: 6 additions & 8 deletions src/components/account.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ import React from 'react';
import { withRouter } from 'react-router';
import { Image, Row, Col, Typography, Button, Form, Input } from 'antd';
import { status, json } from '../utilities/requestHandlers';
import { Link } from "react-router-dom";

import UserContext from '../contexts/user';

@@ -70,6 +69,11 @@ class Account extends React.Component {
.then(data => {
console.log(data);
alert("User Updated!")
if (this.context.user.role === "admin" ){
this.props.history.push('/adminSpace')
}else{
this.props.history.push('/')
}
})
.catch(errorResponse => {
console.log(errorResponse)
@@ -92,7 +96,7 @@ render() {
<div>
<Row type="flex" justify="space-around" align="middle">
<Col span={6} align="center">
<Image width={200} src={user.avatarURL} />
<Image width="70%" height="70%" src={user.avatarURL} />
</Col>
<Col span={12}>
<Title>{user.firstName} {user.lastName}</Title>
@@ -108,19 +112,13 @@ render() {
</Form.Item>
<Form.Item rules={[{required:false, message:'Input a valid last name', min:2}]} name="lastName" label="Last name:">
<Input />
</Form.Item>
<Form.Item rules={[{required:false, message:'Input a valid username', min:3}]} name="username" label="Username:">
<Input />
</Form.Item>
<Form.Item rules={[{required:false,type:'email', message:'Input a valid email'}]} name="email" label="Email:">
<Input />
</Form.Item>
<Form.Item name= "submit">
<Button type="primary" htmlType="submit">Change Details</Button>
</Form.Item>
<Form.Item>
<Button> <Link to ='/'>Reload</Link></Button>
</Form.Item>
</Form>
</Col>
<Col span={6} align="center">
7 changes: 2 additions & 5 deletions src/components/application.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@ import React from 'react';
import { withRouter } from 'react-router';
import { Image, Row, Col, Typography, Space, Button, Form, Select } from 'antd';
import { status, json } from '../utilities/requestHandlers';
import { Link } from "react-router-dom";

import UserContext from '../contexts/user';

@@ -73,6 +72,7 @@ class Application extends React.Component {
.then(data => {
console.log(data);
alert("Application Updated!")
this.props.history.push('/adminSpace')
})
.catch(errorResponse => {
console.log(errorResponse)
@@ -133,7 +133,7 @@ render() {
<div>
<Row type="flex" justify="space-around" align="middle">
<Col span={6} align="center">
<Image width={200} src={application.imageURL} />
<Image width="70%" height="70%" src={application.imageURL} />
</Col>
<Col span={12}>
<Title>{application.companyName}</Title>
@@ -154,9 +154,6 @@ render() {
<Form.Item name= "submit">
<Button type="primary" htmlType="submit">Edit Status</Button>
</Form.Item>
<Form.Item>
<Button> <Link to ='/adminSpace'>Reload</Link></Button>
</Form.Item>
</Form>
</Col>
<Col span={6} align="center">
5 changes: 2 additions & 3 deletions src/components/applicationcardAdmins.js
Original file line number Diff line number Diff line change
@@ -9,12 +9,11 @@ class ApplicationCard extends React.Component {

/** Renders all the structure with the data using the application ID */
render() {
const applicationID = this.props.ID;
return (
<Link to={`/application/${applicationID}`}>
<Link to={`/application/${this.props.ID}`}>
<Card
style={{ width: 320, textAlign: "center", paddingTop: "50px"}}
cover={<NavImage src={this.props.imageURL} to={`/applications/${applicationID}`} />}
cover={<NavImage src={this.props.imageURL} to={`/applications/${this.props.ID}`} />}
hoverable={true}>
<Meta title={this.props.companyName} description={this.props.status} />
</Card>
10 changes: 5 additions & 5 deletions src/components/applicationcardUsers.js
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@ import NavImage from './navimage';

const { Meta } = Card;

class ApplicationItem extends React.Component {
class ApplicationCard extends React.Component {

/** Renders the page using Application Card and filters the search query */
/** Renders all the structure with the data using the application ID */
render() {
return(
<Link to={'/myapplication/' + this.props.ID}>
<Link to={`/myapplication/${this.props.ID}`}>
<Card
style={{ width: 320, textAlign: "center", paddingTop: "50px"}}
cover={<NavImage src={this.props.imageURL} to={`/applications/${this.props.ID}`} />}
cover={<NavImage src={this.props.imageURL} to={`/myapplication/${this.props.ID}`} />}
hoverable={true}>
<Meta title={this.props.companyName} description={this.props.status} />
</Card>
@@ -22,4 +22,4 @@ class ApplicationItem extends React.Component {
}
}

export default ApplicationItem;
export default ApplicationCard;
7 changes: 3 additions & 4 deletions src/components/applicationsForUsers.js
Original file line number Diff line number Diff line change
@@ -26,10 +26,9 @@ class ApplicationForUsers extends React.Component {
* @returns {object} The data about the application that is associated to the user
*/
componentDidMount() {
const id = this.props.match.params.id; // available using withRouter()
const id = this.props.match.params.id;
const username = this.context.user.username
const password = this.context.user.password
const userid = this.context.user.ID
fetch(`https://animal-hello-3000.codio-box.uk/api/v1/applications/myapplications/${id}`, {
method: 'GET',
headers: {
@@ -42,7 +41,7 @@ class ApplicationForUsers extends React.Component {
this.setState({application:application})
})
.catch(err => {
console.log(`Fetch error for application ${userid}`)
console.log('Fetch error for application')
});
};

@@ -67,7 +66,7 @@ render() {
<div>
<Row type="flex" justify="space-around" align="middle">
<Col span={6} align="center">
<Image width={200} src={application.imageURL} />
<Image width="70%" height="70%" src={application.imageURL} />
</Col>
<Col span={12}>
<Title>{application.companyName}</Title>
3 changes: 2 additions & 1 deletion src/components/contact.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React from 'react';
import UserContext from '../contexts/user';
import { Typography, Button, Input } from 'antd';
import { withRouter } from 'react-router';
import emailjs from 'emailjs-com';


const { Title } = Typography;
const { TextArea } = Input;
@@ -25,6 +25,7 @@ class ContactForm extends React.Component {
*/
sendEmail(e){
e.preventDefault();
const emailjs = require("emailjs-com")

emailjs.sendForm('gmail', 'template_tld', e.target, 'user_4pQL25dW7YNzoZmVCML9j') //Details to identify the emailjs account and template
.then((result) => {
6 changes: 3 additions & 3 deletions src/components/newApplication.js
Original file line number Diff line number Diff line change
@@ -2,7 +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";
import { withRouter } from 'react-router';

const { Title } = Typography;

@@ -69,6 +69,7 @@ class NewApplication extends React.Component {
.then(data => {
console.log(data)
alert("Application added!")
this.props.history.push('/')
})
.catch(err => {
console.log(err)
@@ -124,7 +125,6 @@ class NewApplication extends React.Component {

<Form.Item {...tailFormItemLayout}>
<Button type="primary" htmlType="submit">Submit Application</Button>
<Button> <Link to ={`/`}>Click here to see your applications!</Link></Button>
</Form.Item>
</Form>

@@ -133,4 +133,4 @@ class NewApplication extends React.Component {
};
};

export default NewApplication;
export default withRouter(NewApplication);
6 changes: 3 additions & 3 deletions src/components/register.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Form, Input, Button, Typography } from 'antd';
import { status, json } from '../utilities/requestHandlers';
import { Link } from 'react-router-dom';
import { withRouter } from 'react-router';

const { Title } = Typography;

@@ -96,6 +96,7 @@ class RegistrationForm extends React.Component {
.then(data => {
console.log(data);
alert("User added!")
this.props.history.push('/login')
})
.catch(err => {
alert("Error adding user!");
@@ -143,11 +144,10 @@ class RegistrationForm extends React.Component {

<Form.Item {...tailFormItemLayout}>
<Button type="primary" htmlType="submit">Register</Button>
<Button> <Link to ='/login'>Login Here!</Link> </Button>
</Form.Item>
</Form>
);
};
};

export default RegistrationForm;
export default withRouter(RegistrationForm);
5 changes: 2 additions & 3 deletions src/components/usercard.js
Original file line number Diff line number Diff line change
@@ -9,12 +9,11 @@ class UserCard extends React.Component {

/** Renders all the structure with the data using the user ID */
render() {
const userID = this.props.ID;
return (
<Link to={`/user/${userID}`}>
<Link to={`/user/${this.props.ID}`}>
<Card
style={{ width: 320, textAlign: "center", paddingTop: "50px"}}
cover={<NavImage src={this.props.avatarURL} to={`/users/${userID}`} />}
cover={<NavImage src={this.props.avatarURL} to={`/users/${this.props.ID}`} />}
hoverable={true}>
<Meta title={this.props.username} description={this.props.email} />
</Card>
4 changes: 2 additions & 2 deletions src/components/usersgrid.js
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ class UsersGrid extends React.Component {
});
return (
<div style={{ padding: '3% 20%' }}>
<Search placeholder="Search by Company Name, Company Reference Number or Email"
<Search placeholder="Search by username or email"
allowClear
enterButton="Search"
size="large"
@@ -105,7 +105,7 @@ class UsersGrid extends React.Component {
return (
<div>
<div style={{ padding: '3% 20%' }}>
<Search placeholder="Search by Company Name, Company Reference Number or Email"
<Search placeholder="Search by username or email"
allowClear
enterButton="Search"
size="large"
2 changes: 1 addition & 1 deletion src/components/usersinfo.js
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ render() {
<div>
<Row type="flex" justify="space-around" align="middle">
<Col span={6} align="center">
<Image width={200} src={user.avatarURL} />
<Image width="50%" height="50%" src={user.avatarURL} />
</Col>
<Col span={12}>
<Title>{user.firstName} {user.lastName}</Title>

0 comments on commit 4594254

Please sign in to comment.