Commit c169b52d authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'didam' into 'master'

login

See merge request !36
parents 6ae20bb0 4fddb389
...@@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles'; ...@@ -5,6 +5,7 @@ import { withStyles } from '@material-ui/core/styles';
import Visibility from '@material-ui/icons/Visibility'; import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff'; import VisibilityOff from '@material-ui/icons/VisibilityOff';
import api from '../api'; import api from '../api';
import Constant from '../library/Constant';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -40,14 +41,14 @@ class Login extends Component { ...@@ -40,14 +41,14 @@ class Login extends Component {
"username": this.state.username, "username": this.state.username,
"password": this.state.password "password": this.state.password
} }
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.props.history.replace('/home') this.props.history.push('/home/beranda')
// console.log(response.data) localStorage.setItem(Constant.TOKEN, response.data.data.token)
} else { } else {
alert("Oops Incorrect Username or Password!") alert(response.data.message)
} }
}) })
} }
render() { render() {
......
...@@ -4,14 +4,23 @@ import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/ ...@@ -4,14 +4,23 @@ import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/
import SearchIcon from '@material-ui/icons/Search'; import SearchIcon from '@material-ui/icons/Search';
import Images from "../../assets/Images"; import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import AddRole from './UserRole/AddRole';
import EditRole from './UserRole/EditRole'
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions(); const options = ct.customOptions();
export default class User extends Component { export default class User extends Component {
constructor(props) {
super(props)
this.state = {
add: false,
edit: false
}
}
render() { render() {
const columns = ["#", "Nama Perusahaan", "Revisi", "Status", { const columns = [{
name: "Action", name: "Action",
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
...@@ -21,19 +30,9 @@ export default class User extends Component { ...@@ -21,19 +30,9 @@ export default class User extends Component {
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent',
}}
onClick={() => null}
>
<img src={Images.editCopy2} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}} }}
onClick={() => null} onClick={() => this.setState({edit: true})}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
...@@ -41,13 +40,35 @@ export default class User extends Component { ...@@ -41,13 +40,35 @@ export default class User extends Component {
); );
} }
} }
}] }, {
name: "ID",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 50 }}>
{val}
</div >
);
}
}
}, {
name: "User Role",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 250 }}>
{val}
</div >
);
}
}
}, "Hak Akses", "Status"]
const data = [ const data = [
["1", "TRIPUTRA AGRO PERSADA", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"], ["1", "1", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
["2", "DAYA GROUP", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"], ["2", "2", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
["3", "PUNINAR INFINITE RAYA", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"], ["3", "3", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
["4", "DHARMA GROUP", "Laporan Bulanan - September 2020", "0 (20 Oktober 2020)", "Belum Disetujui"], ["4", "4", "Laporan Bulanan - September 2020", "0 (20 Oktober 2020)", "Belum Disetujui"],
["5", "PUNINAR INFINITE RAYA", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"], ["5", "5", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
] ]
return ( return (
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
...@@ -55,10 +76,16 @@ export default class User extends Component { ...@@ -55,10 +76,16 @@ export default class User extends Component {
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} /> <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', width: '20%' }}>Master Data - Role & Otorisasi</label> <label style={{ color: 'white', width: '20%', alignSelf: 'center'}}>Master Data - Role & Otorisasi</label>
<label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> <div style={{width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5, flexDirection: 'row', display: 'flex'}}>
<SearchIcon/>
<input type="text" style={{flexGrow: 1, marginLeft: 10}}/>
</div>
</div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}> <div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<img src={Images.add} /> <img src={Images.add} onClick={() => this.setState({add: true})}/>
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -69,9 +96,10 @@ export default class User extends Component { ...@@ -69,9 +96,10 @@ export default class User extends Component {
options={options} options={options}
/> />
</MuiThemeProvider> </MuiThemeProvider>
</div> </div>
</div> </div>
{this.state.add && <AddRole/>}
{this.state.edit && <EditRole/>}
</div> </div>
); );
} }
......
const Constant = {
TOKEN: 'TOKEN',
USER: null,
}
export default Constant;
\ No newline at end of file
...@@ -14,6 +14,7 @@ import Screen404 from '../container/Screen404' ...@@ -14,6 +14,7 @@ import Screen404 from '../container/Screen404'
import ForgotPassword from '../container/ForgotPassword' import ForgotPassword from '../container/ForgotPassword'
import ResetPassword from '../container/ResetPassword' import ResetPassword from '../container/ResetPassword'
import EmailVerification from "../container/EmailVerification"; import EmailVerification from "../container/EmailVerification";
import Constant from "../library/Constant";
// This site has 3 pages, all of which are rendered // This site has 3 pages, all of which are rendered
// dynamically in the browser (not server rendered). // dynamically in the browser (not server rendered).
// //
...@@ -35,12 +36,16 @@ export default function BasicExample() { ...@@ -35,12 +36,16 @@ export default function BasicExample() {
}} }}
/> />
</Route> </Route>
<Route path="/login" component={Login} /> <Route path="/login" component={Login}/>
{/* <Login/>
</PrivateRoute> */}
<Route path="/forgot-password" component={ForgotPassword} /> <Route path="/forgot-password" component={ForgotPassword} />
<Route path="/reset-password" component={ResetPassword} /> <Route path="/reset-password" component={ResetPassword} />
<Route path="/email-verification" component={EmailVerification} /> <Route path="/email-verification" component={EmailVerification} />
<Route path="/register" component={Register}/> <Route path="/register" component={Register}/>
<PrivateRoute path="/home" component={Home} /> <PrivateRoute path="/home">
<Home/>
</PrivateRoute>
<Route path="*"> <Route path="*">
<Screen404 /> <Screen404 />
</Route> </Route>
...@@ -50,20 +55,21 @@ export default function BasicExample() { ...@@ -50,20 +55,21 @@ export default function BasicExample() {
} }
function PrivateRoute({ children, ...rest }) { function PrivateRoute({ children, ...rest }) {
const logged = localStorage.getItem(Constant.TOKEN) == 'TOKEN'? false : true
return ( return (
<Route <Route
{...rest} {...rest}
render={({ location }) => render={({ location }) =>
// fakeAuth.isAuthenticated ? ( logged ? (
// children children
// ) : ( ) : (
<Redirect <Redirect
to={{ to={{
pathname: "/login", pathname: "/login",
// state: { from: location } state: { from: location }
}} }}
/> />
// ) )
} }
/> />
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment