Skip to content

Commit

Permalink
Merge pull request #5 from ZHIFA-CHIU/238-MergeFrontBack
Browse files Browse the repository at this point in the history
238- Merging front and back end with axios handling
  • Loading branch information
ryan-a-git authored Apr 13, 2022
2 parents cb86a3d + a23f326 commit 08112c1
Show file tree
Hide file tree
Showing 25 changed files with 29,291 additions and 12 deletions.
2 changes: 2 additions & 0 deletions FrontEnd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
HELP.md
28,863 changes: 28,863 additions & 0 deletions FrontEnd/package-lock.json

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions FrontEnd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "roadside",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@mui/material": "^5.6.1",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.26.1",
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.2.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.0",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added FrontEnd/public/favicon.ico
Binary file not shown.
12 changes: 12 additions & 0 deletions FrontEnd/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Roadside Assitant Service</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
Binary file added FrontEnd/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FrontEnd/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions FrontEnd/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, {Component} from 'react';
import {BrowserRouter, Route, Routes} from 'react-router-dom';

import Home from './components/Home';
import About from './components/About';
import Contact from './components/Contact';
import ViewIncompleteRequest from './components/ViewIncompleteRequest';
import ViewCompleteRequest from './components/ViewCompleteRequest';
import Qualifications from './components/Qualifications';
import PaymentInfo from './components/PaymentInfo';
import Dashboard from './components/Dashboard';
import Login from './components/Login';
import CreateAccount from './components/CreateAccount';
import CustomerExample from "./components/CustomerExample";


import Error from './components/Error';
import Navigation from './components/navigation/Navigation';

class App extends Component {
render() {
return (
<BrowserRouter>
<div>
<Navigation/>
<Routes>
<Route path="/" element={<Home/>} exact/>
<Route path="/about" element={<About/>}/>
<Route path="/contact" element={<Contact/>}/>
<Route path="/ViewIncompleteRequest" element={<ViewIncompleteRequest/>}/>
<Route path="/ViewCompleteRequest" element={<ViewCompleteRequest/>}/>
<Route path="/Qualifications" element={<Qualifications/>}/>
<Route path="/PaymentInfo" element={<PaymentInfo/>}/>
<Route path="/Dashboard" element={<Dashboard/>}/>
<Route path="/Login" element={<Login/>}/>
<Route path="/CreateAccount" element={<CreateAccount/>}/>
<Route path="/CustomerExample" element={<CustomerExample/>}/>
<Route component={Error}/>
</Routes>
</div>
</BrowserRouter>
);
}
}

export default App;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/About.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const About = () => {
return (
<div>
<h1>About</h1>
<p>Contact US page body content</p>
</div>
);
}

export default About;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/Contact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const Contact = () => {
return (
<div>
<h1>Contact US</h1>
<p>Contact US page body content</p>
</div>
);
}

export default Contact;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/CreateAccount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const CreateAccount = () => {
return (
<div>
<h1>Create Account</h1>
<p>Contact US page body content</p>
</div>
);
}

export default CreateAccount;
54 changes: 54 additions & 0 deletions FrontEnd/src/components/CustomerExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, {useEffect, useState} from 'react';
import CustomerService from "../services/customerService";
import {Button, Paper, Typography} from "@mui/material";

/**
* CustomerExample component used to demonstrate backend call from frontend
* @returns {JSX.Element}
* @constructor
*/
const CustomerExample = () => {
const [response, setResponse] = useState([]);

useEffect(() => {
getCustomers();
}, []);

const getCustomers = () => {
CustomerService.getCustomerList()
.then(res => {
setResponse(res.data)
})
.catch((err) => {
console.error(err);
});
}

const deleteCustomer = (id) => {
CustomerService.deleteCustomer(id)
.then((res) => {
getCustomers();
})
.catch((err) => {
console.error(err);
});
}

return (<Paper>
<Typography variant={'h2'}>Customer List (Example)</Typography>
<div>
{response.map(customer => <div key={customer.id}>
<Typography variant={'h3'}>{customer.name}</Typography>
<div>Age: {customer.age}</div>
<div>Email: {customer.email}</div>
<Button onClick={() => {
deleteCustomer(customer.id);
getCustomers();
}}>Delete customer
</Button>
</div>)}
</div>
</Paper>);
}

export default CustomerExample;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/Dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const Dashboard = () => {
return (
<div>
<h1>Dashboard</h1>
<p>Contact US page body content</p>
</div>
);
}

export default Dashboard;
11 changes: 11 additions & 0 deletions FrontEnd/src/components/Error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

const Error = () => {
return (
<div>
<p>Error: Page does not exist!</p>
</div>
);
}

export default Error;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/Home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const home = () => {
return (
<div>
<h1>Welcome to Roadside Assitance</h1>
<p>Home page body content</p>
</div>
);
}

export default home;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/Login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const Login = () => {
return (
<div>
<h1>Login</h1>
<p>Contact US page body content</p>
</div>
);
}

export default Login;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/PaymentInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const PaymentInfo = () => {
return (
<div>
<h1>Payment Info</h1>
<p>Contact US page body content</p>
</div>
);
}

export default PaymentInfo;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/Qualifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const Qualifications = () => {
return (
<div>
<h1>Qualifications</h1>
<p>Contact US page body content</p>
</div>
);
}

export default Qualifications;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/ViewCompleteRequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const ViewCompleteRequest = () => {
return (
<div>
<h1>View Complete Requests</h1>
<p>Contact US page body content</p>
</div>
);
}

export default ViewCompleteRequest;
12 changes: 12 additions & 0 deletions FrontEnd/src/components/ViewIncompleteRequest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const ViewIncompleteRequest = () => {
return (
<div>
<h1>View Incomplete Requests</h1>
<p>Contact US page body content</p>
</div>
);
}

export default ViewIncompleteRequest;
39 changes: 39 additions & 0 deletions FrontEnd/src/components/navigation/Navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';

import {Link} from 'react-router-dom';
import styled from 'styled-components';


const StyledLink = styled(Link)`
color: Black;
text-decoration: none;
font-weight: Bold;
font-size: x-large;
margin: 0 10px;
`;

const CenterDiv = styled.div`
text-align:center;
`;

const Navigation = () => {
return (<CenterDiv>
<StyledLink to="/">Home</StyledLink>
<StyledLink to="/about">About</StyledLink>
<StyledLink to="/contact">Contact</StyledLink>
<StyledLink to="/ViewIncompleteRequest">ViewIncompleteRequest</StyledLink>
<StyledLink to="/ViewCompleteRequest">ViewCompleteRequest</StyledLink>
<StyledLink to="/Qualifications">Qualifications</StyledLink>
<StyledLink to="/PaymentInfo">PaymentInfo</StyledLink>
<StyledLink to="/Dashboard">Dashboard</StyledLink>
<StyledLink to="/Login">Login</StyledLink>
<StyledLink to="/CreateAccount">CreateAccount</StyledLink>
<StyledLink to="/CustomerExample">CustomerExample</StyledLink>

<hr></hr>
</CenterDiv>);
}

export default Navigation;
10 changes: 10 additions & 0 deletions FrontEnd/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
Loading

0 comments on commit 08112c1

Please sign in to comment.