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

Merge branch 'didam' into 'master'

update didam

See merge request !91
parents 79b51095 37b42b82
{
"name": "my-app",
"version": "0.1.0",
"homepage": "http://localhost:8080/tia-web/",
"homepage": "http://localhost:8080/tia-web-dev/",
"private": true,
"dependencies": {
"@date-io/date-fns": "^1.3.13",
......
......@@ -72,7 +72,7 @@ export default class ApprovalMatrix extends Component {
}
else if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
let listData = data.sort((a,b) => a.approval_matrix_id - b.approval_matrix_id).map((item, index) => {
return [index, item.approval_matrix_id, item.approval_type_name, item.orders, item.fullname, item.operator_type_name, item.status ]
})
this.setState({ dataTable: listData, listData: response.data.data })
......
......@@ -136,9 +136,11 @@ export default class VisualisasiAM extends Component {
onDragEnd(fromIndex, toIndex) {
const data = [...that.state.listApproval];
const item = data.splice(fromIndex, 1)[0];
that.handleChangeOrder(fromIndex, toIndex, that)
data.splice(toIndex, 0, item);
that.setState({ listApproval: data });
if (fromIndex !== -1 && toIndex !== -1) {
that.handleChangeOrder(fromIndex, toIndex, that)
data.splice(toIndex, 0, item);
that.setState({ listApproval: data });
}
},
nodeSelector: 'li',
handleSelector: 'a'
......
......@@ -3,7 +3,6 @@ import clsx from 'clsx';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import CssBaseline from '@material-ui/core/CssBaseline';
import Typography from '@material-ui/core/Typography';
......@@ -13,15 +12,11 @@ import MenuIcon from '@material-ui/icons/Menu';
import ExpandMore from '@material-ui/icons/ExpandMore'
import ExpandLess from '@material-ui/icons/ExpandLess'
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import InboxIcon from '@material-ui/icons/MoveToInbox';
import MailIcon from '@material-ui/icons/Mail';
import Collapse from '@material-ui/core/Collapse';
import DateFnsUtils from '@date-io/date-fns';
import { DateTimePicker, MuiPickersUtilsProvider } from "@material-ui/pickers";
import { MuiPickersUtilsProvider } from "@material-ui/pickers";
import localeID from 'date-fns/locale/id';
import {
......@@ -131,19 +126,19 @@ export default function MiniDrawer() {
const [selectedSubIndex, setSelectSub] = React.useState([]);
const [userFullname, setUserFullname] = React.useState("")
const [userEmail, setUserEmail] = React.useState("")
React.useEffect(() => {
if (userFullname == "" && userEmail == "") {
if(userFullname == "" && userEmail == "") {
getUserData()
}
}
})
const getUserData = () => {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data.status == 'success') {
setUserFullname(response.data.data.fullname == null ? 'Anonym' : response.data.data.fullname)
setUserEmail(response.data.data.email == null ? 'Anonym@123.xyz' : response.data.data.email)
setUserFullname(response.data.data.fullname == null? 'Anonym' : response.data.data.fullname)
setUserEmail(response.data.data.email == null? 'Anonym@123.xyz' : response.data.data.email)
console.log(userEmail)
}
})
......@@ -172,11 +167,6 @@ export default function MiniDrawer() {
setSelectedIndex(e)
}
const logout = () => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
let { path, url } = useRouteMatch();
const { height, width } = UseWindowDimensions();
......@@ -206,23 +196,24 @@ export default function MiniDrawer() {
>
<div className={classes.toolbarDrawer} style={{
backgroundColor: '#1a2d3e',
height: open ? 203 : 78,
height: open ? null : 78,
paddingLeft: open ? null : 55,
display: open ? null : 'grid',
alignSelf: open ? null : 'center'
paddingBottom: open ? 55 : null,
alignSelf: open? null : 'center'
}}>
{open === true ?
<div style={{ display: 'flex', justifyContent: 'space-between', flex: 1, padding: 10 }}>
<img src={Images.triputra} alt="React Logo" style={{ height: 31, width: 151, alignSelf: 'center' }} />
<IconButton onClick={handleDrawerClose} style={{ outline: 'none' }}>
<IconButton onClick={handleDrawerClose} style={{outline: 'none'}}>
<ChevronLeftIcon style={{ fill: 'white' }} />
</IconButton>
</div> :
<IconButton
color="inherit"
aria-label="open drawer"
style={{ outline: 'none' }}
style={{outline: 'none'}}
onClick={handleDrawerOpen}
edge="start"
className={clsx(classes.menuButton, {
......@@ -232,15 +223,15 @@ export default function MiniDrawer() {
<MenuIcon style={{ fill: 'white' }} />
</IconButton>}
{open &&
<div style={{ width: '100%', marginTop: 15, marginBottom: 60 }}>
<Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', fontWeight: 'bold' }}>{userFullname}</Typography>
<Typography style={{ fontSize: 14, color: '#fff', textAlign: 'center', marginTop: 10 }}>{userEmail}</Typography>
<div style={{ width: '100%' }}>
<Typography style={{ fontSize: 12, color: '#fff', textAlign: 'center', fontWeight: 'bold' }}>John Doe</Typography>
<Typography style={{ fontSize: 12, color: '#fff', textAlign: 'center', marginTop: 10 }}>john@tia.com</Typography>
</div>
}
</div>
<Divider />
{open &&
<div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -45 }}>
<div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -40 }}>
<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>
......@@ -289,7 +280,7 @@ export default function MiniDrawer() {
{item.subItem.map((sub, indexs) => {
return (
<Link to={`${url}/${sub.path}`}>
<div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => sub.label === "Logout" ? logout() : selectSub(sub.label)}>
<div style={{ paddingLeft: 5, }} className={selectedSubIndex === sub.label ? "active" : ""} onClick={() => selectSub(sub.label)}>
<ListItem button style={{ paddingLeft: 61 }}>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{sub.label}</Typography>
</ListItem>
......
import React, { Component } from 'react';
import { Typography, CircularProgress, MuiThemeProvider, createMuiTheme } from '@material-ui/core';
import { Typography, MuiThemeProvider, createMuiTheme } from '@material-ui/core';
import MUIDataTable from "mui-datatables";
import Images from '../assets/Images';
import DonutChart from 'react-d3-donut';
......
import React, { Component } from "react";
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import SearchIcon from '@material-ui/icons/Search';
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
......@@ -18,74 +17,6 @@ var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
const tesss = [{
name: "Data Ke-",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowIndex + 1}
</div >
);
}
}
}, {
name: "Nama Lengkap",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 50 }}>
{titleCase(val)}
</div >
);
}
}
}, {
name: "Email",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 200 }}>
{val}
</div >
);
}
}
}, {
name: "Role",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 150 }}>
{titleCase(val)}
</div >
);
}
}
}, {
name: "Berlaku Mulai",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 100 }}>
{titleCase(val)}
</div >
);
}
}
}, {
name: "Berakhir Hingga",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{val}
</div >
);
}
}
}]
export default class UserRole extends Component {
constructor(props) {
super(props)
......@@ -94,7 +25,8 @@ export default class UserRole extends Component {
indexData: {},
add: false,
edit: false,
visibleUser: true
visibleUser: true,
buttonError: false,
}
}
......@@ -112,22 +44,15 @@ export default class UserRole extends Component {
getUser() {
api.create().getUser().then((response) => {
// console.log(response)
if (response.data.status == 'success') {
// console.log(response.data.data)
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.user_id, item.fullname, item.email, item.role_name, item.company, item.status]
let listData = data.sort((a,b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname === null? '-' : item.fullname, item.email, item.role_name, '-', item.status]
})
// console.log(listData)
this.setState({ listUser: listData })
// this.setState({listUser: response.data.data}, () => {
// console.log(this.state.listUser)
// })
} else {
alert(response.data.message)
}
// console.log(response.data.data)
})
}
......@@ -136,10 +61,10 @@ export default class UserRole extends Component {
"keyword": this.state.search
}
api.create().searchUser(payload).then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.user_id, item.fullname, item.email, item.role_name, item.company, item.status]
let listData = data.sort((a,b) => a.user_id - b.user_id).map((item, index) => {
return [index, item.user_id, item.fullname == null? '-' : item.fullname, item.email, item.role_name, '-', item.status]
})
this.setState({ listUser: listData })
} else {
......@@ -155,18 +80,21 @@ export default class UserRole extends Component {
console.log(err);
}
else {
let judul = resp.rows[0]
// let judul = resp.rows[0]
let isi = resp.rows.slice(3)
let payload = []
console.log(isi)
isi.map((item, index) => {
payload.push({
id: item.id,
fullname: item[0],
email: item[1],
role: item[2],
start_date: item[3],
end_date: item[4],
})
if (item.length > 0) {
payload.push({
id: index + 1,
fullname: item[0],
email: item[1],
role: item[2],
start_date: item[3],
end_date: item[4],
})
}
})
let body = {
user: payload
......@@ -383,7 +311,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 50 }}>
<div style={{ display: 'flex'}}>
{val}
</div >
);
......@@ -394,7 +322,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 200 }}>
<div style={{ display: 'flex'}}>
{titleCase(val)}
</div >
);
......@@ -405,7 +333,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 150 }}>
<div style={{ display: 'flex'}}>
{titleCase(val)}
</div >
);
......@@ -416,7 +344,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex', width: 100 }}>
<div style={{ display: 'flex'}}>
{titleCase(val)}
</div >
);
......@@ -437,7 +365,7 @@ export default class UserRole extends Component {
return (
<div style={{ height: this.props.height }}>
{/* <Row> */}
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
{this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18 }}>Master Data - User</label>
......@@ -565,7 +493,7 @@ export default class UserRole extends Component {
</button>
<button
type="button"
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : null}
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadUser()}
style={{}}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
......
......@@ -5,7 +5,6 @@ import Autocomplete from '@material-ui/lab/Autocomplete';
import { titleCase } from '../../../library/Utils';
import localeID from "date-fns/locale/id"
import format from "date-fns/format";
import * as R from 'ramda'
import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
import { DatePicker } from '@material-ui/pickers';
......@@ -64,7 +63,7 @@ export default class AddUser extends Component {
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
if (isDate && type === 'start_date') {
this.setState({ ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorRoleName: false,
errorStartDate: false,
......@@ -73,7 +72,7 @@ export default class AddUser extends Component {
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type == 'end_date') {
} else if (isDate && type === 'end_date') {
this.setState({ ...data, endDate: format(e, 'yyyy-MM-dd') ,
errorRoleName: false,
errorStartDate: false,
......@@ -110,7 +109,7 @@ export default class AddUser extends Component {
}
api.create().createUser(payload).then((response) => {
console.log(response)
if (String(response.data.status).toLocaleUpperCase == 'success') {
if (String(response.data.status).toLocaleUpperCase === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
......@@ -121,7 +120,7 @@ export default class AddUser extends Component {
getRole() {
api.create().getRole().then((response) => {
if(response.data.status == 'success') {
if(response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
......@@ -142,7 +141,7 @@ export default class AddUser extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if(response.data.status == 'success') {
if(response.data.status === 'success') {
this.setState({listCompany: response.data.data})
console.log(response.data.data)
}
......@@ -150,14 +149,14 @@ export default class AddUser extends Component {
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
return indexID == -1 ? false : true
let indexID = this.state.company.findIndex((val) => val === item.company_id)
return indexID === -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let company = this.state.company
if (indexID == -1) {
if (indexID === -1) {
company.push(item.company_id)
} else {
company.splice(indexID, 1)
......@@ -341,7 +340,7 @@ export default class AddUser extends Component {
</div>
<div style={{flexDirection:'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{fontSize: 12}}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', {locale: localeID})}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData == null? '' : this.state.tempData.updated}`}</Typography> */}
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */}
</div>
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
......@@ -351,8 +350,8 @@ export default class AddUser extends Component {
return(
<div>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.childCompany.length > 0 && <span onClick={() => this.setState({ selectedIndex: index == this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
{item.childCompany.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
......@@ -364,10 +363,10 @@ export default class AddUser extends Component {
</div>
{item.childCompany.length > 0 && item.childCompany.map((items,indexs) => {
return (
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
<div style={{ paddingLeft: 60, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index == this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
{/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */}
{/* <RemoveIcon color={'action'} fontSize={'small'} /> */}
<span>
......
......@@ -5,7 +5,6 @@ import { titleCase } from '../../../library/Utils';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { DatePicker } from '@material-ui/pickers';
import format from "date-fns/format";
import * as R from 'ramda'
import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
......@@ -59,7 +58,7 @@ export default class EditUser extends Component {
handleChange(e, type) {
let data = this.state
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 },
errorRoleName: false,
errorStartDate: false,
......@@ -68,7 +67,7 @@ export default class EditUser extends Component {
msgErrorSD: '',
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') },
errorRoleName: false,
errorStartDate: false,
......@@ -91,7 +90,7 @@ export default class EditUser extends Component {
getDetailUser() {
api.create().getDetailUser(this.state.paramsId).then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.setState({tempData: response.data.data, company: response.data.data.company})
console.log(response.data.data)
} else {
......@@ -116,7 +115,7 @@ export default class EditUser extends Component {
}
api.create().updateUser(payload).then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.props.onClickClose()
this.props.refresh()
} else {
......@@ -127,7 +126,7 @@ export default class EditUser extends Component {
getRole() {
api.create().getRole().then((response) => {
if(response.data.status == 'success') {
if(response.data.status === 'success') {
let data = response.data.data
let roleData = data.map((item) => {
return {
......@@ -140,8 +139,8 @@ export default class EditUser extends Component {
getOptionLabel: (option) => titleCase(option.role_name),
};
let index = roleData.findIndex((val) => val.role_id == this.state.tempData.role_id)
this.setState({listRole: defaultProps, role: index == -1? roleData[0] : roleData[index]})
let index = roleData.findIndex((val) => val.role_id === this.state.tempData.role_id)
this.setState({listRole: defaultProps, role: index === -1? roleData[0] : roleData[index]})
} else {
alert(response.data.message)
}
......@@ -150,7 +149,7 @@ export default class EditUser extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if(response.data.status == 'success') {
if(response.data.status === 'success') {
this.setState({listCompany: response.data.data})
console.log(response.data.data)
}
......@@ -158,14 +157,14 @@ export default class EditUser extends Component {
}
handleItemChecked(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
return indexID == -1 ? false : true
let indexID = this.state.company.findIndex((val) => val === item.company_id)
return indexID === -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.company.findIndex((val) => val == item.company_id)
let indexID = this.state.company.findIndex((val) => val === item.company_id)
let company = this.state.company
if (indexID == -1) {
if (indexID === -1) {
company.push(item.company_id)
} else {
company.splice(indexID, 1)
......@@ -204,7 +203,7 @@ export default class EditUser extends Component {
disabled
// id="outlined-read-only-input"
variant="filled"
value={this.state.tempData == null? '' : this.state.tempData.user_id}
value={this.state.tempData === null? '' : this.state.tempData.user_id}
onChange={(e) => null}
>
{/* {periode.map((option) => (
......@@ -223,7 +222,7 @@ export default class EditUser extends Component {
id="fullname"
name="fullname"
label="Nama Lengkap"
value={this.state.tempData == null? '' : this.state.tempData.fullname}
value={this.state.tempData === null? '' : this.state.tempData.fullname}
onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value"
// helperText="Some important text"
......@@ -240,7 +239,7 @@ export default class EditUser extends Component {
id="email"
name="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, '')}
// defaultValue="Default Value"
// helperText="Some important text"
......@@ -270,7 +269,7 @@ export default class EditUser extends Component {
id="startDate"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.start_date}
value={this.state.tempData === null ? null : this.state.tempData.start_date}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
onChange={(e) => this.handleChange(e, 'start_date')}
......@@ -290,10 +289,10 @@ export default class EditUser extends Component {
id="endDate"
label="Berlaku Hingga"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.end_date}
value={this.state.tempData === null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
minDate={this.state.tempData == null ? null : this.state.tempData.start_date}
minDate={this.state.tempData === null ? null : this.state.tempData.start_date}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
......@@ -315,7 +314,7 @@ export default class EditUser extends Component {
disabled
// id="outlined-read-only-input"
variant="filled"
value={this.state.tempData == null? '' : this.state.tempData.status}
value={this.state.tempData === null? '' : this.state.tempData.status}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
......@@ -336,7 +335,7 @@ export default class EditUser extends Component {
disabled
// id="outlined-read-only-input"
variant="filled"
value={this.state.tempData == null? '' : this.state.tempData.is_expired}
value={this.state.tempData === null? '' : this.state.tempData.is_expired}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
......@@ -348,8 +347,8 @@ export default class EditUser extends Component {
</div>
</div>
<div style={{flexDirection:'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{fontSize: 12}}>{`Dibuat : ${this.state.tempData == null? '' : this.state.tempData.created}`}</Typography>
<Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData == null? '' : this.state.tempData.updated}`}</Typography>
<Typography style={{fontSize: 12}}>{`Dibuat : ${this.state.tempData === null? '' : this.state.tempData.created}`}</Typography>
<Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography>
</div>
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
......@@ -359,8 +358,8 @@ export default class EditUser extends Component {
return(
<div>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.childCompany.length > 0 && <span onClick={() => this.setState({ selectedIndex: index == this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
{item.childCompany.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
......@@ -372,10 +371,10 @@ export default class EditUser extends Component {
</div>
{item.childCompany.length > 0 && item.childCompany.map((items,indexs) => {
return (
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
<div style={{ paddingLeft: 60, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index == this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
{/* {item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} */}
{/* <RemoveIcon color={'action'} fontSize={'small'} /> */}
<span>
......
import React, { Component, memo } from "react";
import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import SearchIcon from '@material-ui/icons/Search';
import Images from "../../assets/Images";
import MUIDataTable from "mui-datatables";
......@@ -10,7 +9,6 @@ import api from "../../api";
import { titleCase } from "../../library/Utils";
import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField';
import AccountCircle from '@material-ui/icons/AccountCircle';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
......@@ -42,9 +40,9 @@ class UserRole extends Component {
getRole() {
api.create().getRole().then((response) => {
// console.log(response)
if (response.data.status == 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.map((item,index) => {
let listData = data.sort((a,b) => a.role_id - b.role_id).map((item,index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
// console.log(listData)
......@@ -65,9 +63,9 @@ class UserRole extends Component {
"keyword": this.state.search
}
api.create().searchRole(payload).then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
let data = response.data.data
let listData = data.map((item,index) => {
let listData = data.sort((a,b) => a.role_id - b.role_id).map((item,index) => {
return [index, item.role_id, item.role_name, item.access, item.status]
})
this.setState({listRole: listData})
......@@ -168,13 +166,6 @@ class UserRole extends Component {
}
}
}]
const data = [
["1", "1", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
["2", "2", "Laporan Bulanan - September 2020", "1 (20 Oktober 2020)", "Belum Disetujui"],
["3", "3", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
["4", "4", "Laporan Bulanan - September 2020", "0 (20 Oktober 2020)", "Belum Disetujui"],
["5", "5", "Budget Tahunan 2021", "0 (20 Oktober 2020)", "Belum Disetujui"],
]
return (
<div style={{ height: this.props.height }}>
{/* <Row> */}
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, MuiThemeProvider } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import api from '../../../api';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import { DateTimePicker, KeyboardDatePicker, DatePicker} from "@material-ui/pickers";
import {DatePicker} from "@material-ui/pickers";
import format from "date-fns/format";
import localeID from "date-fns/locale/id"
import * as R from 'ramda'
......@@ -54,7 +54,7 @@ export default class AddRole extends Component {
handleChange(e, type) {
let data = this.state
let isDate = type !== ''? true : false
if (isDate && type == 'start_date') {
if (isDate && type === 'start_date') {
this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorRoleName: false,
errorStartDate: false,
......@@ -63,7 +63,7 @@ export default class AddRole extends Component {
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type == 'end_date') {
} else if (isDate && type === 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
errorRoleName: false,
errorStartDate: false,
......@@ -111,7 +111,7 @@ export default class AddRole extends Component {
// console.log(payload)
api.create().addRole(payload).then((response) => {
console.log(response)
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.props.refresh()
this.props.onClickClose()
} else {
......@@ -122,7 +122,7 @@ export default class AddRole extends Component {
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.setState({menuData: response.data.data})
} else {
alert(response.data.message)
......@@ -131,14 +131,14 @@ export default class AddRole extends Component {
}
handleItemChecked(item) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
return indexID == -1? false : true
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
return indexID === -1? false : true
}
handleItemClick(item) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let privileges = this.state.privileges
if (indexID == -1) {
if (indexID === -1) {
privileges.push({
menu_id: item.menu_id,
button_id: [1,2,3]
......@@ -150,36 +150,33 @@ export default class AddRole extends Component {
}
handleSubItemChecked(item, index) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let value = false
if (indexID == -1) {
if (indexID === -1) {
value = false
} else {
let arrayButton = this.state.privileges[indexID].button_id
// console.log(arrayButton)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val == index)
// console.log(indexButtonID)
if (indexButtonID == -1) {
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
if (indexButtonID === -1) {
value = false
} else {
value = true
}
}
return indexID == -1? value : value
return indexID === -1? value : value
}
handleSubItemClick(item, index) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val == index)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
let privileges = this.state.privileges
let button_id = privileges[indexID].button_id
if (indexButtonID == -1) {
if (indexButtonID === -1) {
button_id.push(index)
} else {
button_id.splice(indexButtonID,1)
}
privileges[indexID].button_id = button_id
if (button_id.length == 0) {
if (button_id.length === 0) {
privileges.splice(indexID,1)
}
this.setState({privileges})
......@@ -317,7 +314,7 @@ export default class AddRole extends Component {
</div>
<div style={{flexDirection:'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{fontSize: 12}}>{`Dibuat : ${format(this.state.date, 'dd MMMM yyyy', {locale: localeID})}`}</Typography>
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData == null? '' : this.state.tempData.updated}`}</Typography> */}
{/* <Typography style={{fontSize: 12}}>{`Diubah: ${this.state.tempData === null? '' : this.state.tempData.updated}`}</Typography> */}
</div>
<Divider style={{margin: 20}}/>
<div style={{paddingLeft: 20, paddingRight: 20}}>
......@@ -345,8 +342,8 @@ export default class AddRole extends Component {
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start'}}>
{item.sub_menu.length > 0 && <span onClick={() => this.setState({selectedIndex: index == this.state.selectedIndex? 0 : index})} style={{marginLeft: 7, marginRight: 2}}>
{index == this.state.selectedIndex? <RemoveIcon color={'action'} fontSize={'small'}/> : <AddIcon color={'action'} fontSize={'small'}/>}
{item.sub_menu.length > 0 && <span onClick={() => this.setState({selectedIndex: index === this.state.selectedIndex? 0 : index})} style={{marginLeft: 7, marginRight: 2}}>
{index === this.state.selectedIndex? <RemoveIcon color={'action'} fontSize={'small'}/> : <AddIcon color={'action'} fontSize={'small'}/>}
</span>}
<span>
<CustomCheckbox
......@@ -384,7 +381,7 @@ export default class AddRole extends Component {
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items,indexs) => {
return(
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 50}}>
<CustomCheckbox
......
import React, { Component } from 'react';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse, MuiThemeProvider } from '@material-ui/core';
import { TextField, Divider, Typography, Checkbox, withStyles, Collapse } from '@material-ui/core';
import api from '../../../api';
import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove';
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import { DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
import * as R from 'ramda'
const CustomCheckbox = withStyles({
......@@ -50,7 +50,7 @@ export default class EditRole extends Component {
handleChange(e, type) {
let data = this.state
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 },
errorRoleName: false,
errorStartDate: false,
......@@ -59,7 +59,7 @@ export default class EditRole extends Component {
msgErrorSD: '',
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') },
errorRoleName: false,
errorStartDate: false,
......@@ -83,7 +83,7 @@ export default class EditRole extends Component {
getDetailRole() {
api.create().getDetailRole(this.state.paramsId).then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.setState({ tempData: response.data.data, privileges: response.data.data.privileges })
console.log(response.data.data.start_date)
} else {
......@@ -119,7 +119,7 @@ export default class EditRole extends Component {
// console.log(payload)
api.create().editRole(payload).then((response) => {
console.log(response)
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.props.refresh()
this.props.onClickClose()
} else {
......@@ -130,7 +130,7 @@ export default class EditRole extends Component {
getMenu() {
api.create().getMenu().then((response) => {
if (response.data.status == 'success') {
if (response.data.status === 'success') {
this.setState({ menuData: response.data.data })
} else {
alert(response.data.message)
......@@ -139,14 +139,14 @@ export default class EditRole extends Component {
}
handleItemChecked(item) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
return indexID == -1 ? false : true
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
return indexID === -1 ? false : true
}
handleItemClick(item) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let privileges = this.state.privileges
if (indexID == -1) {
if (indexID === -1) {
privileges.push({
menu_id: item.menu_id,
button_id: [1, 2, 3]
......@@ -158,36 +158,33 @@ export default class EditRole extends Component {
}
handleSubItemChecked(item, index) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let value = false
if (indexID == -1) {
if (indexID === -1) {
value = false
} else {
let arrayButton = this.state.privileges[indexID].button_id
// console.log(arrayButton)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val == index)
// console.log(indexButtonID)
if (indexButtonID == -1) {
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
if (indexButtonID === -1) {
value = false
} else {
value = true
}
}
return indexID == -1 ? value : value
return indexID === -1 ? value : value
}
handleSubItemClick(item, index) {
let indexID = this.state.privileges.findIndex((val) => val.menu_id == item.menu_id)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val == index)
let indexID = this.state.privileges.findIndex((val) => val.menu_id === item.menu_id)
let indexButtonID = this.state.privileges[indexID].button_id.findIndex((val) => val === index)
let privileges = this.state.privileges
let button_id = privileges[indexID].button_id
if (indexButtonID == -1) {
if (indexButtonID === -1) {
button_id.push(index)
} else {
button_id.splice(indexButtonID, 1)
}
privileges[indexID].button_id = button_id
if (button_id.length == 0) {
if (button_id.length === 0) {
privileges.splice(indexID, 1)
}
this.setState({ privileges })
......@@ -229,7 +226,7 @@ export default class EditRole extends Component {
disabled
// id="outlined-read-only-input"
variant="filled"
value={this.state.tempData == null ? '' : this.state.tempData.role_id}
value={this.state.tempData === null ? '' : this.state.tempData.role_id}
onChange={(e) => null}
>
{/* {periode.map((option) => (
......@@ -248,7 +245,7 @@ export default class EditRole extends Component {
id="userRole"
name="role_name"
label="User Role"
value={this.state.tempData == null ? '' : this.state.tempData.role_name}
value={this.state.tempData === null ? '' : this.state.tempData.role_name}
error={this.state.errorRoleName}
helperText={this.state.msgErrorRN}
onChange={(e) => this.handleChange(e, '')}
......@@ -267,7 +264,7 @@ export default class EditRole extends Component {
id="startDate"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.start_date}
value={this.state.tempData === null ? null : this.state.tempData.start_date}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
onChange={(e) => this.handleChange(e, 'start_date')}
......@@ -287,10 +284,10 @@ export default class EditRole extends Component {
id="endDate"
label="Berlaku Hingga"
format="dd MMMM yyyy"
value={this.state.tempData == null ? null : this.state.tempData.end_date}
value={this.state.tempData === null ? null : this.state.tempData.end_date}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
minDate={this.state.tempData == null ? null : this.state.tempData.start_date}
minDate={this.state.tempData === null ? null : this.state.tempData.start_date}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
......@@ -312,7 +309,7 @@ export default class EditRole extends Component {
disabled
// id="outlined-read-only-input"
variant="filled"
value={this.state.tempData == null ? '' : this.state.tempData.status}
value={this.state.tempData === null ? '' : this.state.tempData.status}
>
{/* {periode.map((option) => (
<MenuItem key={option.value} value={option.value}>
......@@ -324,8 +321,8 @@ export default class EditRole extends Component {
</div>
</div>
<div style={{ flexDirection: 'column', display: 'flex', paddingLeft: 20, paddingRight: 20 }}>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${this.state.tempData == null ? '' : (this.state.tempData.created == null ? '-' : this.state.tempData.created)}`}</Typography>
<Typography style={{ fontSize: 12 }}>{`Diubah: ${this.state.tempData == null ? '' : (this.state.tempData.updated == null ? '-' : this.state.tempData.updated)}`}</Typography>
<Typography style={{ fontSize: 12 }}>{`Dibuat : ${this.state.tempData === null ? '' : (this.state.tempData.created === null ? '-' : this.state.tempData.created)}`}</Typography>
<Typography style={{ fontSize: 12 }}>{`Diubah: ${this.state.tempData === null ? '' : (this.state.tempData.updated === null ? '-' : this.state.tempData.updated)}`}</Typography>
</div>
<Divider style={{ margin: 20 }} />
<div style={{ paddingLeft: 20, paddingRight: 20 }}>
......@@ -353,8 +350,8 @@ export default class EditRole extends Component {
<div>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index == this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index == this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
{item.sub_menu.length > 0 && <span onClick={() => this.setState({ selectedIndex: index === this.state.selectedIndex ? 0 : index })} style={{ marginLeft: 7, marginRight: 2 }}>
{index === this.state.selectedIndex ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
......@@ -392,7 +389,7 @@ export default class EditRole extends Component {
</div>
{item.sub_menu.length > 0 && item.sub_menu.map((items, indexs) => {
return (
<Collapse in={index == this.state.selectedIndex} timeout="auto" unmountOnExit>
<Collapse in={index === this.state.selectedIndex} timeout="auto" unmountOnExit>
<div className="grid grid-2x grid-mobile-none gap-15px padding-left-10px padding-right-10px">
<div className="column-1" style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', paddingLeft: 50 }}>
<CustomCheckbox
......
import screen404 from '../container/Screen404'
import Beranda from '../container/Beranda'
import UserRole from '../container/Otorisasi/UserRole'
import User from '../container/Otorisasi/User'
import ApprovalMatrix from '../container/ApprovalMatrix/ApprovalMatrix'
import BudgetTahunan from '../container/BudgetTahunan';
import HomePage from '../container/HomePage';
import BalanceSheet from '../container/BudgetTahunan/BalanceSheet';
import Profile from '../container/Profile';
......
......@@ -26,7 +26,7 @@ import Constant from "../library/Constant";
export default function BasicExample() {
return (
<Router basename={"/tia-web"}>
<Router basename={"/tia-web-dev"}>
<Switch>
<Route exact path="/">
<Redirect
......
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