Commit c30397c9 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into rifka

parents b54ce26d c13c2581
...@@ -2544,6 +2544,13 @@ ...@@ -2544,6 +2544,13 @@
"requires": { "requires": {
"axios": "^0.19.0", "axios": "^0.19.0",
"ramda": "^0.25.0" "ramda": "^0.25.0"
},
"dependencies": {
"ramda": {
"version": "0.25.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz",
"integrity": "sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ=="
}
} }
}, },
"aproba": { "aproba": {
...@@ -11559,9 +11566,9 @@ ...@@ -11559,9 +11566,9 @@
} }
}, },
"ramda": { "ramda": {
"version": "0.25.0", "version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz", "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-GXpfrYVPwx3K7RQ6aYT8KPS8XViSXUVJT1ONhoKPE9VAleW42YE+U+8VEyGWt41EnEQW7gwecYJriTI0pKoecQ==" "integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
}, },
"randombytes": { "randombytes": {
"version": "2.1.0", "version": "2.1.0",
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
work correctly both with client-side routing and a non-root public URL. work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`. Learn how to configure a non-root public URL by running `npm run build`.
--> -->
<title>React App</title> <title>TIA App</title>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
......
{ {
"short_name": "React App", "short_name": "TIA App",
"name": "Create React App Sample", "name": "TIA App",
"icons": [ "icons": [
{ {
"src": "favicon.ico", "src": "favicon.ico",
......
...@@ -7,6 +7,7 @@ import Grid from '@material-ui/core/Grid'; ...@@ -7,6 +7,7 @@ import Grid from '@material-ui/core/Grid';
import { Typography, Avatar } from '@material-ui/core'; import { Typography, Avatar } from '@material-ui/core';
import Images from '../assets/Images'; import Images from '../assets/Images';
import { Link, useRouteMatch } from 'react-router-dom'; import { Link, useRouteMatch } from 'react-router-dom';
import Constant from '../library/Constant';
const useStyles = makeStyles({ const useStyles = makeStyles({
avatar: { avatar: {
...@@ -29,10 +30,14 @@ function FadeMenu() { ...@@ -29,10 +30,14 @@ function FadeMenu() {
const handleClose = () => { const handleClose = () => {
setAnchorEl(null); setAnchorEl(null);
localStorage.clear()
window.location.reload();
}; };
const handleLogout = () => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
setAnchorEl(null);
}
const classes = useStyles(); const classes = useStyles();
let { path, url } = useRouteMatch(); let { path, url } = useRouteMatch();
...@@ -69,7 +74,7 @@ function FadeMenu() { ...@@ -69,7 +74,7 @@ function FadeMenu() {
</div> </div>
</Link> </Link>
</MenuItem> </MenuItem>
<MenuItem onClick={handleClose}> <MenuItem onClick={handleLogout}>
<div style={{ display: 'flex', padding: 10 }}> <div style={{ display: 'flex', padding: 10 }}>
<img src={Images.logout} style={{ height: 20, width: 20, marginRight: 20 }} /> <img src={Images.logout} style={{ height: 20, width: 20, marginRight: 20 }} />
<Typography>Logout</Typography> <Typography>Logout</Typography>
......
...@@ -84,6 +84,11 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -84,6 +84,11 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
const updateUnitBisnis = (body) => api.post('/business_unit/update_business_unit', body) const updateUnitBisnis = (body) => api.post('/business_unit/update_business_unit', body)
const searchUnitBisnis = (body) => api.post('/business_unit/search_business_unit', body) const searchUnitBisnis = (body) => api.post('/business_unit/search_business_unit', body)
// Perusahaan
const getPerusahaan = () => api.get('company/get_all_company')
const createPerusahaan = (body) => api.post('/company/create_company', body)
const updatePerusahaan = (body) => api.post('/company/update_company', body)
// APPROVAL MATRIX // APPROVAL MATRIX
const getAM = () => api.get('approval_matrix/get_all_approval_matrix') const getAM = () => api.get('approval_matrix/get_all_approval_matrix')
const getApprovedByAM = () => api.get('approval_matrix/get_all_approver') const getApprovedByAM = () => api.get('approval_matrix/get_all_approver')
...@@ -122,6 +127,9 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/') ...@@ -122,6 +127,9 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
updateUnitBisnis, updateUnitBisnis,
searchUnitBisnis, searchUnitBisnis,
getAM, getAM,
getPerusahaan,
createPerusahaan,
updatePerusahaan,
getApprovedByAM, getApprovedByAM,
createAM, createAM,
updateAM updateAM
......
...@@ -38,6 +38,7 @@ import Beranda from './Beranda'; ...@@ -38,6 +38,7 @@ import Beranda from './Beranda';
import { Avatar } from '@material-ui/core'; import { Avatar } from '@material-ui/core';
import HomeRoutes from '../router/homeRoutes' import HomeRoutes from '../router/homeRoutes'
import ArraySide from '../library/Array' import ArraySide from '../library/Array'
import Constant from '../library/Constant';
const drawerWidth = 307; const drawerWidth = 307;
...@@ -124,9 +125,10 @@ export default function MiniDrawer() { ...@@ -124,9 +125,10 @@ export default function MiniDrawer() {
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const [selectedIndex, setSelectedIndex] = React.useState([]); const [selectedIndex, setSelectedIndex] = React.useState([]);
React.useEffect(() => { // React.useEffect(() => {
// alert(ArraySide) // //
}) // })
const handleDrawerOpen = () => { const handleDrawerOpen = () => {
setOpen(true); setOpen(true);
}; };
...@@ -220,34 +222,36 @@ export default function MiniDrawer() { ...@@ -220,34 +222,36 @@ export default function MiniDrawer() {
} }
{open && {open &&
<div style={{ marginLeft: 20, marginTop: 20 }}> <div style={{ marginLeft: 20, marginTop: 20 }}>
<Typography style={{ color: 'white', fontSize: 12 }}>APLIKASI</Typography> <Typography style={{ color: 'white', fontSize: 14, fontFamily: 'nunito' }}>APLIKASI</Typography>
</div> </div>
} }
<List> <List>
{ArraySide.map((item, index) => ( {ArraySide.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 10}}> <div style={{ marginTop: index === 0 ? null : 10}}>
{item.subItem != null ? {item.subItem != null ?
<div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingRight: 10 }} onClick={() => selectedIndex == 0 ? setSelectedIndex(index) : setSelectedIndex(0)}> <div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 10, paddingRight: 10 }} onClick={() => selectedIndex == 0 ? setSelectedIndex(index) : setSelectedIndex(0)}>
<ListItem button key={item.label}> <ListItem button key={item.label}>
<ListItemIcon><img src={item.img} /></ListItemIcon> <ListItemIcon><img src={item.img} /></ListItemIcon>
<Typography style={{ color: 'white', fontSize: 12 }}>{item.label}</Typography> <Typography style={{ fontFamily: 'nunito', color: 'white', fontSize: 14 }}>{item.label}</Typography>
</ListItem> </ListItem>
{item.subItem != null ? (index === selectedIndex ? <ExpandLess style={{ color: "white", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "white", marginLeft: 50, alignSelf: 'center' }} />) : null} {item.subItem != null ? (index === selectedIndex ? <ExpandLess style={{ color: "white", marginLeft: 50, alignSelf: 'center' }} /> : <ExpandMore style={{ color: "white", marginLeft: 50, alignSelf: 'center' }} />) : null}
</div> </div>
: :
item.label === 'PENGATURAN' ? item.label === 'PENGATURAN' ?
open ? open ?
<Link to={`${url}/${item.path}`}> <Link to={`${url}/${item.path}`}>
<ListItem button key={item.label} onClick={() => null}> <ListItem button key={item.label} onClick={() => null}>
<Typography style={{ color: 'white', fontSize: 12 }}>{item.label}</Typography> <Typography style={{ fontFamily: 'nunito', color: 'white', fontSize: 14 }}>{item.label}</Typography>
</ListItem> </ListItem>
</Link> : null : </Link> : null
:
<Link to={`${url}/${item.path}`}> <Link to={`${url}/${item.path}`}>
<ListItem button key={item.label} onClick={() => setSelectedIndex(index)}> <div style={{paddingLeft: 10}}>
<ListItemIcon><img src={item.img} /></ListItemIcon> <ListItem button key={item.label} onClick={() => setSelectedIndex(index)}>
<Typography style={{ color: 'white', fontSize: 12 }}>{item.label}</Typography> <ListItemIcon><img src={item.img} /></ListItemIcon>
</ListItem> <Typography style={{ fontFamily: 'nunito', color: 'white', fontSize: 14 }}>{item.label}</Typography>
</ListItem>
</div>
</Link> </Link>
} }
{item.subItem != null && {item.subItem != null &&
...@@ -257,9 +261,11 @@ export default function MiniDrawer() { ...@@ -257,9 +261,11 @@ export default function MiniDrawer() {
{item.subItem.map((sub, index) => { {item.subItem.map((sub, index) => {
return ( return (
<Link to={`${url}/${sub.path}`}> <Link to={`${url}/${sub.path}`}>
<ListItem style={{ paddingLeft: 72 }}> <div style={{paddingLeft: 10}}>
<Typography style={{ color: 'white', fontSize: 12 }}>{sub.label}</Typography> <ListItem style={{ paddingLeft: 72 }}>
</ListItem> <Typography style={{ fontFamily: 'nunito', color: 'white', fontSize: 14 }}>{sub.label}</Typography>
</ListItem>
</div>
</Link> </Link>
) )
})} })}
......
...@@ -28,12 +28,13 @@ class Login extends Component { ...@@ -28,12 +28,13 @@ class Login extends Component {
errorEmail: false, errorEmail: false,
errorPassword: false, errorPassword: false,
msgEmail: '', msgEmail: '',
msgPassword: '' msgPassword: '',
rememberMe: false
} }
} }
componentDidMount() { componentDidMount() {
// this.coba() this.getUser()
} }
handleChange(e) { handleChange(e) {
...@@ -53,7 +54,6 @@ class Login extends Component { ...@@ -53,7 +54,6 @@ class Login extends Component {
validateLogin() { validateLogin() {
var isEmail = this.isEmail(this.state.email) var isEmail = this.isEmail(this.state.email)
if (this.state.email.trim() == "") { if (this.state.email.trim() == "") {
this.setState({ errorEmail: true, msgEmail: 'Email harus diisi!' }) this.setState({ errorEmail: true, msgEmail: 'Email harus diisi!' })
} else if (!isEmail) { } else if (!isEmail) {
...@@ -73,6 +73,14 @@ class Login extends Component { ...@@ -73,6 +73,14 @@ class Login extends Component {
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
localStorage.setItem(Constant.TOKEN, response.data.data.token) localStorage.setItem(Constant.TOKEN, response.data.data.token)
if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password)
// console.log(this.state.email, this.state.password)
} else {
localStorage.setItem(Constant.EMAIL, '')
localStorage.setItem(Constant.PASSWORD, '')
}
this.props.history.push('/home/beranda') this.props.history.push('/home/beranda')
} else { } else {
if (response.data.message == 'Password Salah!') { if (response.data.message == 'Password Salah!') {
...@@ -84,6 +92,15 @@ class Login extends Component { ...@@ -84,6 +92,15 @@ class Login extends Component {
}) })
} }
getUser() {
var email = localStorage.getItem(Constant.EMAIL)
var password = localStorage.getItem(Constant.PASSWORD)
if (email != '' && password != '') {
this.setState({email, password})
}
}
render() { render() {
return ( return (
<div style={{ flex: 1, display: 'flex' }}> <div style={{ flex: 1, display: 'flex' }}>
...@@ -141,7 +158,7 @@ class Login extends Component { ...@@ -141,7 +158,7 @@ class Login extends Component {
/> />
<div style={{ flexDirection: 'row', width: '100%', marginTop: this.state.errorPassword ? 26 : 16 }}> <div style={{ flexDirection: 'row', width: '100%', marginTop: this.state.errorPassword ? 26 : 16 }}>
<CustomCheckbox name="checked-remember" /> <CustomCheckbox name="checked-remember" checked={this.state.rememberMe} onChange={() => this.setState({rememberMe: !this.state.rememberMe})} />
<span style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Remember Me</span> <span style={{ color: 'rgba(0, 0, 0, 0.5)', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Remember Me</span>
<Link to={{pathname: '/forgot-password'}} style={{textDecoration: 'none'}}><span style={{marginLeft: 30, color: '#51c6ea', cursor: 'pointer', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Lupa Kata Sandi?</span></Link> <Link to={{pathname: '/forgot-password'}} style={{textDecoration: 'none'}}><span style={{marginLeft: 30, color: '#51c6ea', cursor: 'pointer', fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Lupa Kata Sandi?</span></Link>
</div> </div>
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core'; import { TextField, Typography } from '@material-ui/core';
import * as R from 'ramda';
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
export default class CreatePerusahaan extends Component { export default class CreatePerusahaan extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
company: '',
parentCompany: '',
unitBisnis: '',
startDate: '',
endDate: ''
}
}
render() { render() {
let { type } = this.props let { type } = this.props
return type === 'edit' ? this.renderEdit() : this.renderCreate() return type === 'edit' ? this.renderEdit() : this.renderCreate()
} }
componentDidMount() {
if (this.props.type === 'edit') {
let data = this.props.data
this.setState({
id: data.company_id,
company: data.company_name,
parentCompany: data.parent,
unitBisnis: data.businessUnitId,
startDate: data.start_date,
endDate: data.end_date
})
}
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd') }, () => {
console.log(this.state.startDate)
})
} else if (isDate && type == 'end_date') {
this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
console.log(this.state.endDate)
})
} else {
// this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
}
}
validasi() {
if (R.isEmpty(this.state.company)) return alert("Nama Perusahaan is Required.");
if (R.isEmpty(this.state.parentCompany)) return alert("Nama Perusahaan is Required.");
if (R.isEmpty(this.state.unitBisnis)) return alert("Unit Bisnis is Required.");
if (R.isEmpty(this.state.totalReport)) return alert("Total Report is Required.");
if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai");
if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required.");
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required.");
console.log('masuk');
if (this.props.type == 'edit') {
let payload = {
"company_id": this.state.id,
"company_name": this.state.company,
"parent": this.state.parentCompany,
"business_unit_id": this.state.unitBisnis,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
this.props.updatePerusahaan(payload)
} else if (this.props.type == 'create') {
let payload = {
"company_name": this.state.company,
"parent": this.state.parentCompany,
"business_unit_id": this.state.unitBisnis,
"total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
this.props.createPerusahaan(payload)
}
}
renderEdit() { renderEdit() {
return ( return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}> <div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
...@@ -34,7 +113,7 @@ export default class CreatePerusahaan extends Component { ...@@ -34,7 +113,7 @@ export default class CreatePerusahaan extends Component {
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={this.props.data[1]} value={this.props.data.company_id}
id="id" id="id"
label="ID" label="ID"
disabled disabled
...@@ -56,7 +135,7 @@ export default class CreatePerusahaan extends Component { ...@@ -56,7 +135,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="unit" id="unit"
label="Unit Bisnis" label="Unit Bisnis"
value={this.props.data[4]} value={this.state.unitBisnis}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -72,12 +151,16 @@ export default class CreatePerusahaan extends Component { ...@@ -72,12 +151,16 @@ export default class CreatePerusahaan extends Component {
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="periode" id="startDate"
value={"1 Januari 2020"}
label="Berlaku Mulai" label="Berlaku Mulai"
onChange={(e) => null} format="dd MMMM yyyy"
value={this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -89,13 +172,14 @@ export default class CreatePerusahaan extends Component { ...@@ -89,13 +172,14 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
>
</TextField> style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div> </div>
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={this.props.data[5]} value={this.props.data.status}
id="status" id="status"
label="Status" label="Status"
disabled disabled
...@@ -114,8 +198,14 @@ export default class CreatePerusahaan extends Component { ...@@ -114,8 +198,14 @@ export default class CreatePerusahaan extends Component {
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : Admin - 21 Jul 2020, 18:45</Typography> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography>
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography>
</div>
</div> </div>
</div> </div>
...@@ -125,7 +215,7 @@ export default class CreatePerusahaan extends Component { ...@@ -125,7 +215,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="perusahaan" id="perusahaan"
label="Nama Perusahaan" label="Nama Perusahaan"
value={this.props.data[2]} value={this.state.company}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -137,6 +227,7 @@ export default class CreatePerusahaan extends Component { ...@@ -137,6 +227,7 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ company: e.target.value })}
> >
</TextField> </TextField>
</div> </div>
...@@ -145,7 +236,7 @@ export default class CreatePerusahaan extends Component { ...@@ -145,7 +236,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="parent" id="parent"
label="Parent Company" label="Parent Company"
value={this.props.data[3]} value={this.state.parentCompany}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -161,11 +252,16 @@ export default class CreatePerusahaan extends Component { ...@@ -161,11 +252,16 @@ export default class CreatePerusahaan extends Component {
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="unit" id="endDate"
label="Berlaku Hingga" label="Berlaku Hingga"
defaultValue={"31 Desember 2020"} format="dd MMMM yyyy"
value={this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -177,22 +273,33 @@ export default class CreatePerusahaan extends Component { ...@@ -177,22 +273,33 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
>
</TextField> style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div> </div>
</div> </div>
</div> </div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}> <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}> <div className="column-1" style={{ alignSelf: 'center' }}>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span> type="button"
</div> onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button>
</div> </div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> type="button"
</div> onClick={() => this.validasi()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -229,7 +336,7 @@ export default class CreatePerusahaan extends Component { ...@@ -229,7 +336,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="unit" id="unit"
label="Unit Bisnis" label="Unit Bisnis"
defaultValue={"Agrobisnis"} value={this.state.unitBisnis}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -241,16 +348,16 @@ export default class CreatePerusahaan extends Component { ...@@ -241,16 +348,16 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ unitBisnis: e.target.value })}
> >
</TextField> </TextField>
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="periode" id="report"
value={"1 Januari 2020"} label="Jumlah Laporan"
label="Berlaku Mulai" value={this.state.totalReport}
onChange={(e) => null}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -262,9 +369,36 @@ export default class CreatePerusahaan extends Component { ...@@ -262,9 +369,36 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ totalReport: e.target.value })}
> >
</TextField> </TextField>
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.startDate == "" ? null : this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
...@@ -298,7 +432,7 @@ export default class CreatePerusahaan extends Component { ...@@ -298,7 +432,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="perusahaan" id="perusahaan"
label="Nama Perusahaan" label="Nama Perusahaan"
defaultValue={"Puninar Infininte Raya"} value={this.state.company}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -310,6 +444,7 @@ export default class CreatePerusahaan extends Component { ...@@ -310,6 +444,7 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ company: e.target.value })}
> >
</TextField> </TextField>
</div> </div>
...@@ -318,7 +453,7 @@ export default class CreatePerusahaan extends Component { ...@@ -318,7 +453,7 @@ export default class CreatePerusahaan extends Component {
style={{ width: '100%' }} style={{ width: '100%' }}
id="parentCompany" id="parentCompany"
label="Parent Company" label="Parent Company"
defaultValue={"Puninar Group"} value={this.state.parentCompany}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -330,15 +465,21 @@ export default class CreatePerusahaan extends Component { ...@@ -330,15 +465,21 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ parentCompany: e.target.value })}
> >
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <DatePicker
style={{ width: '100%' }} margin="normal"
id="unit" id="endDate"
label="Berlaku Hingga" label="Berlaku Hingga"
defaultValue={"31 Desember 2100"} format="dd MMMM yyyy"
value={this.state.endDate == "" ? null : this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{ inputProps={{
style: { style: {
fontSize: 11 fontSize: 11
...@@ -350,8 +491,9 @@ export default class CreatePerusahaan extends Component { ...@@ -350,8 +491,9 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
>
</TextField> style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div> </div>
</div> </div>
...@@ -359,14 +501,24 @@ export default class CreatePerusahaan extends Component { ...@@ -359,14 +501,24 @@ export default class CreatePerusahaan extends Component {
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}> <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}> <div className="column-1" style={{ alignSelf: 'center' }}>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span> type="button"
</div> onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button>
</div> </div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> type="button"
</div> onClick={() => this.validasi()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,14 +3,18 @@ import { Container, Row, Col } from "react-bootstrap"; ...@@ -3,14 +3,18 @@ import { Container, Row, Col } from "react-bootstrap";
import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'; import { makeStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import { Typography } from '@material-ui/core'; import { Typography } from '@material-ui/core';
import Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import UploadFile from "../../../library/Upload";
import MUIDataTable from "mui-datatables"; import MUIDataTable from "mui-datatables";
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import { TextField, InputBase } from "@material-ui/core"; import { TextField, InputBase } from "@material-ui/core";
import { ExcelRenderer } from 'react-excel-renderer';
import CreatePerusahaan from "../Perusahaan/CreatePerusahaan"; import CreatePerusahaan from "../Perusahaan/CreatePerusahaan";
import api from "../../../api";
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();
const options2 = ct.customOptions2();
export default class Perusahaan extends Component { export default class Perusahaan extends Component {
constructor(props) { constructor(props) {
...@@ -18,16 +22,117 @@ export default class Perusahaan extends Component { ...@@ -18,16 +22,117 @@ export default class Perusahaan extends Component {
this.state = { this.state = {
visibleCreate: false, visibleCreate: false,
visibleEdit: false, visibleEdit: false,
data: [] dataTable: [],
listData: [],
data: [],
search: "",
visiblePerusahaan: true,
cols: null,
rows: null,
dataLoaded: false
} }
this.fileHandler = this.fileHandler.bind(this);
}
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
console.log(err);
}
else {
let judul = resp.rows[0]
let isi = resp.rows.slice(1)
// let body = isi.map((item) => {
// return {
// item
// ]
// })
console.log(JSON.stringify(isi));
this.setState({
dataLoaded: true,
cols: judul,
rows: isi
});
}
});
} }
componentDidMount() { componentDidMount() {
this.getData()
}
getData() {
api.create().getPerusahaan().then((response) => {
console.log(response)
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.company_id, item.company_name, item.parent, item.businessUnitId, item.total_report, item.status]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
})
}
openPopUp(index, type) {
if (type === 'edit') {
this.setState({
selectIndex: index,
visibleEdit: true
})
} else {
this.setState({
data: this.state.listData[index],
visibleCreate: true
})
}
}
handleInputChange(e) {
this.setState({ search: e })
let body = {
"keyword": e
}
api.create().searchPerusahaan(body).then(response => {
// console.log(response.data);
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
// return [index, item.business_unit_id, item.business_unit_name, item.status]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
})
}
updatePerusahaan = (payload) => {
this.setState({ visibleEdit: false })
api.create().updatePerusahaan(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
})
}
createPerusahaan = (payload) => {
this.setState({ visibleCreate: false })
api.create().createPerusahaan(payload).then(response => {
if (response.data.status == 'success') {
this.getData()
} else {
alert(response.data.message)
}
})
} }
render() { render() {
console.log(this.props.height)
const columns = [{ const columns = [{
name: "Action", name: "Action",
options: { options: {
...@@ -40,7 +145,8 @@ export default class Perusahaan extends Component { ...@@ -40,7 +145,8 @@ export default class Perusahaan extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })} // onClick={() => this.setState({ visibleEdit: true, data: tableMeta.rowData })}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
...@@ -54,7 +160,7 @@ export default class Perusahaan extends Component { ...@@ -54,7 +160,7 @@ export default class Perusahaan extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
...@@ -65,7 +171,7 @@ export default class Perusahaan extends Component { ...@@ -65,7 +171,7 @@ export default class Perusahaan extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
...@@ -76,7 +182,7 @@ export default class Perusahaan extends Component { ...@@ -76,7 +182,7 @@ export default class Perusahaan extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
...@@ -87,7 +193,18 @@ export default class Perusahaan extends Component { ...@@ -87,7 +193,18 @@ export default class Perusahaan extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div >
);
}
}
}, {
name: "Jumlah Laporan",
options: {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
...@@ -98,75 +215,123 @@ export default class Perusahaan extends Component { ...@@ -98,75 +215,123 @@ export default class Perusahaan extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[5] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
} }
}] }]
const data = [ const data = [
["", "1", "Triputra Agro Persada Group", "Triputra Investindo Arya", "Agrobisnis", "Aktif"], ["", "1", "Triputra Agro Persada Group", "Triputra Investindo Arya", "Agrobisnis", "5", "Aktif"],
["", "2", "Gawi Bahandep Sawit Mekar", "Triputra Agro Persada Group", "Agrobisnis", "Aktif"], ["", "2", "Gawi Bahandep Sawit Mekar", "Triputra Agro Persada Group", "Agrobisnis", "2", "Aktif"],
["", "3", "Puninar Group", "Triputra Investindo Arya", "Service", "Aktif"], ["", "3", "Puninar Group", "Triputra Investindo Arya", "Service", "5", "Aktif"],
["", "4", "Puninar Infinite Raya", "Puninar Group", "Service", "Non Aktif"], ["", "4", "Puninar Infinite Raya", "Puninar Group", "Service", "5", "Non Aktif"],
["", "-", "-", "-", "-","-"], ["", "-", "-", "-", "-","-"],
] ]
return ( return (
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
<div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} /> <div style={{ height: 199, backgroundColor: '#354960', width: '100%' }} />
<div> {this.state.visiblePerusahaan === true ?
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Master Data - Perusahaan</label> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5 }}> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%' }}>Master Data - Perusahaan</label>
<img src={Images.searchBlack} style={{ marginRight: 10 }} /> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<InputBase <img src={Images.searchBlack} style={{ marginRight: 10 }} />
style={{ width: '100%' }} <InputBase
placeholder="Search" style={{ width: '100%' }}
inputProps={{ 'aria-label': 'naked' }} placeholder="Search"
/> value={this.state.search}
onChange={(e) => this.handleInputChange(e.target.value)}
inputProps={{ 'aria-label': 'naked' }}
/>
</div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex', flexFlow: 'wrap' }}>
<img src={Images.template} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
<img src={Images.download} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => null}
>
<img src={Images.visualisasi} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
</div>
</div> </div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}> <div style={{ padding: 25 }}>
<img src={Images.template} /> <MuiThemeProvider theme={getMuiTheme()}>
<img src={Images.upload} /> <MUIDataTable
<img src={Images.download} /> theme={getMuiTheme()}
<button data={this.state.dataTable}
style={{ columns={columns}
backgroundColor: 'transparent', options={options}
cursor: 'pointer', />
borderColor: 'transparent' </MuiThemeProvider>
}}
onClick={() => null} </div>
> </div>
<img src={Images.visualisasi} /> :
</button> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options2}
/>
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button <button
style={{ type="button"
backgroundColor: 'transparent', onClick={() => this.setState({ visiblePerusahaan: true })}
cursor: 'pointer', style={{ marginRight: 20 }}
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleCreate: true })}
> >
<img src={Images.add} /> <div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button> </button>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> }
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={data}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
</div>
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreatePerusahaan <CreatePerusahaan
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
type={"create"}
createPerusahaan={this.createPerusahaan.bind(this)}
/> />
)} )}
...@@ -174,9 +339,44 @@ export default class Perusahaan extends Component { ...@@ -174,9 +339,44 @@ export default class Perusahaan extends Component {
<CreatePerusahaan <CreatePerusahaan
type={"edit"} type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })} onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.data} data={this.state.listData[this.state.selectIndex]}
updatePerusahaan={this.updatePerusahaan.bind(this)}
/> />
)} )}
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<i className="fa fa-lg fa-times" style={{ color: 'white' }} />
</button>
</div>
</div>
<UploadFile
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
}}
onUpload={() => this.setState({ visibleUpload: false, visiblePerusahaan: false })}
/>
</div>
</div>
)}
</div> </div>
); );
} }
......
...@@ -6,6 +6,7 @@ import RemoveIcon from '@material-ui/icons/Remove'; ...@@ -6,6 +6,7 @@ import RemoveIcon from '@material-ui/icons/Remove';
import { DateTimePicker, KeyboardDatePicker, DatePicker} from "@material-ui/pickers"; import { DateTimePicker, KeyboardDatePicker, DatePicker} from "@material-ui/pickers";
import format from "date-fns/format"; import format from "date-fns/format";
import localeID from "date-fns/locale/id" import localeID from "date-fns/locale/id"
import * as R from 'ramda'
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -32,7 +33,13 @@ export default class AddRole extends Component { ...@@ -32,7 +33,13 @@ export default class AddRole extends Component {
roleName: '', roleName: '',
startDate: null, startDate: null,
endDate: null, endDate: null,
date: new Date() date: new Date(),
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
} }
} }
...@@ -48,16 +55,51 @@ export default class AddRole extends Component { ...@@ -48,16 +55,51 @@ export default class AddRole extends Component {
let data = this.state let data = this.state
let isDate = type !== ''? true : false let isDate = type !== ''? true : false
if (isDate && type == 'start_date') { if (isDate && type == 'start_date') {
this.setState({...data, startDate : format(e, 'yyyy-MM-dd')}) this.setState({...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else if (isDate && type == 'end_date') { } else if (isDate && type == 'end_date') {
this.setState({...data, endDate : format(e, 'yyyy-MM-dd')}) this.setState({...data, endDate : format(e, 'yyyy-MM-dd'),
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} else { } else {
this.setState({...data, [e.target.name] : e.target.value}) this.setState({...data, [e.target.name]: e.target.value,
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} }
} }
updateRole() { validasi() {
if (R.isEmpty(this.state.roleName)) {
this.setState({errorRoleName: true, msgErrorRN: 'Role Name tidak boleh kosong'})
} else if (R.isNil(this.state.startDate)) {
this.setState({errorStartDate: true, msgErrorSD: 'Start Date tidak boleh kosong'})
} else if (R.isNil(this.state.endDate)) {
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.addRole()
}
}
addRole() {
// let startDate = format(this.state.tempData.start_date, 'yyyy-MM-dd') // let startDate = format(this.state.tempData.start_date, 'yyyy-MM-dd')
// let endDate = format(this.state.tempData.end_date, 'yyyy-MM-dd') // let endDate = format(this.state.tempData.end_date, 'yyyy-MM-dd')
let payload = { let payload = {
...@@ -199,6 +241,8 @@ export default class AddRole extends Component { ...@@ -199,6 +241,8 @@ export default class AddRole extends Component {
name="roleName" name="roleName"
label="User Role" label="User Role"
value={this.state.roleName} value={this.state.roleName}
error={this.state.errorRoleName}
helperText={this.state.msgErrorRN}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value" // defaultValue="Default Value"
// helperText="Some important text" // helperText="Some important text"
...@@ -216,6 +260,8 @@ export default class AddRole extends Component { ...@@ -216,6 +260,8 @@ export default class AddRole extends Component {
label="Berlaku Mulai" label="Berlaku Mulai"
format="dd MMMM yyyy" format="dd MMMM yyyy"
value={this.state.startDate} value={this.state.startDate}
error={this.state.errorStartDate}
helperText={this.state.msgErrorSD}
onChange={(e) => this.handleChange(e, 'start_date')} onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
...@@ -234,6 +280,8 @@ export default class AddRole extends Component { ...@@ -234,6 +280,8 @@ export default class AddRole extends Component {
label="Berlaku Hingga" label="Berlaku Hingga"
format="dd MMMM yyyy" format="dd MMMM yyyy"
value={this.state.endDate} value={this.state.endDate}
error={this.state.errorEndDate}
helperText={this.state.msgErrorED}
onChange={(e) => this.handleChange(e, 'end_date')} onChange={(e) => this.handleChange(e, 'end_date')}
minDate={this.state.startDate} minDate={this.state.startDate}
KeyboardButtonProps={{ KeyboardButtonProps={{
...@@ -380,14 +428,25 @@ export default class AddRole extends Component { ...@@ -380,14 +428,25 @@ export default class AddRole extends Component {
</div> </div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}> <div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}> <div className="column-1" style={{ alignSelf: 'center' }}>
<div onClick={() => this.props.onClickClose()} style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span> type="button"
</div> onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</div>
</button>
</div> </div>
<div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}> <div className="column-2" style={{display: 'flex', justifyContent: 'flex-end', alignItems: 'center'}}>
<div onClick={() => this.updateRole()}style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <button
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> type="button"
</div> onClick={() => this.validasi()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -5,6 +5,7 @@ import AddIcon from '@material-ui/icons/Add'; ...@@ -5,6 +5,7 @@ import AddIcon from '@material-ui/icons/Add';
import RemoveIcon from '@material-ui/icons/Remove'; import RemoveIcon from '@material-ui/icons/Remove';
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers"; import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format"; import format from "date-fns/format";
import * as R from 'ramda'
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
color: '#51c6ea', color: '#51c6ea',
...@@ -27,7 +28,13 @@ export default class EditRole extends Component { ...@@ -27,7 +28,13 @@ export default class EditRole extends Component {
privileges: [], privileges: [],
checked: false, checked: false,
selectedIndex: 0, selectedIndex: 0,
date: new Date() date: new Date(),
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
} }
} }
...@@ -44,15 +51,32 @@ export default class EditRole extends Component { ...@@ -44,15 +51,32 @@ export default class EditRole extends Component {
let data = this.state let data = this.state
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') } }, () => { this.setState({ ...data, tempData: { ...this.state.tempData, start_date: format(e, 'yyyy-MM-dd'), end_date: null },
console.log(this.state.tempData) errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
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') } }, () => { this.setState({ ...data, tempData: { ...this.state.tempData, end_date: format(e, 'yyyy-MM-dd') },
console.log(this.state.tempData) errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
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 },
errorRoleName: false,
errorStartDate: false,
errorEndDate: false,
msgErrorRN: '',
msgErrorSD: '',
msgErrorED: '',
})
} }
} }
...@@ -68,6 +92,19 @@ export default class EditRole extends Component { ...@@ -68,6 +92,19 @@ export default class EditRole extends Component {
}) })
} }
validasi() {
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.updateRole()
}
}
updateRole() { updateRole() {
// let startDate = format(this.state.tempData.start_date, 'yyyy-MM-dd') // let startDate = format(this.state.tempData.start_date, 'yyyy-MM-dd')
...@@ -212,6 +249,8 @@ export default class EditRole extends Component { ...@@ -212,6 +249,8 @@ export default class EditRole extends Component {
name="role_name" name="role_name"
label="User Role" 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, '')} onChange={(e) => this.handleChange(e, '')}
// defaultValue="Default Value" // defaultValue="Default Value"
// helperText="Some important text" // helperText="Some important text"
...@@ -229,6 +268,8 @@ export default class EditRole extends Component { ...@@ -229,6 +268,8 @@ export default class EditRole extends Component {
label="Berlaku Mulai" label="Berlaku Mulai"
format="dd MMMM yyyy" 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')} onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
...@@ -247,6 +288,8 @@ export default class EditRole extends Component { ...@@ -247,6 +288,8 @@ export default class EditRole extends Component {
label="Berlaku Hingga" label="Berlaku Hingga"
format="dd MMMM yyyy" 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')} onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{ KeyboardButtonProps={{
...@@ -405,7 +448,7 @@ export default class EditRole extends Component { ...@@ -405,7 +448,7 @@ export default class EditRole extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button <button
type="button" type="button"
onClick={() => this.updateRole()} onClick={() => this.validasi()}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span> <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
......
const Constant = { const Constant = {
TOKEN: null, TOKEN: null,
USER: null, USER: null,
EMAIL: 'TOKEN',
PASSWORD: 'PASSWORD'
} }
export default Constant; export default Constant;
\ No newline at end of file
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