Commit b1bc1cbc authored by d.arizona's avatar d.arizona

update didam

parent 37b42b82
...@@ -144,6 +144,11 @@ export default function MiniDrawer() { ...@@ -144,6 +144,11 @@ export default function MiniDrawer() {
}) })
} }
const logout = () => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
const handleDrawerOpen = () => { const handleDrawerOpen = () => {
setOpen(true); setOpen(true);
}; };
...@@ -196,10 +201,10 @@ export default function MiniDrawer() { ...@@ -196,10 +201,10 @@ export default function MiniDrawer() {
> >
<div className={classes.toolbarDrawer} style={{ <div className={classes.toolbarDrawer} style={{
backgroundColor: '#1a2d3e', backgroundColor: '#1a2d3e',
height: open ? null : 78, height: open ? 203 : 78,
paddingLeft: open ? null : 55, paddingLeft: open ? null : 55,
display: open ? null : 'grid', display: open ? null : 'grid',
paddingBottom: open ? 55 : null, // paddingBottom: open ? 55 : null,
alignSelf: open? null : 'center' alignSelf: open? null : 'center'
}}> }}>
{open === true ? {open === true ?
...@@ -223,15 +228,15 @@ export default function MiniDrawer() { ...@@ -223,15 +228,15 @@ export default function MiniDrawer() {
<MenuIcon style={{ fill: 'white' }} /> <MenuIcon style={{ fill: 'white' }} />
</IconButton>} </IconButton>}
{open && {open &&
<div style={{ width: '100%' }}> <div style={{ width: '100%', marginTop: 15, marginBottom: 60 }}>
<Typography style={{ fontSize: 12, color: '#fff', textAlign: 'center', fontWeight: 'bold' }}>John Doe</Typography> <Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', fontWeight: 'bold' }}>{userFullname}</Typography>
<Typography style={{ fontSize: 12, color: '#fff', textAlign: 'center', marginTop: 10 }}>john@tia.com</Typography> <Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', marginTop: 10 }}>{userEmail}</Typography>
</div> </div>
} }
</div> </div>
<Divider /> <Divider />
{open && {open &&
<div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -40 }}> <div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -45 }}>
<div className={"sub-color"} style={{ width: 90, height: 90, borderRadius: 50, display: 'flex', justifyContent: 'center' }}> <div className={"sub-color"} style={{ width: 90, height: 90, borderRadius: 50, display: 'flex', justifyContent: 'center' }}>
<div style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}> <div style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}>
</div> </div>
...@@ -279,8 +284,8 @@ export default function MiniDrawer() { ...@@ -279,8 +284,8 @@ export default function MiniDrawer() {
<List component="div" disablePadding> <List component="div" disablePadding>
{item.subItem.map((sub, indexs) => { {item.subItem.map((sub, indexs) => {
return ( return (
<Link to={`${url}/${sub.path}`}> <Link to={sub.label === "Logout" ? `/` : `${url}/${sub.path}`}>
<div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => selectSub(sub.label)}> <div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => sub.label === "Logout" ? logout() : selectSub(sub.label)}>
<ListItem button style={{ paddingLeft: 61 }}> <ListItem button style={{ paddingLeft: 61 }}>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{sub.label}</Typography> <Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{sub.label}</Typography>
</ListItem> </ListItem>
......
...@@ -7,6 +7,7 @@ import { DatePicker } from '@material-ui/pickers'; ...@@ -7,6 +7,7 @@ import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format"; import format from "date-fns/format";
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import * as R from 'ramda'
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -51,7 +52,6 @@ export default class EditUser extends Component { ...@@ -51,7 +52,6 @@ export default class EditUser extends Component {
componentDidMount() { componentDidMount() {
this.getDetailUser() this.getDetailUser()
this.getRole()
this.getPerusahaan() this.getPerusahaan()
} }
...@@ -60,27 +60,39 @@ export default class EditUser extends Component { ...@@ -60,27 +60,39 @@ export default class EditUser extends Component {
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') { if (isDate && type === 'start_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null }, this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
errorFullname: false,
errorEmail: false,
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') }, this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
errorFullname: false,
errorEmail: false,
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
}) })
} else { } else {
this.setState({ ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value }, this.setState({ ...data, tempData: { ...this.state.tempData, [e.target.name]: e.target.value },
errorFullname: false,
errorEmail: false,
errorRoleName: false, errorRoleName: false,
errorStartDate: false, errorStartDate: false,
errorEndDate: false, errorEndDate: false,
msgErrorFN: '',
msgErrorEM: '',
msgErrorRN: '', msgErrorRN: '',
msgErrorSD: '', msgErrorSD: '',
msgErrorED: '', msgErrorED: '',
...@@ -90,6 +102,7 @@ export default class EditUser extends Component { ...@@ -90,6 +102,7 @@ export default class EditUser extends Component {
getDetailUser() { getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => { api.create().getDetailUser(this.state.paramsId).then((response) => {
this.getRole()
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({tempData: response.data.data, company: response.data.data.company}) this.setState({tempData: response.data.data, company: response.data.data.company})
console.log(response.data.data) console.log(response.data.data)
...@@ -100,8 +113,24 @@ export default class EditUser extends Component { ...@@ -100,8 +113,24 @@ export default class EditUser extends Component {
} }
validasi() { validasi() {
if (R.isEmpty(this.state.tempData.fullname)) {
this.setState({errorFullname: true, msgErrorFN: 'Nama Lengkap tidak boleh kosong'})
} else if (R.isEmpty(this.state.tempData.email)) {
this.setState({errorEmail: true, msgErrorEM: 'Email tidak boleh kosong'})
} else if (R.isEmpty(this.state.tempData.role_name)) {
this.setState({errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong'})
} else if (R.isNil(this.state.tempData.start_date)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
} else if (R.isNil(this.state.tempData.end_date)) {
this.setState({errorEndDate: true, msgErrorED: 'End Date tidak boleh kosong'})
}
// else if (this.state.privileges.length < 1) {
// alert('Hak Akses belum di pilih !!')
// }
else {
this.updateUser() this.updateUser()
} }
}
updateUser() { updateUser() {
let payload = { let payload = {
...@@ -225,7 +254,8 @@ export default class EditUser extends Component { ...@@ -225,7 +254,8 @@ export default class EditUser extends Component {
value={this.state.tempData === null? '' : this.state.tempData.fullname} value={this.state.tempData === null? '' : this.state.tempData.fullname}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value" // defaultValue="Default Value"
// helperText="Some important text" error={this.state.errorFullname}
helperText={this.state.msgErrorFN}
/> />
</div> </div>
</div> </div>
...@@ -241,8 +271,8 @@ export default class EditUser extends Component { ...@@ -241,8 +271,8 @@ export default class EditUser extends Component {
label="Email" label="Email"
value={this.state.tempData === null? '' : this.state.tempData.email} value={this.state.tempData === null? '' : this.state.tempData.email}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value" error={this.state.errorEmail}
// helperText="Some important text" helperText={this.state.msgErrorEM}
/> />
</div> </div>
</div> </div>
...@@ -254,6 +284,7 @@ export default class EditUser extends Component { ...@@ -254,6 +284,7 @@ export default class EditUser extends Component {
id="role" id="role"
onChange={(event, newInputValue) => this.setState({role: newInputValue})} onChange={(event, newInputValue) => this.setState({role: newInputValue})}
debug debug
renderInput={(params) => <TextField {...params} label="Role" margin="normal" style={{marginTop: 7}}/>} renderInput={(params) => <TextField {...params} label="Role" margin="normal" style={{marginTop: 7}}/>}
value={this.state.role} value={this.state.role}
/> />
...@@ -276,7 +307,6 @@ export default class EditUser extends Component { ...@@ -276,7 +307,6 @@ export default class EditUser extends Component {
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
}} }}
style={{ padding: 0, margin: 0, width: '100%' }} style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
......
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