Commit 68ec52b1 authored by Deni Rinaldi's avatar Deni Rinaldi

uplad foto, hover button ++

parent 554bbb2d
...@@ -15360,6 +15360,20 @@ ...@@ -15360,6 +15360,20 @@
"xlsx": "^0.14.1" "xlsx": "^0.14.1"
} }
}, },
"react-flip-move": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-flip-move/-/react-flip-move-3.0.4.tgz",
"integrity": "sha512-HyUVv9g3t/BS7Yz9HgrtYSWyRNdR2F81nkj+C5iRY675AwlqCLB5JU9mnZWg0cdVz7IM4iquoyZx70vzZv3Z8Q=="
},
"react-images-upload": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/react-images-upload/-/react-images-upload-1.2.8.tgz",
"integrity": "sha512-d5mhAE0BfkLTlG5MLvKVw+q76LL8r5easgWW0TTBvXD8n6HXeLMZLwCuPiOibY1a3NRMXI4AnM1r34dqLOBjng==",
"requires": {
"react": "^16.12.0",
"react-flip-move": "^3.0.4"
}
},
"react-is": { "react-is": {
"version": "16.13.1", "version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"react-draggable-list": "^4.0.3", "react-draggable-list": "^4.0.3",
"react-dropzone": "^11.0.2", "react-dropzone": "^11.0.2",
"react-excel-renderer": "^1.1.0", "react-excel-renderer": "^1.1.0",
"react-images-upload": "^1.2.8",
"react-linechart": "^1.1.12", "react-linechart": "^1.1.12",
"react-nestable": "^1.3.0", "react-nestable": "^1.3.0",
"react-number-format": "^4.4.1", "react-number-format": "^4.4.1",
......
...@@ -89,6 +89,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -89,6 +89,8 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const checkUploadUnitBisnis = (body) => api.post('/business_unit/check_import', body) const checkUploadUnitBisnis = (body) => api.post('/business_unit/check_import', body)
const uploadUnitBisnis = (body) => api.post('/business_unit/import_business_unit', body) const uploadUnitBisnis = (body) => api.post('/business_unit/import_business_unit', body)
const getUnitBisnisActive = () => api.get('business_unit/get_all_business_unit_active') const getUnitBisnisActive = () => api.get('business_unit/get_all_business_unit_active')
const getDetailUnitBisnis = (id) => api.get(`business_unit/get_business_unit_by_id/${id}`)
// Perusahaan // Perusahaan
const getPerusahaan = () => api.get('company/get_all_company') const getPerusahaan = () => api.get('company/get_all_company')
...@@ -152,6 +154,10 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -152,6 +154,10 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
//Template //Template
const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`) const downloadTemplate = (fileName, fileType) => api.get(`attachment/download_file?fileName=${fileName}&&fileType=${fileType}`)
// UPLOAD FOTO
const uploadFoto = (body) => api.post('attachment/upload_foto', body)
// ------ // ------
// STEP 3 // STEP 3
// ------ // ------
...@@ -238,7 +244,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -238,7 +244,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
uploadPerusahaan, uploadPerusahaan,
searchPerusahaan, searchPerusahaan,
getUnitBisnisActive, getUnitBisnisActive,
getMenuByUser getMenuByUser,
getDetailUnitBisnis,
uploadFoto
} }
} }
......
...@@ -44,7 +44,8 @@ const Images = { ...@@ -44,7 +44,8 @@ const Images = {
logout: require('./setting.png'), logout: require('./setting.png'),
setting: require('./logout.png'), setting: require('./logout.png'),
failedCopy: require('./failed-copy.svg'), failedCopy: require('./failed-copy.svg'),
triputraLogo: require('./triputra-logo.png') triputraLogo: require('./triputra-logo.png'),
photo: require('./photo.svg')
} }
......
<svg xmlns="http://www.w3.org/2000/svg" width="93" height="30" viewBox="0 0 93 30">
<g fill="none" fill-rule="evenodd">
<rect width="93" height="30" fill="#019CE5" rx="4"/>
<g>
<path d="M0 0H24V24H0z" transform="translate(4 3)"/>
<g transform="translate(4 3) translate(5 6)">
<path fill="#FFF" d="M7.664 0c1.086 0 2 .743 2.259 1.749L11 1.75c1.657 0 3 1.343 3 3v4.5c0 1.657-1.343 3-3 3H3c-1.657 0-3-1.343-3-3v-4.5c0-1.657 1.343-3 3-3l1.074-.001C4.334.743 5.247 0 6.334 0h1.33z"/>
<circle cx="7" cy="7" r="3" fill="#019CE5"/>
</g>
</g>
<text fill="#FFF" font-family="Nunito-SemiBold, Nunito" font-size="11" font-weight="500">
<tspan x="32.43" y="19">Ganti Foto</tspan>
</text>
</g>
</svg>
...@@ -150,6 +150,7 @@ export default function MiniDrawer() { ...@@ -150,6 +150,7 @@ export default function MiniDrawer() {
const [selectedSubIndex, setSelectSub] = React.useState([]); const [selectedSubIndex, setSelectSub] = React.useState([]);
const [userFullname, setUserFullname] = React.useState("") const [userFullname, setUserFullname] = React.useState("")
const [userEmail, setUserEmail] = React.useState("") const [userEmail, setUserEmail] = React.useState("")
const [userPhoto, setUserPhoto] = React.useState("")
const [application, setApplication] = React.useState([]) const [application, setApplication] = React.useState([])
const [setting, setSetting] = React.useState([]) const [setting, setSetting] = React.useState([])
const [data, setData] = React.useState({ const [data, setData] = React.useState({
...@@ -316,7 +317,7 @@ export default function MiniDrawer() { ...@@ -316,7 +317,7 @@ export default function MiniDrawer() {
const parseChildren = (val) => { const parseChildren = (val) => {
let data = Object.assign([], val) let data = Object.assign([], val)
data = data.sort((a,b) => a.menu_id - b.menu_id).map((i) => { data = data.sort((a, b) => a.menu_id - b.menu_id).map((i) => {
return { return {
img: i.icon === '#' ? "" : i.icon, img: i.icon === '#' ? "" : i.icon,
label: i.menu_name, label: i.menu_name,
...@@ -331,21 +332,26 @@ export default function MiniDrawer() { ...@@ -331,21 +332,26 @@ export default function MiniDrawer() {
const getMenuHierarki = () => { const getMenuHierarki = () => {
api.create().getMenuByRole().then((response) => { api.create().getMenuByRole().then((response) => {
console.log(response) console.log(response)
if (response.data.status === "success") { if (response.data) {
let app = null if (response.data.status === "success") {
let set = null let app = null
response.data.data.map((item) => { let set = null
if (item.menu_name === "Application") { response.data.data.map((item) => {
app = parseChildren(item.sub_menu) if (item.menu_name === "Application") {
return app app = parseChildren(item.sub_menu)
} else { return app
set = parseChildren(item.sub_menu) } else {
return set set = parseChildren(item.sub_menu)
} return set
}) }
setApplication(app) })
setSetting(set) setApplication(app)
console.log(app); setSetting(set)
console.log(app);
} else {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
} else { } else {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
window.location.reload(); window.location.reload();
...@@ -356,9 +362,12 @@ export default function MiniDrawer() { ...@@ -356,9 +362,12 @@ export default function MiniDrawer() {
const getUserData = () => { const getUserData = () => {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
if (response.data.status == 'success') { if (response.data) {
setUserFullname(response.data.data.fullname == null ? 'Anonym' : response.data.data.fullname) if (response.data.status == 'success') {
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)
setUserPhoto(response.data.data.photo === null ? "" : response.data.data.photo)
}
} }
}) })
} }
...@@ -474,6 +483,7 @@ export default function MiniDrawer() { ...@@ -474,6 +483,7 @@ export default function MiniDrawer() {
<div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -45, display: 'flex', justifyContent: 'center' }}> <div style={{ width: '100%', textAlign: '-webkit-center', marginTop: -45, display: 'flex', justifyContent: 'center' }}>
<div className={"sub-color"} style={{ width: 90, height: 90, borderRadius: 50, display: 'flex', justifyContent: 'center' }}> <div className={"sub-color"} style={{ width: 90, height: 90, borderRadius: 50, display: 'flex', justifyContent: 'center' }}>
<div style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}> <div style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}>
<img src={userPhoto} style={{ width: 72, height: 72, borderRadius: 50 }} />
</div> </div>
</div> </div>
...@@ -488,7 +498,7 @@ export default function MiniDrawer() { ...@@ -488,7 +498,7 @@ export default function MiniDrawer() {
{application.map((item, index) => ( {application.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 5 }} > <div style={{ marginTop: index === 0 ? null : 5 }} >
{item.subItem.length !== 0 ? {item.subItem.length !== 0 ?
<div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10 }} onClick={() => { handleCollapse(item) }}> <div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10, cursor: 'pointer' }} onClick={() => { handleCollapse(item) }}>
<ListItem key={item.label}> <ListItem key={item.label}>
<ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon> <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography> <Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
...@@ -536,7 +546,7 @@ export default function MiniDrawer() { ...@@ -536,7 +546,7 @@ export default function MiniDrawer() {
{setting.map((item, index) => ( {setting.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 5 }} > <div style={{ marginTop: index === 0 ? null : 5 }} >
{item.subItem.length !== 0 ? {item.subItem.length !== 0 ?
<div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10 }} onClick={() => { handleCollapseSetting(item) }}> <div style={{ justifyContent: 'space-between', flexDirection: 'row', display: 'flex', paddingLeft: 5, paddingRight: 10, cursor: 'pointer' }} onClick={() => { handleCollapseSetting(item) }}>
<ListItem key={item.label}> <ListItem key={item.label}>
<ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon> <ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography> <Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
......
...@@ -42,11 +42,11 @@ class Login extends Component { ...@@ -42,11 +42,11 @@ class Login extends Component {
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
this.setState({...data, [e.target.name] : e.target.value}) this.setState({ ...data, [e.target.name]: e.target.value })
if (e.target.name == "email") { if (e.target.name == "email") {
this.setState({ errorEmail: false, msgEmail: '' }) this.setState({ errorEmail: false, msgEmail: '' })
} else if (e.target.name) { } else if (e.target.name) {
this.setState({ errorPassword: false, msgPassword: '' }) this.setState({ errorPassword: false, msgPassword: '' })
} }
} }
...@@ -56,23 +56,24 @@ class Login extends Component { ...@@ -56,23 +56,24 @@ 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) {
this.setState({ errorEmail: true, msgEmail: 'Format email tidak sesuai!' }) this.setState({ errorEmail: true, msgEmail: 'Format email tidak sesuai!' })
} else if (this.state.password.trim() == "") { } else if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' }) this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
} else { } else {
this.login() this.login()
} }
} }
login() { login() {
console.log('login');
let payload = { let payload = {
"email": this.state.email, "email": this.state.email,
"password": this.state.password "password": this.state.password
} }
api.create().login(payload).then((response) => { api.create().login(payload).then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
console.log(response.data.data) console.log(response.data.data)
...@@ -89,9 +90,9 @@ class Login extends Component { ...@@ -89,9 +90,9 @@ class Login extends Component {
this.props.history.push('/home/beranda') this.props.history.push('/home/beranda')
} else { } else {
if (response.data.message == 'Kata sandi tidak sesuai.') { if (response.data.message == 'Kata sandi tidak sesuai.') {
this.setState({ errorPassword: true, msgPassword: response.data.message }) this.setState({ errorPassword: true, msgPassword: response.data.message })
} else { } else {
this.setState({ errorEmail: true, msgEmail: response.data.message }) this.setState({ errorEmail: true, msgEmail: response.data.message })
} }
} }
}) })
...@@ -101,9 +102,9 @@ class Login extends Component { ...@@ -101,9 +102,9 @@ class Login extends Component {
var email = localStorage.getItem(Constant.EMAIL) var email = localStorage.getItem(Constant.EMAIL)
var password = localStorage.getItem(Constant.PASSWORD) var password = localStorage.getItem(Constant.PASSWORD)
if (email == null || password == null) { if (email == null || password == null) {
this.setState({email: '', password: ''}) this.setState({ email: '', password: '' })
} else if(email != '' && password != ''){ } else if (email != '' && password != '') {
this.setState({email, password}) this.setState({ email, password })
} }
} }
...@@ -116,63 +117,82 @@ class Login extends Component { ...@@ -116,63 +117,82 @@ class Login extends Component {
<img src={Images.imageLogin} style={{ marginTop: 30 }} /> <img src={Images.imageLogin} style={{ marginTop: 30 }} />
</div> </div>
<div style={{ width: '50%', height: '100vh', backgroundColor: '#152d40', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}> <div style={{ width: '50%', height: '100vh', backgroundColor: '#152d40', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
<div style={{ paddingTop: 56, paddingLeft: 54, paddingRight: 54, display: 'flex', flexDirection: 'column', width: 388, height: (this.state.msgEmail.length > 45 ? 466 : 441), borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}>
<img src={Images.tia} />
<TextField <form onSubmit={(e) => {
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>} e.preventDefault()
id="email" this.validateLogin()
type={"text"} }}
name={"email"} >
value={this.state.email} <div style={{ paddingTop: 56, paddingLeft: 54, paddingRight: 54, display: 'flex', flexDirection: 'column', width: 388, height: (this.state.msgEmail.length > 45 ? 466 : 441), borderRadius: 12, boxShadow: '0 2 4 0 rgba(0, 0, 0, 0.2)', backgroundColor: '#ffffff' }}>
onChange={(email) => { <img src={Images.tia} />
<TextField
label={<Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Email *</Typography>}
id="email"
type={"text"}
name={"email"}
value={this.state.email}
onChange={(email) => {
this.handleChange(email) this.handleChange(email)
}} }}
variant="outlined" variant="outlined"
error={this.state.errorEmail} error={this.state.errorEmail}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }} style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }}
helperText={this.state.msgEmail} helperText={this.state.msgEmail}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>, endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}} }}
/> />
<TextField <TextField
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Kata Sandi *</Typography>} label={<Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Kata Sandi *</Typography>}
id="password" id="password"
type={this.state.showPass ? 'text' : 'password'} type={this.state.showPass ? 'text' : 'password'}
name={"password"} name={"password"}
value={this.state.password} value={this.state.password}
onChange={(password) => { onChange={(password) => {
this.handleChange(password) this.handleChange(password)
}} }}
variant="outlined" variant="outlined"
error={this.state.errorPassword} error={this.state.errorPassword}
style={{ width: '100%', height: 51, marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 20 }} style={{ width: '100%', height: 51, marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 20 }}
helperText={this.state.msgPassword} helperText={this.state.msgPassword}
InputProps={{ onSubmit={() => this.validateLogin()}
endAdornment: <InputAdornment position="end"> InputProps={{
<IconButton endAdornment: <InputAdornment position="end">
aria-label="toggle password visibility" <IconButton
style={{color: '#4b4b4b', opacity: 0.5}} aria-label="toggle password visibility"
onClick={() => this.setState({showPass: !this.state.showPass})} style={{ color: '#4b4b4b', opacity: 0.5 }}
edge="end" onClick={() => this.setState({ showPass: !this.state.showPass })}
> edge="end"
{this.state.showPass ? <Visibility style={{fontSize: 18}} /> : <VisibilityOff style={{fontSize: 18}} />} >
</IconButton> {this.state.showPass ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
</InputAdornment>, </IconButton>
}} </InputAdornment>,
/> }}
/>
<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" checked={this.state.rememberMe} onChange={() => this.setState({rememberMe: !this.state.rememberMe})} /> <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>
<button
type="submit"
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
disabled={this.state.email.trim() == '' && this.state.password.trim() == '' ? true : false}
// onClick={() => this.validateLogin()}
>
<Button name="submit" variant="contained" disabled={this.state.email.trim() == '' && this.state.password.trim() == '' ? true : false} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4, color: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#d8d8d8' : '#51c6ea' }}>
<Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Login</Typography>
</Button>
</button>
</div> </div>
<Button name="submit" variant="contained" disabled={this.state.email.trim() == '' && this.state.password.trim() == '' ? true : false} onClick={() => this.validateLogin()} style={{ marginTop: 23, width: '100%', height: 35, borderRadius: 4, color: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#4b4b4b' : '#fff', backgroundColor: this.state.email.trim() == '' && this.state.password.trim() == '' ? '#d8d8d8' : '#51c6ea' }}> </form>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Login</Typography>
</Button>
</div>
</div> </div>
</div > </div >
); );
......
...@@ -495,9 +495,14 @@ export default class Parameter extends Component { ...@@ -495,9 +495,14 @@ export default class Parameter extends Component {
uploadParameter() { uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => { api.create().uploadParameter(this.state.payload).then(response => {
console.log(response) if (response.data) {
this.getAllParameter() if (response.data.status === "success") {
this.setState({ visibleParameter: true }) console.log(response)
alert(response.data.message)
this.getAllParameter()
this.setState({ visibleParameter: true })
}
}
}) })
} }
...@@ -648,49 +653,62 @@ export default class Parameter extends Component { ...@@ -648,49 +653,62 @@ export default class Parameter extends Component {
/> />
</div> </div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}> <div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}>
<button <a data-tip={'Download Template'} data-for="template">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadFile()} }}
> onClick={() => this.downloadFile()}
<img src={Images.template} /> >
</button> <img src={Images.template} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Upload'} data-for="upload">
borderColor: 'transparent', <button
margin: 5 style={{
}} backgroundColor: 'transparent',
onClick={() => this.setState({ visibleUpload: true })} cursor: 'pointer',
> borderColor: 'transparent',
<img src={Images.upload} /> margin: 5
</button> }}
<button onClick={() => this.setState({ visibleUpload: true })}
style={{ >
backgroundColor: 'transparent', <img src={Images.upload} />
cursor: 'pointer', </button>
borderColor: 'transparent', </a>
margin: 5 <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
}} <a data-tip={'Download'} data-for="download">
onClick={() => this.downloadDataTable()} <button
> style={{
<img src={Images.download} /> backgroundColor: 'transparent',
</button> cursor: 'pointer',
<button borderColor: 'transparent',
style={{ margin: 5
backgroundColor: 'transparent', }}
cursor: 'pointer', onClick={() => this.downloadDataTable()}
borderColor: 'transparent' >
}} <img src={Images.download} />
onClick={() => this.setState({ visibleCreate: true })} </button>
> </a>
<img src={Images.add} /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
</button> <a data-tip={'Tambah'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -777,7 +795,7 @@ export default class Parameter extends Component { ...@@ -777,7 +795,7 @@ export default class Parameter extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })} onClick={() => this.setState({ visibleUpload: false })}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -785,7 +803,7 @@ export default class Parameter extends Component { ...@@ -785,7 +803,7 @@ export default class Parameter extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["pdf"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
......
...@@ -49,7 +49,7 @@ export default class ReportItems extends Component { ...@@ -49,7 +49,7 @@ export default class ReportItems extends Component {
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
let payload = [] let payload = []
isi.map((item, index) => { isi.map((item, index) => {
if(item.length > 0) { if (item.length > 0) {
payload.push({ payload.push({
id: index + 1, id: index + 1,
report: item[0], report: item[0],
...@@ -452,8 +452,8 @@ export default class ReportItems extends Component { ...@@ -452,8 +452,8 @@ export default class ReportItems extends Component {
console.log(response) console.log(response)
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.item_report_id-b.item_report_id).map((item, index) => { let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status ] return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status]
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
...@@ -486,7 +486,7 @@ export default class ReportItems extends Component { ...@@ -486,7 +486,7 @@ export default class ReportItems extends Component {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let listData = data.map((item, index) => { let listData = data.map((item, index) => {
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status ] return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_report_name, item.status]
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data })
} else { } else {
...@@ -549,12 +549,17 @@ export default class ReportItems extends Component { ...@@ -549,12 +549,17 @@ export default class ReportItems extends Component {
uploadReportItems() { uploadReportItems() {
api.create().uploadReportItems(this.state.payload).then(response => { api.create().uploadReportItems(this.state.payload).then(response => {
console.log(response) if (response.data) {
this.getData() if (response.data.status === "success") {
this.setState({ itemReport: true }) console.log(response)
alert(response.data.message)
this.getData()
this.setState({ itemReport: true })
}
}
}) })
} }
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -569,7 +574,7 @@ export default class ReportItems extends Component { ...@@ -569,7 +574,7 @@ export default class ReportItems extends Component {
borderColor: 'transparent' borderColor: 'transparent'
}} }}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')} onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
...@@ -698,15 +703,15 @@ export default class ReportItems extends Component { ...@@ -698,15 +703,15 @@ export default class ReportItems extends Component {
} }
} }
} }
] ]
const data = [ const data = [
["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"], ["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "35%", "Formula", "Aktif"],
["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"], ["", "2", "KPI", "TIA", "2", "Trading Profit", "1", "Rp Bio", "35%", "Formula", "Aktif"],
["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"], ["", "3", "KPI", "TIA", "3", "Revenue", "1", "Rp Bio", "0%", "Formula", "Aktif"],
["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"], ["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"], ["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
] ]
return ( return (
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
{/* <Row> */} {/* <Row> */}
...@@ -726,60 +731,76 @@ export default class ReportItems extends Component { ...@@ -726,60 +731,76 @@ export default class ReportItems extends Component {
/> />
</div> </div>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button <a data-tip={'Download Template'} data-for="template">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadFile()} }}
> onClick={() => this.downloadFile()}
<img src={Images.template} /> >
</button> <img src={Images.template} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Upload'} data-for="upload">
borderColor: 'transparent', <button
margin: 5 style={{
}} backgroundColor: 'transparent',
onClick={() => null} cursor: 'pointer',
> borderColor: 'transparent',
<img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} /> margin: 5
</button> }}
<button onClick={() => null}
style={{ >
backgroundColor: 'transparent', <img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} />
cursor: 'pointer', </button>
borderColor: 'transparent', </a>
margin: 5 <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
}} <a data-tip={'Download'} data-for="download">
onClick={() => this.downloadDataTable()} <button
> style={{
<img src={Images.download} /> backgroundColor: 'transparent',
</button> cursor: 'pointer',
<button borderColor: 'transparent',
style={{ margin: 5
backgroundColor: 'transparent', }}
cursor: 'pointer', onClick={() => this.downloadDataTable()}
borderColor: 'transparent', >
margin: 5 <img src={Images.download} />
}} </button>
onClick={() => null} </a>
> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<img src={Images.visualisasi} onClick={() => this.setState({ visualisasi: true, itemReport: false })} /> <a data-tip={'Visualisasi'} data-for="visualisasi">
</button> <button
<button style={{
style={{ backgroundColor: 'transparent',
backgroundColor: 'transparent', cursor: 'pointer',
cursor: 'pointer', borderColor: 'transparent',
borderColor: 'transparent', margin: 5
margin: 5 }}
}} onClick={() => this.setState({ visualisasi: true, itemReport: false })}
> >
<img src={Images.add} onClick={() => this.setState({ add: true })} /> <img src={Images.visualisasi} />
</button> </button>
</a>
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" />
<a data-tip={'Tambah'} data-for="tambah">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
>
<img src={Images.add} onClick={() => this.setState({ add: true })} />
</button>
</a>
<ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -793,75 +814,75 @@ export default class ReportItems extends Component { ...@@ -793,75 +814,75 @@ export default class ReportItems extends Component {
</MuiThemeProvider> </MuiThemeProvider>
</div> </div>
</div> </div>
: :
this.state.visualisasi == true ? this.state.visualisasi == true ?
<VisualReportItems <VisualReportItems
onClickClose={() => this.setState({ visualisasi: false, itemReport: true })} onClickClose={() => this.setState({ visualisasi: false, itemReport: true })}
height= {this.props.height} height={this.props.height}
/> />
: :
<div style={{ height: this.props.height }}> <div style={{ height: this.props.height }}>
<div style={{ height: 199, width: '100%' }} className={"main-color"}/> <div style={{ height: 199, width: '100%' }} className={"main-color"} />
<div>
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
</div> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
<div style={{ padding: 25 }}> </div>
{this.state.dataLoaded && ( <div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}> {this.state.dataLoaded && (
<MUIDataTable <MuiThemeProvider theme={getMuiTheme()}>
theme={getMuiTheme()} <MUIDataTable
data={this.state.rows} theme={getMuiTheme()}
columns={this.state.cols} data={this.state.rows}
options={options} columns={this.state.cols}
/> options={options}
</MuiThemeProvider> />
)} </MuiThemeProvider>
</div> )}
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}> </div>
<button <div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
type="button" <button
onClick={() => this.setState({ itemReport: true })} type="button"
style={{ marginRight: 20}} onClick={() => this.setState({ itemReport: true })}
> style={{ marginRight: 20 }}
<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 style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
</div> <span style={{ color: '#354960', fontSize: 11 }}>Batal</span>
</button> </div>
<button </button>
type="button" <button
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadReportItems()} type="button"
style={{}} onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadReportItems()}
> style={{}}
<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 style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
</div> <span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</button> </div>
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
} }
{this.state.add && ( {this.state.add && (
<CreateReportItems <CreateReportItems
onClickClose={() => this.setState({ add: false })} onClickClose={() => this.setState({ add: false })}
data={this.state.listData} data={this.state.listData}
refresh={this.getData.bind(this)} refresh={this.getData.bind(this)}
createReportItems={this.createReportItems.bind(this)} createReportItems={this.createReportItems.bind(this)}
/> />
)} )}
{this.state.edit && ( {this.state.edit && (
<EditReportItems <EditReportItems
onClickClose={() => this.setState({ edit: false })} onClickClose={() => this.setState({ edit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.listData[this.state.selectIndex]}
refresh={this.getData.bind(this)} refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)} updateReportItems={this.updateReportItems.bind(this)}
/> />
)} )}
{this.state.popupError && ( {this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} /> <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)} )}
{this.state.visibleUpload && ( {this.state.visibleUpload && (
<div className="test app-popup-show"> <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 }}>
...@@ -877,7 +898,7 @@ export default class ReportItems extends Component { ...@@ -877,7 +898,7 @@ export default class ReportItems extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })} onClick={() => this.setState({ visibleUpload: false })}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -885,7 +906,7 @@ export default class ReportItems extends Component { ...@@ -885,7 +906,7 @@ export default class ReportItems extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["pdf"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
...@@ -895,7 +916,7 @@ export default class ReportItems extends Component { ...@@ -895,7 +916,7 @@ export default class ReportItems extends Component {
</div> </div>
</div> </div>
)} )}
</div> </div>
); );
} }
} }
...@@ -183,27 +183,31 @@ export default class UnitBisnis extends Component { ...@@ -183,27 +183,31 @@ export default class UnitBisnis extends Component {
getData() { getData() {
api.create().getUnitBisnis().then((response) => { api.create().getUnitBisnis().then((response) => {
console.log(response) console.log(response)
if (response.data.status == 'success') { if (response.data) {
let data = response.data.data if (response.data.status == 'success') {
let listData = data.sort((a,b) => a.business_unit_id - b.business_unit_id).map((item, index) => { let data = response.data.data
return [index, item.business_unit_id, item.business_unit_name, item.status] let listData = data.sort((a, b) => a.business_unit_id - b.business_unit_id).map((item, index) => {
}) return [index, item.business_unit_id, item.business_unit_name, item.status]
this.setState({ dataTable: listData, listData: response.data.data }) })
this.setState({ dataTable: listData, listData: response.data.data })
} else {
alert(response.data.message)
}
} else { } else {
alert(response.data.message) this.setState({ dataTable: [] })
} }
}) })
} }
openPopUp(index, type) { openPopUp(rowData, type) {
if (type === 'edit') { if (type === 'edit') {
this.setState({ this.setState({
selectIndex: index, rowData: rowData,
visibleEdit: true visibleEdit: true
}) })
} else { } else {
this.setState({ this.setState({
data: this.state.listData[index], rowData: rowData,
visibleCreate: true visibleCreate: true
}) })
} }
...@@ -232,6 +236,7 @@ export default class UnitBisnis extends Component { ...@@ -232,6 +236,7 @@ export default class UnitBisnis extends Component {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => { api.create().updateUnitBisnis(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
} else { } else {
alert(response.data.message) alert(response.data.message)
...@@ -283,8 +288,11 @@ export default class UnitBisnis extends Component { ...@@ -283,8 +288,11 @@ export default class UnitBisnis extends Component {
uploadUnitBisnis() { uploadUnitBisnis() {
api.create().uploadUnitBisnis(this.state.payload).then(response => { api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
this.getData() if (response.data.status === "success") {
this.setState({ visibleUnitBisnis: true }) alert(response.data.message)
this.getData()
this.setState({ visibleUnitBisnis: true })
}
}) })
} }
...@@ -301,8 +309,8 @@ export default class UnitBisnis extends Component { ...@@ -301,8 +309,8 @@ export default class UnitBisnis extends Component {
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
}} }}
// onClick={() => console.log(tableMeta.rowData[1])} // onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')} onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
...@@ -368,53 +376,64 @@ export default class UnitBisnis extends Component { ...@@ -368,53 +376,64 @@ export default class UnitBisnis extends Component {
onChange={(e) => this.handleInputChange(e.target.value)} onChange={(e) => this.handleInputChange(e.target.value)}
inputProps={{ 'aria-label': 'naked' }} inputProps={{ 'aria-label': 'naked' }}
/> />
{/* <input type="text" value={this.state.search} onChange={(e)=> this.setState({ search: e.target.value})} style={{ width: '100%'}} /> */}
</div> </div>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button <a data-tip={'Download Template'} data-for="template">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadFile()} }}
> onClick={() => this.downloadFile()}
<img src={Images.template} /> >
</button> <img src={Images.template} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Upload'} data-for="upload">
borderColor: 'transparent', <button
margin: 5 style={{
}} backgroundColor: 'transparent',
onClick={() => this.setState({ visibleUpload: true })} cursor: 'pointer',
> borderColor: 'transparent',
<img src={Images.upload} /> margin: 5
</button> }}
<button onClick={() => this.setState({ visibleUpload: true })}
style={{ >
backgroundColor: 'transparent', <img src={Images.upload} />
cursor: 'pointer', </button>
borderColor: 'transparent', </a>
margin: 5 <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
}} <a data-tip={'Download'} data-for="download">
onClick={() => this.downloadDataTable()} <button
> style={{
<img src={Images.download} /> backgroundColor: 'transparent',
</button> cursor: 'pointer',
<button borderColor: 'transparent',
style={{ margin: 5
backgroundColor: 'transparent', }}
cursor: 'pointer', onClick={() => this.downloadDataTable()}
borderColor: 'transparent', >
margin: 5 <img src={Images.download} />
}} </button>
onClick={() => this.setState({ visibleCreate: true })} </a>
> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<img src={Images.add} /> <a data-tip={'Tambah'} data-for="create">
</button> <button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -481,12 +500,12 @@ export default class UnitBisnis extends Component { ...@@ -481,12 +500,12 @@ export default class UnitBisnis extends Component {
<CreateUnitBisnis <CreateUnitBisnis
type={"edit"} type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })} onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.rowData}
updateUnitBisnis={this.updateUnitBisnis.bind(this)} updateUnitBisnis={this.updateUnitBisnis.bind(this)}
/> />
)} )}
{this.state.popupError && ( {this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} /> <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)} )}
{this.state.visibleUpload && ( {this.state.visibleUpload && (
...@@ -504,7 +523,7 @@ export default class UnitBisnis extends Component { ...@@ -504,7 +523,7 @@ export default class UnitBisnis extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })} onClick={() => this.setState({ visibleUpload: false })}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -512,7 +531,7 @@ export default class UnitBisnis extends Component { ...@@ -512,7 +531,7 @@ export default class UnitBisnis extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["pdf"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
......
...@@ -4,12 +4,14 @@ import * as R from 'ramda' ...@@ -4,12 +4,14 @@ import * as R from 'ramda'
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 Images from '../../../assets/Images'; import Images from '../../../assets/Images';
import api from '../../../api';
export default class CreateUnitBisnis extends Component { export default class CreateUnitBisnis extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
id: '', id: '',
status:"",
name: '', name: '',
startDate: '', startDate: '',
endDate: '', endDate: '',
...@@ -28,16 +30,44 @@ export default class CreateUnitBisnis extends Component { ...@@ -28,16 +30,44 @@ export default class CreateUnitBisnis extends Component {
componentDidMount() { componentDidMount() {
if (this.props.type === 'edit') { if (this.props.type === 'edit') {
let data = this.props.data this.getDetailUnitBisnis()
console.log(this.props.data);
// this.setState({
// id: data[0],
// name: data[1],
// startDate: data[2],
// endDate: data[3]
// })
} else {
let date = format(new Date, 'yyyy-MM-dd')
console.log(date);
this.setState({ this.setState({
id: data.business_unit_id, startDate: date,
name: data.business_unit_name, endDate: date
startDate: data.start_date,
endDate: data.end_date
}) })
} }
} }
getDetailUnitBisnis() {
api.create().getDetailUnitBisnis(this.props.data[1]).then(response => {
console.log(response)
if (response.data) {
if (response.data.status === "success") {
let data = response.data.data
this.setState({
id: data.business_unit_id,
name: data.business_unit_name,
startDate: data.start_date,
endDate: data.end_date,
status: data.status,
created: data.created,
updated: data.updated === null ? "" : data.updated
})
}
}
})
}
handleChange(e, type) { handleChange(e, type) {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
...@@ -90,9 +120,9 @@ export default class CreateUnitBisnis extends Component { ...@@ -90,9 +120,9 @@ export default class CreateUnitBisnis extends Component {
if (R.isEmpty(this.state.name)) { if (R.isEmpty(this.state.name)) {
this.setState({ errorName: true, msgErrorName: 'Unit Bisnis tidak boleh kosong' }) this.setState({ errorName: true, msgErrorName: 'Unit Bisnis tidak boleh kosong' })
} else if (R.isEmpty(this.state.startDate)) { } else if (R.isEmpty(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Tanggal Mulai tidak boleh kosong' }) this.setState({ errorStartDate: true, msgErrorStartDate: 'Berlaku Mulai tidak boleh kosong' })
} else if (R.isEmpty(this.state.endDate)) { } else if (R.isEmpty(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'Tanggal Berakhir tidak boleh kosong' }) this.setState({ errorEndDate: true, msgErrorEndDate: 'Berkahir Hingga tidak boleh kosong' })
} else { } else {
let payload = { let payload = {
"business_unit_name": this.state.name, "business_unit_name": this.state.name,
...@@ -119,7 +149,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -119,7 +149,7 @@ export default class CreateUnitBisnis extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -130,8 +160,8 @@ export default class CreateUnitBisnis extends Component { ...@@ -130,8 +160,8 @@ export default class CreateUnitBisnis 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.business_unit_id} value={this.state.id}
id="status" id="id"
label="ID" label="ID"
disabled disabled
inputProps={{ inputProps={{
...@@ -178,7 +208,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -178,7 +208,7 @@ export default class CreateUnitBisnis extends Component {
<div className="margin-top-10px" 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.status} value={this.state.status}
id="status" id="status"
label="Status" label="Status"
disabled disabled
...@@ -199,11 +229,11 @@ export default class CreateUnitBisnis extends Component { ...@@ -199,11 +229,11 @@ export default class CreateUnitBisnis extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.created}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
</div> </div>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography> <Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography> <Typography style={{ fontSize: 11 }}>: {this.state.updated}</Typography>
</div> </div>
</div> </div>
</div> </div>
...@@ -307,7 +337,7 @@ export default class CreateUnitBisnis extends Component { ...@@ -307,7 +337,7 @@ export default class CreateUnitBisnis extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -385,8 +415,8 @@ export default class CreateUnitBisnis extends Component { ...@@ -385,8 +415,8 @@ export default class CreateUnitBisnis 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> <Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography> <Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div> </div>
</div> </div>
......
...@@ -7,7 +7,7 @@ import AddUser from './User/AddUser'; ...@@ -7,7 +7,7 @@ import AddUser from './User/AddUser';
import EditUser from './User/EditUser' import EditUser from './User/EditUser'
import api from "../../api"; import api from "../../api";
import { titleCase } from "../../library/Utils"; import { titleCase } from "../../library/Utils";
import { InputAdornment, TextField } from "@material-ui/core"; import { InputAdornment, TextField, InputBase } from "@material-ui/core";
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import ReactTooltip from "react-tooltip"; import ReactTooltip from "react-tooltip";
...@@ -46,8 +46,8 @@ export default class UserRole extends Component { ...@@ -46,8 +46,8 @@ export default class UserRole extends Component {
api.create().getUser().then((response) => { api.create().getUser().then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.user_id - b.user_id).map((item, index) => { 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.totalCompany, item.status] return [index, item.user_id, item.fullname === null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
...@@ -63,8 +63,8 @@ export default class UserRole extends Component { ...@@ -63,8 +63,8 @@ export default class UserRole extends Component {
api.create().searchUser(payload).then((response) => { api.create().searchUser(payload).then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.user_id - b.user_id).map((item, index) => { 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.totalCompany, item.status] return [index, item.user_id, item.fullname == null ? '-' : item.fullname, item.email, item.role_name, item.totalCompany, item.status]
}) })
this.setState({ listUser: listData }) this.setState({ listUser: listData })
} else { } else {
...@@ -278,9 +278,14 @@ export default class UserRole extends Component { ...@@ -278,9 +278,14 @@ export default class UserRole extends Component {
uploadUser() { uploadUser() {
api.create().uploadUser(this.state.payload).then(response => { api.create().uploadUser(this.state.payload).then(response => {
console.log(response) if (response.data) {
this.getUser() if (response.data.status === "success") {
this.setState({ visibleUser: true }) console.log(response)
alert(response.data.message)
this.getUser()
this.setState({ visibleUser: true })
}
}
}) })
} }
...@@ -291,19 +296,19 @@ export default class UserRole extends Component { ...@@ -291,19 +296,19 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[6] === "Aktif" ? {tableMeta.rowData[6] === "Aktif" ?
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
}} }}
// onClick={() => console.log(tableMeta.rowData[1])} // onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })} onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
> >
<img src={Images.editCopy} /> <img src={Images.editCopy} />
</button> </button>
: :
null null
} }
</div > </div >
...@@ -315,7 +320,7 @@ export default class UserRole extends Component { ...@@ -315,7 +320,7 @@ export default class UserRole extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex'}}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span>
</div > </div >
); );
...@@ -326,7 +331,7 @@ export default class UserRole extends Component { ...@@ -326,7 +331,7 @@ export default class UserRole extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex'}}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span>
</div > </div >
); );
...@@ -337,7 +342,7 @@ export default class UserRole extends Component { ...@@ -337,7 +342,7 @@ export default class UserRole extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex'}}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span>
</div > </div >
); );
...@@ -348,7 +353,7 @@ export default class UserRole extends Component { ...@@ -348,7 +353,7 @@ export default class UserRole extends Component {
options: { options: {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex'}}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span> <span style={{ color: tableMeta.rowData[6] === "Aktif" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span>
</div > </div >
); );
...@@ -383,8 +388,8 @@ export default class UserRole extends Component { ...@@ -383,8 +388,8 @@ export default class UserRole extends Component {
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
{this.state.visibleUser ? <div> {this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18 }}>Master Data - User</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - User</label>
<div style={{ width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}> {/* <div style={{ width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{ width: '50%', backgroundColor: 'white', padding: 10, borderRadius: 7.5 }}> <div style={{ width: '50%', backgroundColor: 'white', padding: 10, borderRadius: 7.5 }}>
<TextField <TextField
id="input-with-icon-textfield" id="input-with-icon-textfield"
...@@ -412,62 +417,83 @@ export default class UserRole extends Component { ...@@ -412,62 +417,83 @@ export default class UserRole extends Component {
}} }}
/> />
</div> </div>
</div> */}
<div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase
style={{ width: '100%' }}
placeholder="Search"
value={this.state.search}
onChange={(e) => {
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchUser()
} else {
this.getUser()
}
});
}}
inputProps={{ 'aria-label': 'naked' }}
/>
</div> </div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */} {/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}> <div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<button <a data-tip={'Download Template'} data-for="template">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
margin: 5 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadFile()} }}
> onClick={() => this.downloadFile()}
<img src={Images.template} /> >
</button> <img src={Images.template} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Upload'} data-for="upload">
borderColor: 'transparent', <button
marginTop: 5, style={{
marginBottom: 5, backgroundColor: 'transparent',
marginRight: 5, cursor: 'pointer',
marginLeft: 20 borderColor: 'transparent',
}} margin: 5
onClick={() => this.setState({ visibleUpload: true })} }}
> onClick={() => this.setState({ visibleUpload: true })}
<img src={Images.upload} /> >
</button> <img src={Images.upload} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Download'} data-for="download">
borderColor: 'transparent', <button
marginTop: 5, style={{
marginBottom: 5, backgroundColor: 'transparent',
marginRight: 5, cursor: 'pointer',
marginLeft: 20 borderColor: 'transparent',
}} margin: 5
onClick={() => this.downloadDataTables()} }}
> onClick={() => this.downloadDataTables()}
<img src={Images.download} /> >
</button> <img src={Images.download} />
<button </button>
style={{ </a>
backgroundColor: 'transparent', <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
cursor: 'pointer', <a data-tip={'Tambah'} data-for="create">
borderColor: 'transparent', <button
marginTop: 5, style={{
marginBottom: 5, backgroundColor: 'transparent',
marginRight: 5, cursor: 'pointer',
marginLeft: 20 borderColor: 'transparent',
}} margin: 5
onClick={() => this.setState({ add: true })} }}
> onClick={() => this.setState({ add: true })}
<img src={Images.add} /> >
</button> <img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -538,7 +564,7 @@ export default class UserRole extends Component { ...@@ -538,7 +564,7 @@ export default class UserRole extends Component {
{this.state.visibleUpload && ( {this.state.visibleUpload && (
<div className="test app-popup-show"> <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 main-color" style={{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' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Upload File</span>
...@@ -550,7 +576,7 @@ export default class UserRole extends Component { ...@@ -550,7 +576,7 @@ export default class UserRole extends Component {
className="btn btn-circle btn-white" className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })} onClick={() => this.setState({ visibleUpload: false })}
> >
<img src={Images.close}/> <img src={Images.close} />
</button> </button>
</div> </div>
</div> </div>
...@@ -558,7 +584,7 @@ export default class UserRole extends Component { ...@@ -558,7 +584,7 @@ export default class UserRole extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["pdf"]} acceptedFiles={["xlsx"]}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
......
...@@ -263,7 +263,7 @@ export default class AddUser extends Component { ...@@ -263,7 +263,7 @@ export default class AddUser extends Component {
return ( return (
<div className="test app-popup-show"> <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 main-color" style={{ 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' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span>
......
...@@ -299,7 +299,7 @@ export default class EditUser extends Component { ...@@ -299,7 +299,7 @@ export default class EditUser extends Component {
return ( return (
<div className="test app-popup-show"> <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 main-color" style={{ 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' }}>
<div className="popup-title"> <div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span>
......
...@@ -9,6 +9,8 @@ import api from "../../api"; ...@@ -9,6 +9,8 @@ import api from "../../api";
import { titleCase } from "../../library/Utils"; import { titleCase } from "../../library/Utils";
import InputAdornment from '@material-ui/core/InputAdornment'; import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
import { InputBase } from "@material-ui/core";
import ReactTooltip from "react-tooltip";
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();
...@@ -30,11 +32,11 @@ class UserRole extends Component { ...@@ -30,11 +32,11 @@ class UserRole extends Component {
} }
closeEdit() { closeEdit() {
this.setState({edit: false}) this.setState({ edit: false })
} }
closeAdd() { closeAdd() {
this.setState({add: false}) this.setState({ add: false })
} }
getRole() { getRole() {
...@@ -42,15 +44,15 @@ class UserRole extends Component { ...@@ -42,15 +44,15 @@ class UserRole extends Component {
// console.log(response) // console.log(response)
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.role_id - b.role_id).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] return [index, item.role_id, item.role_name, item.access, item.status]
}) })
// console.log(listData) // console.log(listData)
this.setState({listRole: listData}) this.setState({ listRole: listData })
// this.setState({listRole: response.data.data}, () => { // this.setState({listRole: response.data.data}, () => {
// console.log(this.state.listRole) // console.log(this.state.listRole)
// }) // })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -65,14 +67,14 @@ class UserRole extends Component { ...@@ -65,14 +67,14 @@ class UserRole extends Component {
api.create().searchRole(payload).then((response) => { api.create().searchRole(payload).then((response) => {
if (response.data.status === 'success') { if (response.data.status === 'success') {
let data = response.data.data let data = response.data.data
let listData = data.sort((a,b) => a.role_id - b.role_id).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] return [index, item.role_id, item.role_name, item.access, item.status]
}) })
this.setState({listRole: listData}) this.setState({ listRole: listData })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
}) })
} }
_handleKeyDown(e) { _handleKeyDown(e) {
...@@ -87,9 +89,9 @@ class UserRole extends Component { ...@@ -87,9 +89,9 @@ class UserRole extends Component {
handleChange(e) { handleChange(e) {
let data = this.state let data = this.state
window.requestIdleCallback((e) => this.setState({...data, [e.target.name]: e.target.value}, () => { window.requestIdleCallback((e) => this.setState({ ...data, [e.target.name]: e.target.value }, () => {
alert('asdk') alert('asdk')
})) }))
} }
...@@ -107,15 +109,15 @@ class UserRole extends Component { ...@@ -107,15 +109,15 @@ class UserRole extends Component {
borderColor: 'transparent', borderColor: 'transparent',
}} }}
// onClick={() => console.log(tableMeta.rowData[1])} // onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => this.setState({edit: true, indexData: tableMeta.rowData[1]})} onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
> >
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{ tableMeta.rowData[4] === "Aktif" ? {tableMeta.rowData[4] === "Aktif" ?
<img src={Images.editCopy}/> : <img src={Images.editCopy} /> :
null null
} }
</div > </div >
</button> </button>
</div > </div >
); );
...@@ -172,39 +174,41 @@ class UserRole extends Component { ...@@ -172,39 +174,41 @@ class UserRole extends Component {
<div className={"main-color"} style={{ height: 199, width: '100%' }} /> <div className={"main-color"} style={{ height: 199, width: '100%' }} />
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18}}>Master Data - Role & Otorisasi</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Otorisasi</label>
<div style={{width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}> <div style={{ color: 'white', width: '50%', height: 37, display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center', borderRadius: 6, paddingLeft: 5, paddingRight: 5, alignSelf: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}> <img src={Images.searchBlack} style={{ marginRight: 10 }} />
<TextField <InputBase
id="input-with-icon-textfield" style={{ width: '100%' }}
name="search" placeholder="Search"
value={this.state.search} value={this.state.search}
placeholder={'Search'} onChange={(e) => {
onChange={(e) => { this.setState({ search: e.target.value }, () => {
this.setState({ search: e.target.value }, () => { if (this.state.search.length > 0) {
if (this.state.search.length > 0) { this.searchRole()
this.searchRole() } else {
} else { this.getRole()
this.getRole() }
} });
}); }}
}} inputProps={{ 'aria-label': 'naked' }}
onKeyDown={(e) => this._handleKeyDown(e)} />
style={{width: '100%', borderBottomWidth: 0, borderBottomColor: 'red'}}
InputProps={{
style: { fontFamily: 'nunito', borderBottomColor: 'white'},
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
/>
</div>
</div> </div>
{/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */} {/* <label style={{ color: 'white', width: '60%', justifyContent: 'center', display: 'flex', backgroundColor: 'white', borderWidth: 2, alignItems: 'center' }}>Search</label> */}
<div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}> <div style={{ width: '20%', justifyContent: 'flex-end', display: 'flex' }}>
<img src={Images.add} onClick={() => this.setState({add: true})}/> <a data-tip={'Tambah'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ add: true })}
>
<img src={Images.add} />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div> </div>
</div> </div>
<div style={{ padding: 25 }}> <div style={{ padding: 25 }}>
...@@ -218,14 +222,14 @@ class UserRole extends Component { ...@@ -218,14 +222,14 @@ class UserRole extends Component {
</div> </div>
</div> </div>
{this.state.add && ( {this.state.add && (
<AddRole <AddRole
onClickClose={this.closeAdd.bind(this)} onClickClose={this.closeAdd.bind(this)}
refresh={this.getRole.bind(this)} refresh={this.getRole.bind(this)}
data={this.state.indexData} data={this.state.indexData}
/> />
)} )}
{this.state.edit && ( {this.state.edit && (
<EditRole <EditRole
onClickClose={this.closeEdit.bind(this)} onClickClose={this.closeEdit.bind(this)}
refresh={this.getRole.bind(this)} refresh={this.getRole.bind(this)}
data={this.state.indexData} data={this.state.indexData}
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, AppBar, Tabs, Tab, TextField, Collapse, withStyles, Checkbox } from '@material-ui/core'; import { Typography, AppBar, Tabs, Tab, TextField, Collapse, withStyles, Checkbox, InputAdornment, IconButton } from '@material-ui/core';
import Visibility from '@material-ui/icons/Visibility';
import VisibilityOff from '@material-ui/icons/VisibilityOff';
import HomePage from './HomePage'; import HomePage from './HomePage';
import Images from '../assets/Images'; import Images from '../assets/Images';
import api from '../api'; import api from '../api';
...@@ -8,6 +10,7 @@ import RemoveIcon from '@material-ui/icons/Remove'; ...@@ -8,6 +10,7 @@ import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add'; import AddIcon from '@material-ui/icons/Add';
import { titleCase } from '../library/Utils'; import { titleCase } from '../library/Utils';
import * as R from 'ramda' import * as R from 'ramda'
import ImageUploader from 'react-images-upload';
const CustomCheckbox = withStyles({ const CustomCheckbox = withStyles({
root: { root: {
...@@ -35,8 +38,14 @@ export default class Profile extends Component { ...@@ -35,8 +38,14 @@ export default class Profile extends Component {
msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.', msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
company: [], company: [],
listCompany: [], listCompany: [],
selectedIndex: 0 selectedIndex: 0,
showPass: false,
showPass2: false,
showPass3: false,
pictures: [],
name: ""
} }
this.onDrop = this.onDrop.bind(this);
} }
componentDidMount() { componentDidMount() {
...@@ -101,10 +110,12 @@ export default class Profile extends Component { ...@@ -101,10 +110,12 @@ export default class Profile extends Component {
} }
api.create().changePassword(body).then(response => { api.create().changePassword(body).then(response => {
console.log(response); console.log(response);
if (response.data.status === "success") { if (response.data) {
this.setState({ oldPassword: "", password: "", confirmPassword: "" }) if (response.data.status === "success") {
alert(response.data.message) this.setState({ oldPassword: "", password: "", confirmPassword: "" })
} else { localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
alert(response.data.message) alert(response.data.message)
} }
}) })
...@@ -124,8 +135,9 @@ export default class Profile extends Component { ...@@ -124,8 +135,9 @@ export default class Profile extends Component {
getUser() { getUser() {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
console.log(response);
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.setState({ company: response.data.data.company }) this.setState({ company: response.data.data.company, photo: response.data.data.photo, name: response.data.data.fullname })
console.log(response) console.log(response)
} }
...@@ -134,9 +146,12 @@ export default class Profile extends Component { ...@@ -134,9 +146,12 @@ export default class Profile extends Component {
getPerusahaan() { getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => { api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status == 'success') { // console.log(response);
this.setState({ listCompany: response.data.data }) if (response.data) {
console.log(response.data.data) if (response.data.status == 'success') {
this.setState({ listCompany: response.data.data })
console.log(response.data.data)
}
} }
}) })
} }
...@@ -158,28 +173,28 @@ export default class Profile extends Component { ...@@ -158,28 +173,28 @@ export default class Profile extends Component {
{item.children.map((data, index) => { {item.children.map((data, index) => {
return ( return (
// <li> // <li>
<Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}> <Collapse key={index} timeout="auto" unmountOnExit in={item.collapse}>
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: R.isNil(data.children) ? (padding + 20) : padding }}>
{R.isNil(data.children)? {R.isNil(data.children) ?
null null
: :
data.children.length < 1? data.children.length < 1 ?
null null
: :
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}> <span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} {data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span> </span>
} }
<span> <span>
<CustomCheckbox <CustomCheckbox
checked={this.handleItemChecked(data)} checked={this.handleItemChecked(data)}
onChange={() => null} onChange={() => null}
/> />
</span> </span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography> <Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div> </div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)} {!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse> </Collapse>
// </li> // </li>
) )
})} })}
...@@ -188,64 +203,103 @@ export default class Profile extends Component { ...@@ -188,64 +203,103 @@ export default class Profile extends Component {
} }
handleCollapse(item) { handleCollapse(item) {
let path = this.searchIt({children: this.state.listCompany}, item.id) let path = this.searchIt({ children: this.state.listCompany }, item.id)
let listCompany = this.state.listCompany let listCompany = this.state.listCompany
let arrayPath = [] let arrayPath = []
if (path.length > 1) { if (path.length > 1) {
arrayPath = path.split('-'); arrayPath = path.split('-');
arrayPath = arrayPath.map((item) => {return item}) arrayPath = arrayPath.map((item) => { return item })
} else { } else {
arrayPath.push(path) arrayPath.push(path)
} }
let pathSelect = null let pathSelect = null
if (arrayPath.length == 1) { if (arrayPath.length == 1) {
pathSelect= listCompany[arrayPath[0]] pathSelect = listCompany[arrayPath[0]]
} else if (arrayPath.length == 2) { } else if (arrayPath.length == 2) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]]
} else if (arrayPath.length == 3) { } else if (arrayPath.length == 3) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]]
} else if (arrayPath.length == 4) { } else if (arrayPath.length == 4) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]]
} else if (arrayPath.length == 5) { } else if (arrayPath.length == 5) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]]
} else if (arrayPath.length == 6) { } else if (arrayPath.length == 6) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]]
} else if (arrayPath.length == 7) { } else if (arrayPath.length == 7) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]].children[arrayPath[6]] pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]].children[arrayPath[2]].children[arrayPath[3]].children[arrayPath[4]].children[arrayPath[5]].children[arrayPath[6]]
} }
pathSelect.collapse = !pathSelect.collapse pathSelect.collapse = !pathSelect.collapse
// console.log(pathSelect.collapse) // console.log(pathSelect.collapse)
this.setState({listCompany}, () => console.log(pathSelect)) this.setState({ listCompany }, () => console.log(pathSelect))
} }
searchIt = (node, search, path = '', position = 0) => { searchIt = (node, search, path = '', position = 0) => {
if (node.id && node.id === search) {return path !== '' ? `${path}-${position}` : position;} if (node.id && node.id === search) { return path !== '' ? `${path}-${position}` : position; }
if (!node.children) {return false} if (!node.children) { return false }
const index = node.children.findIndex((x) => x.id && x.id === search); const index = node.children.findIndex((x) => x.id && x.id === search);
if (index >= 0) { if (index >= 0) {
return path !== '' ? `${path}-${index}` : index; return path !== '' ? `${path}-${index}` : index;
} }
for (let i = 0; i < node.children.length; i++) { for (let i = 0; i < node.children.length; i++) {
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i , i); const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i, i);
if (result){ if (result) {
return result; return result;
} }
} }
return false; return false;
}; };
async onDrop(pictureFiles) {
let formData = new FormData()
formData.append('file', pictureFiles[0])
let response = await api.create().uploadFoto(formData)
if (response.data) {
if (response.data.status === "success") {
this.setState({ uploadVisible: false }, () => {
alert(response.data.message)
this.getUser()
window.location.reload()
})
}
}
// console.log(response);
// console.log(pictureFiles);
// console.log(pictureDataURLs);
// this.setState({
// pictures: this.state.pictures.concat(pictureFiles),
// });
}
render() { render() {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8', marginBottom: 100, minHeight: 1000 }}>
<div className={"main-color"} style={{ height: 203, flex: 1, display: 'flex', alignItems: 'flex-end', padding: 20 }}> <div className={"main-color"} style={{ height: 203, flex: 1, display: 'flex', alignItems: 'flex-end', padding: 20 }}>
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
<div style={{ height: 72, width: 72, backgroundColor: 'white', borderRadius: 40, marginRight: 20 }} /> <div style={{ display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '24px', color: 'white', fontWeight: 'bold' }}>John Doe</Typography> <div style={{ height: 72, width: 72, backgroundColor: 'white', borderRadius: 40, marginRight: 20 }}>
<img src={this.state.photo} style={{ width: 72, height: 72, borderRadius: 40 }} />
</div>
<Typography style={{ fontSize: '24px', color: 'white', fontWeight: 'bold' }}>{this.state.name}</Typography>
</div>
<div>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.setState({ uploadVisible: true })}
>
<img src={Images.photo} />
</button>
</div>
</div> </div>
</div> </div>
<div> <div>
<AppBar position="static"> <AppBar position="static">
<Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#f8f8f8', borderColor: 'transparent' }}> <Tabs indicatorColor="primary" value={this.state.tab} onChange={this.selectTab} aria-label="simple tabs example" style={{ backgroundColor: '#f8f8f8', borderColor: 'transparent' }}>
...@@ -254,68 +308,114 @@ export default class Profile extends Component { ...@@ -254,68 +308,114 @@ export default class Profile extends Component {
</Tabs> </Tabs>
</AppBar> </AppBar>
{this.state.tab == 0 ? {this.state.tab == 0 ?
<div style={{ padding: 20, marginTop: 10, marginBottom: 100 }}> <form onSubmit={(e) => {
<div style={{ width: 432, borderRadius: 6, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }}> e.preventDefault()
<div style={{ width: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}> this.validasi()
<Typography style={{ fontSize: '13px', color: 'white', fontWeight: 'bold' }}>Kata Sandi</Typography> }}>
</div> <div style={{ padding: 20, marginTop: 10, marginBottom: 100 }}>
<div style={{ padding: 20, justifyContent: 'space-between' }}> <div style={{ width: 432, borderRadius: 6, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }}>
<TextField <div style={{ width: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}>
style={{ width: '100%' }} <Typography style={{ fontSize: '13px', color: 'white', fontWeight: 'bold' }}>Kata Sandi</Typography>
inputProps={{ style: { fontSize: 11 } }} </div>
id="filled-required" <div style={{ padding: 20, justifyContent: 'space-between' }}>
name={"oldPassword"} <TextField
label="Kata Sandi Saat Ini" style={{ width: '100%' }}
value={this.state.oldPassword} inputProps={{ style: { fontSize: 11 } }}
variant="outlined" id="filled-required"
onChange={(password) => { name={"oldPassword"}
this.handleChange(password) type={this.state.showPass ? 'text' : 'password'}
}} label="Kata Sandi Saat Ini"
error={this.state.errorOldPassword} value={this.state.oldPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgOldPassword}</Typography>} variant="outlined"
/> onChange={(password) => {
<TextField this.handleChange(password)
style={{ width: '100%', marginTop: 20 }} }}
inputProps={{ style: { fontSize: 11 } }} error={this.state.errorOldPassword}
id="filled-required" helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgOldPassword}</Typography>}
label="Kata Sandi Baru" InputProps={{
name={"password"} endAdornment: <InputAdornment position="end">
value={this.state.password} <IconButton
onChange={(password) => { aria-label="toggle password visibility"
this.handleChange(password) style={{ color: '#4b4b4b', opacity: 0.5 }}
}} onClick={() => this.setState({ showPass: !this.state.showPass })}
error={this.state.errorPassword} edge="end"
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgPassword}</Typography>} >
variant="outlined" {this.state.showPass ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
/> </IconButton>
<TextField </InputAdornment>,
style={{ width: '100%', marginTop: 20 }} }}
inputProps={{ style: { fontSize: 11 } }} />
id="filled-required" <TextField
label="Konfirmasi Kata Sandi Baru" style={{ width: '100%', marginTop: 20 }}
name={"confirmPassword"} inputProps={{ style: { fontSize: 11 } }}
value={this.state.confirmPassword} id="filled-required"
onChange={(confirmPassword) => { label="Kata Sandi Baru"
this.handleChange(confirmPassword) name={"password"}
}} type={this.state.showPass2 ? 'text' : 'password'}
variant="outlined" value={this.state.password}
error={this.state.errorConfirmPassword} onChange={(password) => {
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgConfirmPassword}</Typography>} this.handleChange(password)
/> }}
</div> error={this.state.errorPassword}
<div style={{ width: '100%', backgroundColor: '#f5f5f5', height: 43, display: 'flex', justifyContent: 'flex-end', padding: 10, borderColor: 'rgba(0, 0, 0, 0.25)', borderWidth: .2, borderStyle: 'dotted' }}> helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgPassword}</Typography>}
<button variant="outlined"
type="button" InputProps={{
onClick={() => this.validasi()} endAdornment: <InputAdornment position="end">
style={{}} <IconButton
> aria-label="toggle password visibility"
<div style={{ backgroundColor: '#354960', textAlign: 'center', height: 25, width: 64, borderRadius: 3 }}> style={{ color: '#4b4b4b', opacity: 0.5 }}
<span style={{ color: 'white', fontSize: 11 }}>Simpan</span> onClick={() => this.setState({ showPass2: !this.state.showPass2 })}
</div> edge="end"
</button> >
{this.state.showPass2 ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
</IconButton>
</InputAdornment>,
}}
/>
<TextField
style={{ width: '100%', marginTop: 20 }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
label="Konfirmasi Kata Sandi Baru"
name={"confirmPassword"}
type={this.state.showPass3 ? 'text' : 'password'}
value={this.state.confirmPassword}
onChange={(confirmPassword) => {
this.handleChange(confirmPassword)
}}
variant="outlined"
error={this.state.errorConfirmPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgConfirmPassword}</Typography>}
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
style={{ color: '#4b4b4b', opacity: 0.5 }}
onClick={() => this.setState({ showPass3: !this.state.showPass3 })}
edge="end"
>
{this.state.showPass3 ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
</IconButton>
</InputAdornment>,
}}
/>
</div>
<div style={{ width: '100%', backgroundColor: '#f5f5f5', height: 43, display: 'flex', justifyContent: 'flex-end', padding: 10, borderColor: 'rgba(0, 0, 0, 0.25)', borderWidth: .2, borderStyle: 'dotted' }}>
<button
type="submit"
// onClick={() => this.validasi()}
style={{}}
>
<div style={{ backgroundColor: '#354960', textAlign: 'center', height: 25, width: 64, borderRadius: 3 }}>
<span style={{ color: 'white', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div>
</div> </div>
</div> </div>
</div> : </form>
:
<div style={{ padding: 20, marginTop: 10, marginBottom: 100 }}> <div style={{ padding: 20, marginTop: 10, marginBottom: 100 }}>
<div style={{ width: 432, borderRadius: 6, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }}> <div style={{ width: 432, borderRadius: 6, boxShadow: '0 1px 4px 0 rgba(0, 0, 0, 0.25)' }}>
<div style={{ width: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}> <div style={{ width: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}>
...@@ -343,20 +443,20 @@ export default class Profile extends Component { ...@@ -343,20 +443,20 @@ export default class Profile extends Component {
<div> <div>
{/* <ul> {/* <ul>
<li> */} <li> */}
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start' }}>
{item.children.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}> {item.children.length > 0 && <span onClick={() => this.handleCollapse(item)} style={{ marginLeft: 7, marginRight: 2 }}>
{item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />} {item.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>} </span>}
<span> <span>
<CustomCheckbox <CustomCheckbox
checked={this.handleItemChecked(item)} checked={this.handleItemChecked(item)}
onChange={() => null} onChange={() => null}
/> />
</span> </span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography> <Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div> </div>
{!R.isNil(item.children) && this.renderChildren(item)} {!R.isNil(item.children) && this.renderChildren(item)}
{/* </li> {/* </li>
</ul> */} </ul> */}
</div> </div>
) )
...@@ -366,7 +466,37 @@ export default class Profile extends Component { ...@@ -366,7 +466,37 @@ export default class Profile extends Component {
</div> </div>
} }
</div> </div>
{this.state.uploadVisible && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ 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({ uploadVisible: false })}
>
<img src={Images.close} />
</button>
</div>
</div>
<ImageUploader
withIcon={true}
buttonText='Choose images'
onChange={this.onDrop}
imgExtension={['.jpg', '.gif', '.png', '.gif', '.jpeg']}
maxFileSize={5242880}
/>
</div>
</div>
)}
</div> </div>
); );
} }
} }
...@@ -28,12 +28,12 @@ class Upload extends Component { ...@@ -28,12 +28,12 @@ class Upload extends Component {
console.log('old percentage', prevs.percentage) console.log('old percentage', prevs.percentage)
console.log('new percentage', this.state.percentage) console.log('new percentage', this.state.percentage)
if (this.state.percentage !== prevs.percentage) { if (this.state.percentage !== prevs.percentage) {
this.setState({percentage: prevs.percentage}) this.setState({ percentage: prevs.percentage })
} }
} }
if (prevs.result === 'success' || prevs.result === 'error') { if (prevs.result === 'success' || prevs.result === 'error') {
if (this.state.uploadProgress === true) { if (this.state.uploadProgress === true) {
this.setState({uploadProgress: false, percentage: '100', iconButtonUpload: 'fa fa-1x fa-check'}) this.setState({ uploadProgress: false, percentage: '100', iconButtonUpload: 'fa fa-1x fa-check' })
} }
} }
} }
...@@ -43,22 +43,21 @@ class Upload extends Component { ...@@ -43,22 +43,21 @@ class Upload extends Component {
let length = acceptedFiles[0].name.split(".").length let length = acceptedFiles[0].name.split(".").length
let fileType = acceptedFiles[0].name.split(".")[length - 1] let fileType = acceptedFiles[0].name.split(".")[length - 1]
formData.append('file', acceptedFiles[0]) formData.append('file', acceptedFiles[0])
if (acceptedFiles) console.log(acceptedFiles);
{ if (acceptedFiles) {
this.setState({ this.setState({
file: acceptedFiles[0], file: acceptedFiles[0],
typeFile: fileType, typeFile: fileType,
nameFile: acceptedFiles[0].name, nameFile: acceptedFiles[0].name,
sizeFile: (acceptedFiles[0].size/1000).toFixed(0), sizeFile: (acceptedFiles[0].size / 1000).toFixed(0),
previewVisible: true, previewVisible: true,
inputVisible: false, inputVisible: false,
uploadProgress: false, uploadProgress: false,
percentage: '0' percentage: '0'
}) })
this.props.onHandle(acceptedFiles[0]) this.props.onHandle(acceptedFiles[0])
} }
else else {
{
this.setState({ this.setState({
previewVisible: false, previewVisible: false,
inputVisible: true, inputVisible: true,
...@@ -79,93 +78,100 @@ class Upload extends Component { ...@@ -79,93 +78,100 @@ class Upload extends Component {
} }
onUpload = () => { onUpload = () => {
this.props.onUpload() // this.props.onUpload()
// var strProps = this.props.acceptedFiles var strProps = this.props.acceptedFiles
// var strState = this.state.typeFile var strState = this.state.typeFile
// if (strProps.includes(strState)) { // console.log(strProps);
// this.setState({uploadProgress: true, percentage: '0'}) // console.log(strState);
// this.props.onUpload()
// } else { if (strProps.includes(strState)) {
// alert('Unsupported File Type') if (this.state.sizeFile < 1000000) {
// } this.props.onUpload()
} else {
alert('File Tidak Boleh Lebih Dari 1MB')
}
} else {
alert('File Tidak Mendukung')
}
} }
render() { render() {
return( return (
<div> <div>
<Dropzone ref={dropzoneRef} onDrop={this.onDrop}> <Dropzone ref={dropzoneRef} onDrop={this.onDrop}>
{({getRootProps, getInputProps}) => ( {({ getRootProps, getInputProps }) => (
<div> <div>
<div className="upload-file"> <div className="upload-file">
{/* label */} {/* label */}
{ this.state.inputVisible {this.state.inputVisible
? <div {...getRootProps()} className="padding-10px" style={{cursor: 'pointer'}}> ? <div {...getRootProps()} className="padding-10px" style={{ cursor: 'pointer' }}>
<input {...getInputProps()} /> <input {...getInputProps()} />
<div className="u-p-title"> <div className="u-p-title">
Drag 'n' drop some files here, or click to select files Drag 'n' drop some files here, or click to select files
</div>
</div> </div>
</div> : null}
: null }
{/* file */} {/* file */}
{ this.state.previewVisible {this.state.previewVisible
? ?
<div className="u-p-file u-p-preview"> <div className="u-p-file u-p-preview">
<div className="display-flex-normal"> <div className="display-flex-normal">
<div className="width width-35px"> <div className="width width-35px">
<button <button
onClick={this.state.uploadProgress === true ? null : this.onRemove} onClick={this.state.uploadProgress === true ? null : this.onRemove}
className="btn btn-small-circle btn-black" className="btn btn-small-circle btn-black"
type="button"> type="button">
<i className="fa fa-1x fa-times" /> <i className="fa fa-1x fa-times" />
</button> </button>
</div>
<div className="width width-full margin-left-10px">
<div className="txt-site txt-12 txt-white txt-bold">
{ this.state.nameFile }
</div> </div>
<div className="txt-site txt-11 txt-white txt-thin"> <div className="width width-full margin-left-10px">
{ this.state.sizeFile } KB <div className="txt-site txt-12 txt-white txt-bold">
{this.state.nameFile}
</div>
<div className="txt-site txt-11 txt-white txt-thin">
{this.state.sizeFile} KB
</div> </div>
</div> </div>
{/* this.state.uploadProgress === true {/* this.state.uploadProgress === true
? ( ? (
<div className="width width-100px padding-10px txt-site txt-12 txt-white txt-thin"> <div className="width width-100px padding-10px txt-site txt-12 txt-white txt-thin">
({this.state.percentage})% ({this.state.percentage})%
</div> </div>
) : null */} ) : null */}
{this.props.type === 'upload' ? {this.props.type === 'upload' ?
<div className="width width-155px padding-10px txt-site txt-11 txt-white txt-thin"> <div className="width width-155px padding-10px txt-site txt-11 txt-white txt-thin">
Uploading {this.state.percentage}% Uploading {this.state.percentage}%
</div> : null } </div> : null}
{this.props.disableButtonUpload !== true ? ( {this.props.disableButtonUpload !== true ? (
<div className="width width-35px"> <div className="width width-35px">
<button <button
className="btn btn-small-circle" className="btn btn-small-circle"
type="button" type="button"
onClick={this.state.uploadProgress === true ? null : this.onUpload}> onClick={this.state.uploadProgress === true ? null : this.onUpload}>
{/*<i className={this.state.iconButtonUpload} />*/} {/*<i className={this.state.iconButtonUpload} />*/}
{this.state.uploadProgress === true {this.state.uploadProgress === true
? <i className={ 'fa fa-1x fa-spinner fa-spin'} /> : ? <i className={'fa fa-1x fa-spinner fa-spin'} /> :
<img src={Images.upload} />} <img src={Images.upload} />}
</button> </button>
</div> </div>
) : null} ) : null}
</div> </div>
{this.props.type === 'upload' ? {this.props.type === 'upload' ?
<div className="margin-top-15px"> <div className="margin-top-15px">
<LinearProgress variant="determinate" value={this.state.percentage} /> <LinearProgress variant="determinate" value={this.state.percentage} />
</div> : null } </div> : null}
{/* this.state.uploadProgress === true {/* this.state.uploadProgress === true
? ( ? (
<div className="margin-15px"> <div className="margin-15px">
<LinearProgress variant="determinate" value={this.state.percentage} /> <LinearProgress variant="determinate" value={this.state.percentage} />
</div> </div>
) : null */} ) : null */}
</div> </div>
: null } : null}
{/* image */} {/* image */}
{/* <div className="u-p-image u-p-preview"> {/* <div className="u-p-image u-p-preview">
......
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