Skip to content
Open
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
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

34 changes: 16 additions & 18 deletions admin-panel/src/App.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React, { Component } from 'react'
import {Route} from 'react-router-dom'
import Auth from './components/routes/auth'
import Admin from './components/routes/Admin'
import ProtectedRoute from './components/common/ProtectedRoute'
import React, { Component } from "react";
import { Route } from "react-router-dom";
import Auth from "./components/routes/auth";
import Admin from "./components/routes/Admin";
import ProtectedRoute from "./components/common/ProtectedRoute";

class App extends Component {
static propTypes = {
static propTypes = {};

};

render() {
return (
<div>
<h1>Hello world</h1>
<Route path='/auth' component={Auth}/>
<ProtectedRoute path='/admin' component={Admin}/>
</div>
)
}
render() {
return (
<div>
<h1>Hello world</h1>
<Route path="/auth" component={Auth} />
<ProtectedRoute path="/admin" component={Admin} />
</div>
);
}
}

export default App
export default App;
36 changes: 17 additions & 19 deletions admin-panel/src/Root.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import React, { Component } from 'react'
import {ConnectedRouter as Router} from 'react-router-redux'
import {Provider} from 'react-redux'
import App from './App'
import store from './redux'
import history from './history'
import React, { Component } from "react";
import { ConnectedRouter as Router } from "react-router-redux";
import { Provider } from "react-redux";
import App from "./App";
import store from "./redux";
import history from "./history";

class Root extends Component {
static propTypes = {
static propTypes = {};

};

render() {
return (
<Provider store={store}>
<Router history={history}>
<App />
</Router>
</Provider>
)
}
render() {
return (
<Provider store={store}>
<Router history={history}>
<App />
</Router>
</Provider>
);
}
}

export default Root
export default Root;
46 changes: 22 additions & 24 deletions admin-panel/src/components/auth/SignInForm.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import React, { Component } from 'react'
import {reduxForm, Field} from 'redux-form'
import React, { Component } from "react";
import { reduxForm, Field } from "redux-form";

class SignInForm extends Component {
static propTypes = {
static propTypes = {};

};

render() {
return (
<div>
<h3>Sign In</h3>
<form onSubmit={this.props.handleSubmit}>
<div>
email: <Field name='email' component='input'/>
</div>
<div>
password: <Field name='password' component='input' type='password'/>
</div>
<input type='submit' />
</form>

</div>
)
}
render() {
return (
<div>
<h3>Sign In</h3>
<form onSubmit={this.props.handleSubmit}>
<div>
email: <Field name="email" component="input" />
</div>
<div>
password:{" "}
<Field name="password" component="input" type="password" />
</div>
<input type="submit" />
</form>
</div>
);
}
}

export default reduxForm({
form: 'auth'
})(SignInForm)
form: "auth",
})(SignInForm);
69 changes: 34 additions & 35 deletions admin-panel/src/components/auth/SignUpForm.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
import React, { Component } from 'react'
import {reduxForm, Field} from 'redux-form'
import validator from 'email-validator'
import ErrorField from '../common/ErrorField'
import React, { Component } from "react";
import { reduxForm, Field } from "redux-form";
import validator from "email-validator";
import ErrorField from "../common/ErrorField";

class SignUpForm extends Component {
static propTypes = {

};

render() {
return (
<div>
<h3>Sign In</h3>
<form onSubmit={this.props.handleSubmit}>
<div>
email: <Field name='email' component={ErrorField}/>
</div>
<div>
password: <Field name='password' component={ErrorField} type='password'/>
</div>
<input type='submit' />
</form>

</div>
)
}
static propTypes = {};

render() {
return (
<div>
<h3>Sign In</h3>
<form onSubmit={this.props.handleSubmit}>
<div>
email: <Field name="email" component={ErrorField} />
</div>
<div>
password:{" "}
<Field name="password" component={ErrorField} type="password" />
</div>
<input type="submit" />
</form>
</div>
);
}
}

const validate = ({ email, password }) => {
const errors = {}
const errors = {};

if (!email) errors.email = 'email is a required field'
if (email && !validator.validate(email)) errors.email = 'incorrect email format'
if (!email) errors.email = "email is a required field";
if (email && !validator.validate(email))
errors.email = "incorrect email format";

if (!password) errors.password = 'password is a required field'
if (password && password.length < 8) errors.password = 'password is to short'
if (!password) errors.password = "password is a required field";
if (password && password.length < 8) errors.password = "password is to short";

return errors
}
return errors;
};

export default reduxForm({
form: 'auth',
validate
})(SignUpForm)
form: "auth",
validate,
})(SignUpForm);
29 changes: 14 additions & 15 deletions admin-panel/src/components/common/ErrorField.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, { Component } from 'react'
import React, { Component } from "react";

class ErrorField extends Component {
static propTypes = {
static propTypes = {};

};

render() {
const {input, meta: { error, touched }, type} = this.props
const errorMessage = error && touched && <h4 style={{color: 'red'}}>{error}</h4>
return (
<div>
<input {...input} type={type} />
{errorMessage}
</div>
)
}
render() {
const { input, meta: { error, touched }, type } = this.props;
const errorMessage = error &&
touched && <h4 style={{ color: "red" }}>{error}</h4>;
return (
<div>
<input {...input} type={type} />
{errorMessage}
</div>
);
}
}

export default ErrorField
export default ErrorField;
43 changes: 25 additions & 18 deletions admin-panel/src/components/common/ProtectedRoute.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import React, { Component } from 'react'
import {Route} from 'react-router-dom'
import {connect} from 'react-redux'
import {userSelector} from '../../ducks/auth'
import React, { Component } from "react";
import { Route } from "react-router-dom";
import { connect } from "react-redux";
import { userSelector } from "../../ducks/auth";

class ProtectedRoute extends Component {
static propTypes = {
static propTypes = {};

};
render() {
const { component, authorized, ...rest } = this.props;
return <Route {...rest} render={this.renderAuthorized} />;
}

render() {
const {component, authorized, ...rest} = this.props
return <Route {...rest} render = {this.renderAuthorized}/>
}

renderAuthorized = ({match}) => {
// const {authorized, ...rest} = this.props
return this.props.authorized ? <this.props.component match = {match} /> : <h1>UnAuthorized</h1>
}
renderAuthorized = ({ match }) => {
// const {authorized, ...rest} = this.props
return this.props.authorized ? (
<this.props.component match={match} />
) : (
<h1>UnAuthorized</h1>
);
};
}

export default connect(state => ({
authorized: userSelector(state)
}), null, null, {pure: false})(ProtectedRoute)
export default connect(
state => ({
authorized: userSelector(state),
}),
null,
null,
{ pure: false },
)(ProtectedRoute);
Loading