Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/trthhrtz/ShareCity
Browse files Browse the repository at this point in the history
  • Loading branch information
asp437 committed Nov 24, 2018
2 parents 29bdb67 + 7981a72 commit b598d2a
Show file tree
Hide file tree
Showing 41 changed files with 616 additions and 580 deletions.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
Update later with project info.
## Steps to Setup the Spring Boot Back-end app

0. **Requirements**
```
Java 8+
Maven (or use Maven Wrapper bundled with application)
```
1. **Clone the application**
```bash
git clone https://github.com/trthhrtz/ShareCity.git
cd junction-bytom-app
```
2. **Create PostgreSQL database**
```
create database in postgresql bytom_app
```
3. **Create PSQL user**
```
login:bytom
password:bytom
```
Or change to desired in `bytomapp-server/src/main/java/application.properties`
4. **Run the app**
You can run the spring boot app by typing the following command -
```bash
mvn spring-boot:run
```
The server will start on port 5000.
5. **Add the default Roles**
The spring boot app uses role based authorization powered by spring security. Please execute the following sql queries in the database to insert the `USER` and `ADMIN` roles.
```sql
INSERT INTO bytom_app.roles (name) VALUES ('ROLE_USER');
INSERT INTO bytom_app.roles (name) VALUES ('ROLE_ADMIN');
INSERT INTO bytom_app.roles (name) VALUES ('ROLE_BUSINESS');
INSERT INTO bytom_app.roles (name) VALUES ('ROLE_STARTUP');
INSERT INTO bytom_app.roles (name) VALUES ('ROLE_CORPORATE');
```
Any new user who signs up to the app is assigned the `ROLE_USER` by default.
## Steps to Setup the React Front-end app
0. **Requirements**
```
node.js 10.13
```
1. **Go to the `bytom-app-client` folder**
```bash
cd bytom-app-client
```
2. **Use the following command to install the dependencies and start the application**
```bash
npm install && npm start
```
The front-end server will start on port `3000`.
2 changes: 1 addition & 1 deletion app-client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function changeCurrent(current) {

export const FETCH_BUSINESS = 'FETCH_BUSINESS';

export function fetchBusiness(props) {
export function fetchCorporation(props) {
const request = axios.post(`${API_BASE_URL}/business/`, props);

return {
Expand Down
15 changes: 8 additions & 7 deletions app-client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import NewPoll from '../poll/NewPoll';
import NewRequest from '../request/NewRequest';
import Login from '../user/login/Login';
import Signup from '../user/signup/Signup';
import LoginBusiness from '../business/login/LoginBusiness';
import SignupBusiness from '../business/signup/SignupBusiness';
import LoginCorporation from '../business/login/LoginCorporation';
import SignupCorporation from '../business/signup/SignupCorporation';
import Profile from '../user/profile/Profile';
import AppHeader from '../common/AppHeader';
import AppFooter from '../common/AppFooter';
Expand Down Expand Up @@ -83,7 +83,7 @@ class App extends Component {
this.props.history.push(redirectTo);

notification[notificationType]({
message: 'Polling App',
message: 'SHARE city',
description: description,
});
}
Expand All @@ -95,11 +95,12 @@ class App extends Component {
*/
async handleLogin() {
notification.success({
message: 'Polling App',
message: 'SHARE city',
description: "You're successfully logged in.",
});
await this.loadCurrentUser().then(() => {
if (this.state.currentUser && this.state.currentUser.roleName === 'ROLE_BUSINESS') {
// if (this.state.currentUser && this.state.currentUser.roleName === 'ROLE_BUSINESS') {
if (this.state.currentUser && true) {
this.props.history.push("/business/polls");
} else if (this.state.currentUser && this.state.currentUser.roleName === 'ROLE_USER') {
this.props.history.push(`/users/${this.state.currentUser.username}`);
Expand Down Expand Up @@ -134,9 +135,9 @@ class App extends Component {
<Route path="/test" component={NewRequest}>
</Route>
<Route path="/business/login"
render={(props) => <LoginBusiness onLogin={this.handleLogin} {...props} />}>
render={(props) => <LoginCorporation onLogin={this.handleLogin} {...props} />}>
</Route>
<Route path="/business/signup" component={SignupBusiness}>
<Route path="/business/signup" component={SignupCorporation}>
</Route>
<Route path="/users/:username"
render={(props) => <Profile isAuthenticated={this.state.isAuthenticated} currentUser={this.state.currentUser} {...props} />}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { Component } from 'react';
import { login } from '../../util/APIUtils';
import './LoginBusiness.css';
import './LoginCorporation.css';
import { Link } from 'react-router-dom';
import { ACCESS_TOKEN } from '../../constants';

import { Form, Input, Button, Icon, notification } from 'antd';
const FormItem = Form.Item;

class LoginBusiness extends Component {
class LoginCorporation extends Component {
render() {
const AntWrappedLoginForm = Form.create()(LoginForm)
return (
<div className="login-container">
<h1 className="page-title">Login Business</h1>
<h1 className="page-title">Login Corporation</h1>
<div className="login-content">
<AntWrappedLoginForm onLogin={this.props.onLogin} />
</div>
Expand All @@ -39,12 +39,12 @@ class LoginForm extends Component {
}).catch(error => {
if(error.status === 401) {
notification.error({
message: 'Polling App',
message: 'SHARE city',
description: 'Your Username or Password is incorrect. Please try again!'
});
} else {
notification.error({
message: 'Polling App',
message: 'SHARE city',
description: error.message || 'Sorry! Something went wrong. Please try again!'
});
}
Expand Down Expand Up @@ -90,4 +90,4 @@ class LoginForm extends Component {
}


export default LoginBusiness;
export default LoginCorporation;
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { Avatar, Tabs } from 'antd';
import { getAvatarColor } from '../../util/Colors';
import { formatDate } from '../../util/Helpers';
import LoadingIndicator from '../../common/LoadingIndicator';
import './ProfileBusiness.js.css';
import './ProfileCorporation.js.css';
import NotFound from '../../common/NotFound';
import ServerError from '../../common/ServerError';
import { store }from '../../index';
const TabPane = Tabs.TabPane;

class Profile extends Component {
class ProfileCorporation extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -102,7 +101,7 @@ class Profile extends Component {
className="profile-tabs">

{this.state.user && this.state.user.roleName === 'ROLE_BUSINESS' ? (
<TabPane tab={`${this.state.user.pollCount} Polls`} key="1">
<TabPane tab={`${this.state.user.pollCount} Requests`} key="1">
<PollList username={this.props.match.params.username} type="USER_CREATED_POLLS" />
</TabPane>) : null}

Expand All @@ -116,4 +115,4 @@ class Profile extends Component {
}
}

export default Profile;
export default ProfileCorporation;
Loading

0 comments on commit b598d2a

Please sign in to comment.