Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class App extends React.Component {
this.authenticationService = new AuthenticationService();
}



render() {
if (this.authenticationService.isAuthenticated()) {
return (
<div>
<MainPage />
<MainPage />
</div>
);
}
Expand Down
26 changes: 2 additions & 24 deletions src/components/loginComponents/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ class Register extends React.Component {
this.setState({
[event.target.name]: event.target.value,
badName: "",

badUsername: "",

badEmail: "",
badPass: "",
badSecondPass: "",
badName: ""
});

}

serverErrorHandler(e) {


this.setState({
badUsername: e.response.data.error.message
});
Expand All @@ -52,10 +48,8 @@ class Register extends React.Component {
const { username, name, email, password1, password2 } = this.state;

event.preventDefault();

if (name === "") { this.setState({ badName: "This field is required" }); return; }
if (username === "") { this.setState({ badUsername: "This field is required" }); return; }

if (!validateEmail(email)) { this.setState({ badEmail: "Email address is bad!" }); return; }
if (password1.length < 6) { this.setState({ badPass: "Password must be at least 6 characters long" }); return; }
if (password1 === password2) {
Expand All @@ -78,15 +72,13 @@ class Register extends React.Component {

const { name, email, password1, password2, username, badEmail, badPass, badSecondPass, badUsername, badName } = this.state;


return (
<div className="body-class">
<div className="outer__wrapper">
<div className="inner__wrapper--left">
<div className="h1__main-page">
<h1>REGISTER TO BITBOOK</h1>
</div>

<div className="p__main-page">
<p>
Beogradski institut za tehnologiju – BIT je škola za programiranje osnovana u Beogradu, s ciljem da svoje polaznike uči praktičnim i primenljivim znanjima u IT industriji. Tehnički deo programa je FrontEnd Stack, najčešće tražen od strane poslodavaca. Pored tehničkog obrazovanja, u BITu se uči i kako funkcioniše IT industrija i kako pronaći svoje mesto u njoj.
Expand Down Expand Up @@ -124,23 +116,9 @@ class Register extends React.Component {
</div>
<div style={{ "color": "red" }}> {badSecondPass} </div>
<button className="form-btn" onClick={this.onClickRegister} type="submit">Register</button>


</div>
<div className="field-wrap">

<input name="password1" type="text" value={password1} onChange={this.handleChange} placeholder="Password" />
</div>
<div style={{ "color": "red" }}> {badPass} </div>
<div className="field-wrap">

<input name="password2" type="text" value={password2} onChange={this.handleChange} placeholder="Repeat password" />
</div>
<div style={{ "color": "red" }}> {badSecondPass} </div>
<button onClick={this.onClickRegister} type="submit">Register</button>
</div>
</form>

</form>
</div>
</div>
</div>
</div>
Expand Down
15 changes: 10 additions & 5 deletions src/components/navMenu.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from "react";
import { Link } from "react-router-dom";
import MainFeedPage from "./mainFeedPage";
import comObj from "../services/communicationService";
// import PostPage from "./postPage";
import ProfilePage from "./profilePage";


class NavMenu extends React.Component {
constructor(props) {
super(props);

}

logout() {
comObj.clearID();

}

render() {

Expand All @@ -24,21 +29,21 @@ class NavMenu extends React.Component {
<ul>
<li>
<Link to="/mainFeedPage">
<a href="#" src=""><i className="fa fa-home" aria-hidden="true"></i> FEED</a>
FEED
</Link>
</li>
<li>
<Link to="/profilePage">
<a href="#" src="">PROFILE</a>
PROFILE
</Link>
</li>
<li>
<Link to="/postPage">
<a href="#" src="">POSTS</a>
POSTS
</Link>
</li>
<li>
<a href="#" src=""><i className="fa fa-sign-out" aria-hidden="true"></i> LOGOUT</a>
<Link to="/login" onClick={this.logout} ><i className="fa fa-sign-out" aria-hidden="true"></i> LOGOUT</Link>
</li>
</ul>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/profilePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import dataObj from "../services/dataService";
// MainPage = Feed Page

class ProfilePage extends React.Component {
Expand All @@ -7,6 +8,7 @@ class ProfilePage extends React.Component {
}

render() {
dataObj.getProfile();
return (
<div className="profile">
<div className="container">
Expand Down
16 changes: 8 additions & 8 deletions src/services/authenticationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import comObj from "./communicationService";
import { redirect } from "../components/redirect";
class AuthenticationService {
constructor() {

this.bindThisAndThats();
}
bindThisAndThats(){
bindThisAndThats() {
this.login = this.login.bind(this);
this.register = this.register.bind(this);
this.successLogin = this.successLogin.bind(this);
Expand All @@ -14,7 +14,7 @@ class AuthenticationService {
successLogin(a) {
comObj.setID(a.sessionId);
console.log(a);
// redirect("/");
redirect("/");
}
failLogin(a) {
console.log("Sranje si!");
Expand All @@ -23,15 +23,15 @@ class AuthenticationService {
login(dataObj) {
if (comObj.getID()) { alert("Vec postoji ulogovan korisnik"); return; }
comObj.post("login", dataObj, this.successLogin, this.failLogin);

}
successRegister(a){
successRegister(a) {
redirect("/");

}
failRegister(error){
failRegister(error) {
console.log(error.response.data.error.message);

}
register(dataObj, callbackFail) {
comObj.post("register", dataObj, this.succesRegister, callbackFail);
Expand Down
11 changes: 10 additions & 1 deletion src/services/dataService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import comObj from "./communicationService";
import ProfileDTO from "./profileDTO";
class DataService {
constructor(){

}
}

getProfile(callback, failCallback){
comObj.get("profile", a=> callback(new ProfileDTO(a)), a=> failCallback(a));
}
}

const dataObj = new DataService();

export default dataObj;
File renamed without changes.