Commit cd9bb020 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'syadziy' into 'master'

Syadziy

See merge request !141
parents 3cef8616 4e4caec8
...@@ -287,47 +287,51 @@ export default class AddUser extends Component { ...@@ -287,47 +287,51 @@ export default class AddUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<ul> <div>
{item.children.map((data, index) => { {item.children.length > 0 && (
return ( <ul>
// <li> {item.children.map((data, index) => {
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> return (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> // <li>
{R.isNil(data.children) ? <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
null <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
: {R.isNil(data.children) ?
data.children.length < 1 ? null
null :
: data.children.length < 1 ?
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> null
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
{this.state.role ? this.state.role.role_id === 1 ?
<CustomCheckboxDisabled
disabled={true}
checked={true}
// onChange={() => this.handleItemClick(item)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span> </span>
} <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
<span> </div>
{this.state.role ? this.state.role.role_id === 1 ? {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
<CustomCheckboxDisabled </Collapse>
disabled={true} // </li>
checked={true} )
// onChange={() => this.handleItemClick(item)} })}
/> : </ul>
<CustomCheckbox )}
checked={this.handleItemChecked(data)} </div>
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
})}
</ul>
) )
} }
......
...@@ -289,47 +289,51 @@ export default class EditUser extends Component { ...@@ -289,47 +289,51 @@ export default class EditUser extends Component {
padding = 20 padding = 20
} }
return ( return (
<ul> <div>
{item.children.map((data, index) => { {item.children.length > 0 && (
return ( <ul>
// <li> {item.children.map((data, index) => {
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> return (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> // <li>
{R.isNil(data.children) ? <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
null <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
: {R.isNil(data.children) ?
data.children.length < 1 ? null
null :
: data.children.length < 1 ?
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> null
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
{this.state.role ? this.state.role.role_id === 1 ?
<CustomCheckboxDisabled
disabled={true}
checked={true}
// onChange={() => this.handleItemClick(item)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span> </span>
} <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
<span> </div>
{this.state.role ? this.state.role.role_id === 1 ? {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
<CustomCheckboxDisabled </Collapse>
disabled={true} // </li>
checked={true} )
// onChange={() => this.handleItemClick(item)} })}
/> : </ul>
<CustomCheckbox )}
checked={this.handleItemChecked(data)} </div>
onChange={() => this.handleItemClick(data)}
/> :
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => this.handleItemClick(data)}
/>
}
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
})}
</ul>
) )
} }
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, AppBar, Tabs, Tab, TextField, Collapse, withStyles, Checkbox, InputAdornment, IconButton } from '@material-ui/core'; import { Typography, AppBar, Tabs, Tab, TextField, Snackbar, Collapse, withStyles, Checkbox, InputAdornment, IconButton } from '@material-ui/core';
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 HomePage from './HomePage'; import MuiAlert from '@material-ui/lab/Alert';
import Images from '../assets/Images'; import Images from '../assets/Images';
import api from '../api'; import api from '../api';
import Constant from '../library/Constant'; import Constant from '../library/Constant';
...@@ -22,6 +22,9 @@ const CustomCheckbox = withStyles({ ...@@ -22,6 +22,9 @@ const CustomCheckbox = withStyles({
checked: {}, checked: {},
})((props) => <Checkbox color="default" {...props} />); })((props) => <Checkbox color="default" {...props} />);
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class Profile extends Component { export default class Profile extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
...@@ -43,7 +46,10 @@ export default class Profile extends Component { ...@@ -43,7 +46,10 @@ export default class Profile extends Component {
showPass2: false, showPass2: false,
showPass3: false, showPass3: false,
pictures: [], pictures: [],
name: "" name: "",
alert: false,
tipeAlert: '',
messageAlert: ''
} }
this.onDrop = this.onDrop.bind(this); this.onDrop = this.onDrop.bind(this);
} }
...@@ -111,12 +117,20 @@ export default class Profile extends Component { ...@@ -111,12 +117,20 @@ export default class Profile extends Component {
api.create().changePassword(body).then(response => { api.create().changePassword(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.ok) {
this.setState({ oldPassword: "", password: "", confirmPassword: "" }) if (response.data.status === "success") {
localStorage.removeItem(Constant.TOKEN) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
window.location.reload(); this.setState({ oldPassword: "", password: "", confirmPassword: "" })
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
alert(response.data.message) } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -136,11 +150,20 @@ export default class Profile extends Component { ...@@ -136,11 +150,20 @@ export default class Profile extends Component {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
console.log(response); console.log(response);
if (response.data.status == 'success') { if (response.data) {
this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname }) if (response.ok) {
console.log(response) if (response.data.status == 'success') {
this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname })
console.log(response)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -148,10 +171,18 @@ export default class Profile extends Component { ...@@ -148,10 +171,18 @@ export default class Profile extends Component {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.ok) {
this.setState({ listCompany: response.data.data }) if (response.data.status == 'success') {
console.log(response.data.data) this.setState({ listCompany: response.data.data })
console.log(response.data.data)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
...@@ -169,36 +200,40 @@ export default class Profile extends Component { ...@@ -169,36 +200,40 @@ export default class Profile extends Component {
padding = 20 padding = 20
} }
return ( return (
<ul> <div>
{item.children.map((data, index) => { {item.children.length > 0 && (
return ( <ul>
// <li> {item.children.map((data, index) => {
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> return (
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> // <li>
{R.isNil(data.children) ? <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
null <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
: {R.isNil(data.children) ?
data.children.length < 1 ?
null null
: :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> data.children.length < 1 ?
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} null
</span> :
} <span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
<span> {data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
<CustomCheckbox </span>
checked={this.handleItemChecked(data)} }
onChange={() => null} <span>
/> <CustomCheckbox
</span> checked={this.handleItemChecked(data)}
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography> onChange={() => null}
</div> />
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)} </span>
</Collapse> <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
// </li> </div>
) {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
})} </Collapse>
</ul> // </li>
)
})}
</ul>
)}
</div>
) )
} }
...@@ -269,20 +304,37 @@ export default class Profile extends Component { ...@@ -269,20 +304,37 @@ export default class Profile extends Component {
api.create().uploadFoto(formData).then(response => { api.create().uploadFoto(formData).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.ok){
this.setState({ uploadVisible: false }, () => { if (response.data.status === "success") {
alert(response.data.message) this.setState({ uploadVisible: false }, () => {
this.getUser() this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
window.location.reload() this.getUser()
}) window.location.reload()
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' })
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className={"main-color"} style={{ height: 203, flex: 1, display: 'flex', alignItems: 'flex-end', padding: 20 }}> <div className={"main-color"} style={{ height: 203, flex: 1, display: 'flex', alignItems: 'flex-end', padding: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}> <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
......
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