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

uplad foto, hover button ++

parent 554bbb2d
......@@ -15360,6 +15360,20 @@
"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": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
......
......@@ -32,6 +32,7 @@
"react-draggable-list": "^4.0.3",
"react-dropzone": "^11.0.2",
"react-excel-renderer": "^1.1.0",
"react-images-upload": "^1.2.8",
"react-linechart": "^1.1.12",
"react-nestable": "^1.3.0",
"react-number-format": "^4.4.1",
......
......@@ -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 uploadUnitBisnis = (body) => api.post('/business_unit/import_business_unit', body)
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
const getPerusahaan = () => api.get('company/get_all_company')
......@@ -152,6 +154,10 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
//Template
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
// ------
......@@ -238,7 +244,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
uploadPerusahaan,
searchPerusahaan,
getUnitBisnisActive,
getMenuByUser
getMenuByUser,
getDetailUnitBisnis,
uploadFoto
}
}
......
......@@ -44,7 +44,8 @@ const Images = {
logout: require('./setting.png'),
setting: require('./logout.png'),
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() {
const [selectedSubIndex, setSelectSub] = React.useState([]);
const [userFullname, setUserFullname] = React.useState("")
const [userEmail, setUserEmail] = React.useState("")
const [userPhoto, setUserPhoto] = React.useState("")
const [application, setApplication] = React.useState([])
const [setting, setSetting] = React.useState([])
const [data, setData] = React.useState({
......@@ -316,7 +317,7 @@ export default function MiniDrawer() {
const parseChildren = (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 {
img: i.icon === '#' ? "" : i.icon,
label: i.menu_name,
......@@ -331,21 +332,26 @@ export default function MiniDrawer() {
const getMenuHierarki = () => {
api.create().getMenuByRole().then((response) => {
console.log(response)
if (response.data.status === "success") {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = parseChildren(item.sub_menu)
return app
} else {
set = parseChildren(item.sub_menu)
return set
}
})
setApplication(app)
setSetting(set)
console.log(app);
if (response.data) {
if (response.data.status === "success") {
let app = null
let set = null
response.data.data.map((item) => {
if (item.menu_name === "Application") {
app = parseChildren(item.sub_menu)
return app
} else {
set = parseChildren(item.sub_menu)
return set
}
})
setApplication(app)
setSetting(set)
console.log(app);
} else {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
} else {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
......@@ -356,9 +362,12 @@ export default function MiniDrawer() {
const getUserData = () => {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data.status == 'success') {
setUserFullname(response.data.data.fullname == null ? 'Anonym' : response.data.data.fullname)
setUserEmail(response.data.data.email == null ? 'Anonym@123.xyz' : response.data.data.email)
if (response.data) {
if (response.data.status == 'success') {
setUserFullname(response.data.data.fullname === null ? 'Anonym' : response.data.data.fullname)
setUserEmail(response.data.data.email === null ? 'Anonym@123.xyz' : response.data.data.email)
setUserPhoto(response.data.data.photo === null ? "" : response.data.data.photo)
}
}
})
}
......@@ -474,6 +483,7 @@ export default function MiniDrawer() {
<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 style={{ width: 72, height: 72, backgroundColor: '#838383', borderRadius: 50, alignSelf: 'center' }}>
<img src={userPhoto} style={{ width: 72, height: 72, borderRadius: 50 }} />
</div>
</div>
......@@ -488,7 +498,7 @@ export default function MiniDrawer() {
{application.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 5 }} >
{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}>
<ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
......@@ -536,7 +546,7 @@ export default function MiniDrawer() {
{setting.map((item, index) => (
<div style={{ marginTop: index === 0 ? null : 5 }} >
{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}>
<ListItemIcon style={{ minWidth: open ? 40 : 56 }}><img src={item.img} /></ListItemIcon>
<Typography style={{ fontFamily: 'nunito', color: '#525355', fontSize: 14 }}>{item.label}</Typography>
......
......@@ -42,11 +42,11 @@ class Login extends Component {
handleChange(e) {
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") {
this.setState({ errorEmail: false, msgEmail: '' })
this.setState({ errorEmail: false, msgEmail: '' })
} else if (e.target.name) {
this.setState({ errorPassword: false, msgPassword: '' })
this.setState({ errorPassword: false, msgPassword: '' })
}
}
......@@ -56,23 +56,24 @@ class Login extends Component {
}
validateLogin() {
var isEmail = this.isEmail(this.state.email)
if (this.state.email.trim() == "") {
this.setState({ errorEmail: true, msgEmail: 'Email harus diisi!' })
} else if (!isEmail) {
this.setState({ errorEmail: true, msgEmail: 'Format email tidak sesuai!' })
} else if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
} else {
this.login()
}
var isEmail = this.isEmail(this.state.email)
if (this.state.email.trim() == "") {
this.setState({ errorEmail: true, msgEmail: 'Email harus diisi!' })
} else if (!isEmail) {
this.setState({ errorEmail: true, msgEmail: 'Format email tidak sesuai!' })
} else if (this.state.password.trim() == "") {
this.setState({ errorPassword: true, msgPassword: 'Password harus diisi!' })
} else {
this.login()
}
}
login() {
console.log('login');
let payload = {
"email": this.state.email,
"password": this.state.password
}
}
api.create().login(payload).then((response) => {
if (response.data.status === 'success') {
console.log(response.data.data)
......@@ -89,9 +90,9 @@ class Login extends Component {
this.props.history.push('/home/beranda')
} else {
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 {
this.setState({ errorEmail: true, msgEmail: response.data.message })
this.setState({ errorEmail: true, msgEmail: response.data.message })
}
}
})
......@@ -101,9 +102,9 @@ class Login extends Component {
var email = localStorage.getItem(Constant.EMAIL)
var password = localStorage.getItem(Constant.PASSWORD)
if (email == null || password == null) {
this.setState({email: '', password: ''})
} else if(email != '' && password != ''){
this.setState({email, password})
this.setState({ email: '', password: '' })
} else if (email != '' && password != '') {
this.setState({ email, password })
}
}
......@@ -116,63 +117,82 @@ class Login extends Component {
<img src={Images.imageLogin} style={{ marginTop: 30 }} />
</div>
<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
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Email *</Typography>}
id="email"
type={"text"}
name={"email"}
value={this.state.email}
onChange={(email) => {
<form onSubmit={(e) => {
e.preventDefault()
this.validateLogin()
}}
>
<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
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)
}}
variant="outlined"
error={this.state.errorEmail}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }}
helperText={this.state.msgEmail}
InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}}
/>
variant="outlined"
error={this.state.errorEmail}
style={{ width: '100%', height: 51, marginTop: 32, fontSize: 14 }}
helperText={this.state.msgEmail}
InputProps={{
endAdornment: <InputAdornment position="end"><img src={Images.email} /></InputAdornment>,
}}
/>
<TextField
label={<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Kata Sandi *</Typography>}
id="password"
type={this.state.showPass ? 'text' : 'password'}
name={"password"}
value={this.state.password}
onChange={(password) => {
<TextField
label={<Typography style={{ fontSize: 12, fontFamily: 'Nunito Sans, sans-serif' }}>Kata Sandi *</Typography>}
id="password"
type={this.state.showPass ? 'text' : 'password'}
name={"password"}
value={this.state.password}
onChange={(password) => {
this.handleChange(password)
}}
variant="outlined"
error={this.state.errorPassword}
style={{ width: '100%', height: 51, marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 20 }}
helperText={this.state.msgPassword}
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
style={{color: '#4b4b4b', opacity: 0.5}}
onClick={() => this.setState({showPass: !this.state.showPass})}
edge="end"
>
{this.state.showPass ? <Visibility style={{fontSize: 18}} /> : <VisibilityOff style={{fontSize: 18}} />}
</IconButton>
</InputAdornment>,
}}
/>
variant="outlined"
error={this.state.errorPassword}
style={{ width: '100%', height: 51, marginTop: this.state.errorEmail ? (this.state.msgEmail.length > 45 ? 60 : 35) : 20 }}
helperText={this.state.msgPassword}
onSubmit={() => this.validateLogin()}
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
style={{ color: '#4b4b4b', opacity: 0.5 }}
onClick={() => this.setState({ showPass: !this.state.showPass })}
edge="end"
>
{this.state.showPass ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
</IconButton>
</InputAdornment>,
}}
/>
<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})} />
<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>
<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 })} />
<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>
</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>
<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' }}>
<Typography style={{fontSize: 12, fontFamily: 'Nunito Sans, sans-serif'}}>Login</Typography>
</Button>
</div>
</form>
</div>
</div >
);
......
......@@ -495,9 +495,14 @@ export default class Parameter extends Component {
uploadParameter() {
api.create().uploadParameter(this.state.payload).then(response => {
console.log(response)
this.getAllParameter()
this.setState({ visibleParameter: true })
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getAllParameter()
this.setState({ visibleParameter: true })
}
}
})
}
......@@ -648,49 +653,62 @@ export default class Parameter extends Component {
/>
</div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<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 style={{ padding: 25 }}>
......@@ -777,7 +795,7 @@ export default class Parameter extends Component {
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -785,7 +803,7 @@ export default class Parameter extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
......
......@@ -49,7 +49,7 @@ export default class ReportItems extends Component {
let isi = resp.rows.slice(3)
let payload = []
isi.map((item, index) => {
if(item.length > 0) {
if (item.length > 0) {
payload.push({
id: index + 1,
report: item[0],
......@@ -452,8 +452,8 @@ export default class ReportItems extends Component {
console.log(response)
if (response.data.status == 'success') {
let data = response.data.data
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 ]
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]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
......@@ -486,7 +486,7 @@ export default class ReportItems extends Component {
if (response.data.status == 'success') {
let data = response.data.data
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 })
} else {
......@@ -549,12 +549,17 @@ export default class ReportItems extends Component {
uploadReportItems() {
api.create().uploadReportItems(this.state.payload).then(response => {
console.log(response)
this.getData()
this.setState({ itemReport: true })
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getData()
this.setState({ itemReport: true })
}
}
})
}
render() {
const columns = [{
name: "Action",
......@@ -569,7 +574,7 @@ export default class ReportItems extends Component {
borderColor: 'transparent'
}}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
>
<img src={Images.editCopy} />
</button>
......@@ -698,15 +703,15 @@ export default class ReportItems extends Component {
}
}
}
]
const data = [
["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "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"],
["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
]
]
const data = [
["", "1", "KPI", "TIA", "1", "Financial Perspective", "0", "-", "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"],
["", "4", "KPI", "TIA", "4", "EBITDA", "1", "Rp Bio", "0%", "Formula", "Non Aktif"],
["", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"],
]
return (
<div style={{ height: this.props.height }}>
{/* <Row> */}
......@@ -726,60 +731,76 @@ export default class ReportItems extends Component {
/>
</div>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.visualisasi} onClick={() => this.setState({ visualisasi: true, itemReport: false })} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
>
<img src={Images.add} onClick={() => this.setState({ add: true })} />
</button>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
<img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualisasi'} data-for="visualisasi">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visualisasi: true, itemReport: false })}
>
<img src={Images.visualisasi} />
</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 style={{ padding: 25 }}>
......@@ -793,75 +814,75 @@ export default class ReportItems extends Component {
</MuiThemeProvider>
</div>
</div>
:
this.state.visualisasi == true ?
<VisualReportItems
onClickClose={() => this.setState({ visualisasi: false, itemReport: true })}
height= {this.props.height}
/>
:
<div style={{ height: this.props.height }}>
<div style={{ height: 199, width: '100%' }} className={"main-color"}/>
<div>
:
this.state.visualisasi == true ?
<VisualReportItems
onClickClose={() => this.setState({ visualisasi: false, itemReport: true })}
height={this.props.height}
/>
:
<div style={{ height: this.props.height }}>
<div style={{ height: 199, width: '100%' }} className={"main-color"} />
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
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>
</button>
<button
type="button"
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>
</button>
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center' }}>Preview Data</label>
</div>
<div style={{ padding: 25 }}>
{this.state.dataLoaded && (
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.rows}
columns={this.state.cols}
options={options}
/>
</MuiThemeProvider>
)}
</div>
<div style={{ display: 'flex', width: '100%', placeContent: 'flex-end', padding: 20 }}>
<button
type="button"
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>
</button>
<button
type="button"
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>
</button>
</div>
</div>
</div>
</div>
</div>
}
{this.state.add && (
<CreateReportItems
<CreateReportItems
onClickClose={() => this.setState({ add: false })}
data={this.state.listData}
refresh={this.getData.bind(this)}
createReportItems={this.createReportItems.bind(this)}
/>
)}
)}
{this.state.edit && (
<EditReportItems
<EditReportItems
onClickClose={() => this.setState({ edit: false })}
data={this.state.listData[this.state.selectIndex]}
refresh={this.getData.bind(this)}
updateReportItems={this.updateReportItems.bind(this)}
/>
)}
)}
{this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} />
)}
<PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)}
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
......@@ -877,7 +898,7 @@ export default class ReportItems extends Component {
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -885,7 +906,7 @@ export default class ReportItems extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
......@@ -895,7 +916,7 @@ export default class ReportItems extends Component {
</div>
</div>
)}
</div>
</div>
);
}
}
......@@ -183,27 +183,31 @@ export default class UnitBisnis extends Component {
getData() {
api.create().getUnitBisnis().then((response) => {
console.log(response)
if (response.data.status == 'success') {
let data = response.data.data
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 })
if (response.data) {
if (response.data.status == 'success') {
let data = response.data.data
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 })
} else {
alert(response.data.message)
}
} else {
alert(response.data.message)
this.setState({ dataTable: [] })
}
})
}
openPopUp(index, type) {
openPopUp(rowData, type) {
if (type === 'edit') {
this.setState({
selectIndex: index,
rowData: rowData,
visibleEdit: true
})
} else {
this.setState({
data: this.state.listData[index],
rowData: rowData,
visibleCreate: true
})
}
......@@ -232,6 +236,7 @@ export default class UnitBisnis extends Component {
this.setState({ visibleEdit: false })
api.create().updateUnitBisnis(payload).then(response => {
if (response.data.status == 'success') {
alert(response.data.message)
this.getData()
} else {
alert(response.data.message)
......@@ -283,8 +288,11 @@ export default class UnitBisnis extends Component {
uploadUnitBisnis() {
api.create().uploadUnitBisnis(this.state.payload).then(response => {
console.log(response)
this.getData()
this.setState({ visibleUnitBisnis: true })
if (response.data.status === "success") {
alert(response.data.message)
this.getData()
this.setState({ visibleUnitBisnis: true })
}
})
}
......@@ -301,8 +309,8 @@ export default class UnitBisnis extends Component {
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => this.openPopUp(tableMeta.rowIndex, 'edit')}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
>
<img src={Images.editCopy} />
</button>
......@@ -368,53 +376,64 @@ export default class UnitBisnis extends Component {
onChange={(e) => this.handleInputChange(e.target.value)}
inputProps={{ 'aria-label': 'naked' }}
/>
{/* <input type="text" value={this.state.search} onChange={(e)=> this.setState({ search: e.target.value})} style={{ width: '100%'}} /> */}
</div>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
<img src={Images.add} />
</button>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<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 style={{ padding: 25 }}>
......@@ -481,12 +500,12 @@ export default class UnitBisnis extends Component {
<CreateUnitBisnis
type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]}
data={this.state.rowData}
updateUnitBisnis={this.updateUnitBisnis.bind(this)}
/>
)}
{this.state.popupError && (
<PopUpFailedSave onClickClose={()=> this.setState({ popupError: false })} />
<PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)}
{this.state.visibleUpload && (
......@@ -504,7 +523,7 @@ export default class UnitBisnis extends Component {
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -512,7 +531,7 @@ export default class UnitBisnis extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
......
......@@ -4,12 +4,14 @@ import * as R from 'ramda'
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
import Images from '../../../assets/Images';
import api from '../../../api';
export default class CreateUnitBisnis extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
status:"",
name: '',
startDate: '',
endDate: '',
......@@ -28,16 +30,44 @@ export default class CreateUnitBisnis extends Component {
componentDidMount() {
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({
id: data.business_unit_id,
name: data.business_unit_name,
startDate: data.start_date,
endDate: data.end_date
startDate: date,
endDate: 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) {
let data = this.state
let isDate = type !== '' ? true : false
......@@ -90,9 +120,9 @@ export default class CreateUnitBisnis extends Component {
if (R.isEmpty(this.state.name)) {
this.setState({ errorName: true, msgErrorName: 'Unit Bisnis tidak boleh kosong' })
} 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)) {
this.setState({ errorEndDate: true, msgErrorEndDate: 'Tanggal Berakhir tidak boleh kosong' })
this.setState({ errorEndDate: true, msgErrorEndDate: 'Berkahir Hingga tidak boleh kosong' })
} else {
let payload = {
"business_unit_name": this.state.name,
......@@ -119,7 +149,7 @@ export default class CreateUnitBisnis extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -130,8 +160,8 @@ export default class CreateUnitBisnis extends Component {
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.props.data.business_unit_id}
id="status"
value={this.state.id}
id="id"
label="ID"
disabled
inputProps={{
......@@ -178,7 +208,7 @@ export default class CreateUnitBisnis extends Component {
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.props.data.status}
value={this.state.status}
id="status"
label="Status"
disabled
......@@ -199,11 +229,11 @@ export default class CreateUnitBisnis extends Component {
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}>
<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 style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.props.data.updated == - null ? "" : this.props.data.updated}</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.updated}</Typography>
</div>
</div>
</div>
......@@ -307,7 +337,7 @@ export default class CreateUnitBisnis extends Component {
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -385,8 +415,8 @@ export default class CreateUnitBisnis extends Component {
</div>
<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 }}>Diubah : Admin - 21 Jul 2020, 18:45</Typography>
<Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div>
</div>
......
......@@ -7,7 +7,7 @@ import AddUser from './User/AddUser';
import EditUser from './User/EditUser'
import api from "../../api";
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 { ExcelRenderer } from 'react-excel-renderer';
import ReactTooltip from "react-tooltip";
......@@ -46,8 +46,8 @@ export default class UserRole extends Component {
api.create().getUser().then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
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]
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]
})
this.setState({ listUser: listData })
} else {
......@@ -63,8 +63,8 @@ export default class UserRole extends Component {
api.create().searchUser(payload).then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
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]
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]
})
this.setState({ listUser: listData })
} else {
......@@ -278,9 +278,14 @@ export default class UserRole extends Component {
uploadUser() {
api.create().uploadUser(this.state.payload).then(response => {
console.log(response)
this.getUser()
this.setState({ visibleUser: true })
if (response.data) {
if (response.data.status === "success") {
console.log(response)
alert(response.data.message)
this.getUser()
this.setState({ visibleUser: true })
}
}
})
}
......@@ -291,19 +296,19 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{tableMeta.rowData[6] === "Aktif" ?
{tableMeta.rowData[6] === "Aktif" ?
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
>
<img src={Images.editCopy} />
</button>
:
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta.rowData[1])}
onClick={() => this.setState({ edit: true, indexData: tableMeta.rowData[1] })}
>
<img src={Images.editCopy} />
</button>
:
null
}
</div >
......@@ -315,7 +320,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
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>
</div >
);
......@@ -326,7 +331,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
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>
</div >
);
......@@ -337,7 +342,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
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>
</div >
);
......@@ -348,7 +353,7 @@ export default class UserRole extends Component {
options: {
customBodyRender: (val, tableMeta) => {
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>
</div >
);
......@@ -383,8 +388,8 @@ export default class UserRole extends Component {
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
{this.state.visibleUser ? <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18 }}>Master Data - User</label>
<div style={{ width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<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: '50%', backgroundColor: 'white', padding: 10, borderRadius: 7.5 }}>
<TextField
id="input-with-icon-textfield"
......@@ -412,62 +417,83 @@ export default class UserRole extends Component {
}}
/>
</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>
{/* <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' }}>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginTop: 5,
marginBottom: 5,
marginRight: 5,
marginLeft: 20
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginTop: 5,
marginBottom: 5,
marginRight: 5,
marginLeft: 20
}}
onClick={() => this.downloadDataTables()}
>
<img src={Images.download} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginTop: 5,
marginBottom: 5,
marginRight: 5,
marginLeft: 20
}}
onClick={() => this.setState({ add: true })}
>
<img src={Images.add} />
</button>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} />
</button>
</a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
<a data-tip={'Upload'} data-for="upload">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} />
</button>
</a>
<ReactTooltip border={true} id="upload" place="bottom" type="light" effect="solid" />
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTables()}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
<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 style={{ padding: 25 }}>
......@@ -538,7 +564,7 @@ export default class UserRole extends Component {
{this.state.visibleUpload && (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="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>
......@@ -550,7 +576,7 @@ export default class UserRole extends Component {
className="btn btn-circle btn-white"
onClick={() => this.setState({ visibleUpload: false })}
>
<img src={Images.close}/>
<img src={Images.close} />
</button>
</div>
</div>
......@@ -558,7 +584,7 @@ export default class UserRole extends Component {
type={this.state.uploadStatus}
percentage={this.state.percentage}
result={this.state.result}
acceptedFiles={["pdf"]}
acceptedFiles={["xlsx"]}
onHandle={(dt) => {
this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' })
......
......@@ -263,7 +263,7 @@ export default class AddUser extends Component {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="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' }}>Ubah Data</span>
......
......@@ -299,7 +299,7 @@ export default class EditUser extends Component {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x" style={{ backgroundColor: '#51c6ea', height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="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' }}>Ubah Data</span>
......
......@@ -9,6 +9,8 @@ import api from "../../api";
import { titleCase } from "../../library/Utils";
import InputAdornment from '@material-ui/core/InputAdornment';
import TextField from '@material-ui/core/TextField';
import { InputBase } from "@material-ui/core";
import ReactTooltip from "react-tooltip";
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
......@@ -30,11 +32,11 @@ class UserRole extends Component {
}
closeEdit() {
this.setState({edit: false})
this.setState({ edit: false })
}
closeAdd() {
this.setState({add: false})
this.setState({ add: false })
}
getRole() {
......@@ -42,15 +44,15 @@ class UserRole extends Component {
// console.log(response)
if (response.data.status === 'success') {
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]
})
// console.log(listData)
this.setState({listRole: listData})
this.setState({ listRole: listData })
// this.setState({listRole: response.data.data}, () => {
// console.log(this.state.listRole)
// })
} else {
alert(response.data.message)
}
......@@ -65,14 +67,14 @@ class UserRole extends Component {
api.create().searchRole(payload).then((response) => {
if (response.data.status === 'success') {
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]
})
this.setState({listRole: listData})
this.setState({ listRole: listData })
} else {
alert(response.data.message)
}
})
})
}
_handleKeyDown(e) {
......@@ -87,9 +89,9 @@ class UserRole extends Component {
handleChange(e) {
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')
}))
}
......@@ -107,15 +109,15 @@ class UserRole extends Component {
borderColor: 'transparent',
}}
// 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' }}>
{ tableMeta.rowData[4] === "Aktif" ?
<img src={Images.editCopy}/> :
{tableMeta.rowData[4] === "Aktif" ?
<img src={Images.editCopy} /> :
null
}
</div >
</button>
</div >
);
......@@ -172,39 +174,41 @@ class UserRole extends Component {
<div className={"main-color"} style={{ height: 199, width: '100%' }} />
<div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -150 }}>
<label style={{ fontFamily: 'nunito', color: 'white', width: '20%', alignSelf: 'center', fontSize: 18}}>Master Data - Role & Otorisasi</label>
<div style={{width: '60%', justifyContent: 'center', display: 'flex', borderWidth: 2, alignItems: 'center' }}>
<div style={{width: '50%', backgroundColor:'white', padding: 10, borderRadius: 7.5}}>
<TextField
id="input-with-icon-textfield"
name="search"
value={this.state.search}
placeholder={'Search'}
onChange={(e) => {
this.setState({ search: e.target.value }, () => {
if (this.state.search.length > 0) {
this.searchRole()
} else {
this.getRole()
}
});
}}
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>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '20%', }}>Master Data - Role & Otorisasi</label>
<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.searchRole()
} else {
this.getRole()
}
});
}}
inputProps={{ 'aria-label': 'naked' }}
/>
</div>
{/* <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' }}>
<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 style={{ padding: 25 }}>
......@@ -218,14 +222,14 @@ class UserRole extends Component {
</div>
</div>
{this.state.add && (
<AddRole
<AddRole
onClickClose={this.closeAdd.bind(this)}
refresh={this.getRole.bind(this)}
data={this.state.indexData}
/>
)}
{this.state.edit && (
<EditRole
<EditRole
onClickClose={this.closeEdit.bind(this)}
refresh={this.getRole.bind(this)}
data={this.state.indexData}
......
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 Images from '../assets/Images';
import api from '../api';
......@@ -8,6 +10,7 @@ import RemoveIcon from '@material-ui/icons/Remove';
import AddIcon from '@material-ui/icons/Add';
import { titleCase } from '../library/Utils';
import * as R from 'ramda'
import ImageUploader from 'react-images-upload';
const CustomCheckbox = withStyles({
root: {
......@@ -35,8 +38,14 @@ export default class Profile extends Component {
msgConfirmPassword: 'Terdiri 8 karakter dengan kombinasi angka.',
company: [],
listCompany: [],
selectedIndex: 0
selectedIndex: 0,
showPass: false,
showPass2: false,
showPass3: false,
pictures: [],
name: ""
}
this.onDrop = this.onDrop.bind(this);
}
componentDidMount() {
......@@ -101,10 +110,12 @@ export default class Profile extends Component {
}
api.create().changePassword(body).then(response => {
console.log(response);
if (response.data.status === "success") {
this.setState({ oldPassword: "", password: "", confirmPassword: "" })
alert(response.data.message)
} else {
if (response.data) {
if (response.data.status === "success") {
this.setState({ oldPassword: "", password: "", confirmPassword: "" })
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}
alert(response.data.message)
}
})
......@@ -124,8 +135,9 @@ export default class Profile extends Component {
getUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
console.log(response);
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)
}
......@@ -134,9 +146,12 @@ export default class Profile extends Component {
getPerusahaan() {
api.create().getPerusahaanHierarki().then((response) => {
if (response.data.status == 'success') {
this.setState({ listCompany: response.data.data })
console.log(response.data.data)
// console.log(response);
if (response.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 {
{item.children.map((data, index) => {
return (
// <li>
<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 }}>
{R.isNil(data.children)?
null
:
data.children.length < 1?
<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 }}>
{R.isNil(data.children) ?
null
:
data.children.length < 1 ?
null
:
<span onClick={() => this.handleCollapse(data)} style={{ marginLeft: 7, marginRight: 2 }}>
{data.collapse? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => null}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
{data.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>
}
<span>
<CustomCheckbox
checked={this.handleItemChecked(data)}
onChange={() => null}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(data.company_name)}</Typography>
</div>
{!R.isNil(data.children) && this.renderChildren(data, padding + 20)}
</Collapse>
// </li>
)
})}
......@@ -188,64 +203,103 @@ export default class Profile extends Component {
}
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 arrayPath = []
if (path.length > 1) {
arrayPath = path.split('-');
arrayPath = arrayPath.map((item) => {return item})
arrayPath = arrayPath.map((item) => { return item })
} else {
arrayPath.push(path)
}
let pathSelect = null
if (arrayPath.length == 1) {
pathSelect= listCompany[arrayPath[0]]
pathSelect = listCompany[arrayPath[0]]
} else if (arrayPath.length == 2) {
pathSelect= listCompany[arrayPath[0]].children[arrayPath[1]]
pathSelect = listCompany[arrayPath[0]].children[arrayPath[1]]
} 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) {
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) {
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) {
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) {
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
// console.log(pathSelect.collapse)
this.setState({listCompany}, () => console.log(pathSelect))
this.setState({ listCompany }, () => console.log(pathSelect))
}
searchIt = (node, search, path = '', position = 0) => {
if (node.id && node.id === search) {return path !== '' ? `${path}-${position}` : position;}
if (!node.children) {return false}
if (node.id && node.id === search) { return path !== '' ? `${path}-${position}` : position; }
if (!node.children) { return false }
const index = node.children.findIndex((x) => x.id && x.id === search);
if (index >= 0) {
return path !== '' ? `${path}-${index}` : index;
return path !== '' ? `${path}-${index}` : index;
}
for (let i = 0; i < node.children.length; i++) {
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i , i);
if (result){
return result;
}
const result = this.searchIt(node.children[i], search, path !== '' ? `${path}-${i}` : i, i);
if (result) {
return result;
}
}
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() {
return (
<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 style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ height: 72, width: 72, backgroundColor: 'white', borderRadius: 40, marginRight: 20 }} />
<Typography style={{ fontSize: '24px', color: 'white', fontWeight: 'bold' }}>John Doe</Typography>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<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>
<AppBar position="static">
<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 {
</Tabs>
</AppBar>
{this.state.tab == 0 ?
<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: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}>
<Typography style={{ fontSize: '13px', color: 'white', fontWeight: 'bold' }}>Kata Sandi</Typography>
</div>
<div style={{ padding: 20, justifyContent: 'space-between' }}>
<TextField
style={{ width: '100%' }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
name={"oldPassword"}
label="Kata Sandi Saat Ini"
value={this.state.oldPassword}
variant="outlined"
onChange={(password) => {
this.handleChange(password)
}}
error={this.state.errorOldPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgOldPassword}</Typography>}
/>
<TextField
style={{ width: '100%', marginTop: 20 }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
label="Kata Sandi Baru"
name={"password"}
value={this.state.password}
onChange={(password) => {
this.handleChange(password)
}}
error={this.state.errorPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgPassword}</Typography>}
variant="outlined"
/>
<TextField
style={{ width: '100%', marginTop: 20 }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
label="Konfirmasi Kata Sandi Baru"
name={"confirmPassword"}
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>}
/>
</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="button"
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>
<form onSubmit={(e) => {
e.preventDefault()
this.validasi()
}}>
<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: '100%', height: 64, backgroundColor: '#354960', display: 'flex', paddingLeft: 20, borderTopLeftRadius: 6, borderTopRightRadius: 6, alignItems: 'center' }}>
<Typography style={{ fontSize: '13px', color: 'white', fontWeight: 'bold' }}>Kata Sandi</Typography>
</div>
<div style={{ padding: 20, justifyContent: 'space-between' }}>
<TextField
style={{ width: '100%' }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
name={"oldPassword"}
type={this.state.showPass ? 'text' : 'password'}
label="Kata Sandi Saat Ini"
value={this.state.oldPassword}
variant="outlined"
onChange={(password) => {
this.handleChange(password)
}}
error={this.state.errorOldPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgOldPassword}</Typography>}
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
style={{ color: '#4b4b4b', opacity: 0.5 }}
onClick={() => this.setState({ showPass: !this.state.showPass })}
edge="end"
>
{this.state.showPass ? <Visibility style={{ fontSize: 18 }} /> : <VisibilityOff style={{ fontSize: 18 }} />}
</IconButton>
</InputAdornment>,
}}
/>
<TextField
style={{ width: '100%', marginTop: 20 }}
inputProps={{ style: { fontSize: 11 } }}
id="filled-required"
label="Kata Sandi Baru"
name={"password"}
type={this.state.showPass2 ? 'text' : 'password'}
value={this.state.password}
onChange={(password) => {
this.handleChange(password)
}}
error={this.state.errorPassword}
helperText={<Typography style={{ fontSize: 9, marginTop: 4, fontFamily: 'Nunito Sans, sans-serif' }}>{this.state.msgPassword}</Typography>}
variant="outlined"
InputProps={{
endAdornment: <InputAdornment position="end">
<IconButton
aria-label="toggle password visibility"
style={{ color: '#4b4b4b', opacity: 0.5 }}
onClick={() => this.setState({ showPass2: !this.state.showPass2 })}
edge="end"
>
{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> :
</form>
:
<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: '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 {
<div>
{/* <ul>
<li> */}
<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.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => null}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{!R.isNil(item.children) && this.renderChildren(item)}
{/* </li>
<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.collapse ? <RemoveIcon color={'action'} fontSize={'small'} /> : <AddIcon color={'action'} fontSize={'small'} />}
</span>}
<span>
<CustomCheckbox
checked={this.handleItemChecked(item)}
onChange={() => null}
/>
</span>
<Typography style={{ fontSize: 12 }}>{titleCase(item.company_name)}</Typography>
</div>
{!R.isNil(item.children) && this.renderChildren(item)}
{/* </li>
</ul> */}
</div>
)
......@@ -366,7 +466,37 @@ export default class Profile extends Component {
</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>
);
}
}
......@@ -28,12 +28,12 @@ class Upload extends Component {
console.log('old percentage', prevs.percentage)
console.log('new percentage', this.state.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 (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 {
let length = acceptedFiles[0].name.split(".").length
let fileType = acceptedFiles[0].name.split(".")[length - 1]
formData.append('file', acceptedFiles[0])
if (acceptedFiles)
{
console.log(acceptedFiles);
if (acceptedFiles) {
this.setState({
file: acceptedFiles[0],
typeFile: fileType,
nameFile: acceptedFiles[0].name,
sizeFile: (acceptedFiles[0].size/1000).toFixed(0),
sizeFile: (acceptedFiles[0].size / 1000).toFixed(0),
previewVisible: true,
inputVisible: false,
uploadProgress: false,
percentage: '0'
})
this.props.onHandle(acceptedFiles[0])
}
else
{
}
else {
this.setState({
previewVisible: false,
inputVisible: true,
......@@ -79,93 +78,100 @@ class Upload extends Component {
}
onUpload = () => {
this.props.onUpload()
// var strProps = this.props.acceptedFiles
// var strState = this.state.typeFile
// if (strProps.includes(strState)) {
// this.setState({uploadProgress: true, percentage: '0'})
// this.props.onUpload()
// } else {
// alert('Unsupported File Type')
// }
// this.props.onUpload()
var strProps = this.props.acceptedFiles
var strState = this.state.typeFile
// console.log(strProps);
// console.log(strState);
if (strProps.includes(strState)) {
if (this.state.sizeFile < 1000000) {
this.props.onUpload()
} else {
alert('File Tidak Boleh Lebih Dari 1MB')
}
} else {
alert('File Tidak Mendukung')
}
}
render() {
return(
return (
<div>
<Dropzone ref={dropzoneRef} onDrop={this.onDrop}>
{({getRootProps, getInputProps}) => (
{({ getRootProps, getInputProps }) => (
<div>
<div className="upload-file">
{/* label */}
{ this.state.inputVisible
? <div {...getRootProps()} className="padding-10px" style={{cursor: 'pointer'}}>
<input {...getInputProps()} />
<div className="u-p-title">
Drag 'n' drop some files here, or click to select files
{this.state.inputVisible
? <div {...getRootProps()} className="padding-10px" style={{ cursor: 'pointer' }}>
<input {...getInputProps()} />
<div className="u-p-title">
Drag 'n' drop some files here, or click to select files
</div>
</div>
</div>
: null }
: null}
{/* file */}
{ this.state.previewVisible
?
<div className="u-p-file u-p-preview">
<div className="display-flex-normal">
<div className="width width-35px">
<button
onClick={this.state.uploadProgress === true ? null : this.onRemove}
className="btn btn-small-circle btn-black"
type="button">
<i className="fa fa-1x fa-times" />
</button>
</div>
<div className="width width-full margin-left-10px">
<div className="txt-site txt-12 txt-white txt-bold">
{ this.state.nameFile }
{this.state.previewVisible
?
<div className="u-p-file u-p-preview">
<div className="display-flex-normal">
<div className="width width-35px">
<button
onClick={this.state.uploadProgress === true ? null : this.onRemove}
className="btn btn-small-circle btn-black"
type="button">
<i className="fa fa-1x fa-times" />
</button>
</div>
<div className="txt-site txt-11 txt-white txt-thin">
{ this.state.sizeFile } KB
<div className="width width-full margin-left-10px">
<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>
{/* this.state.uploadProgress === true
</div>
{/* this.state.uploadProgress === true
? (
<div className="width width-100px padding-10px txt-site txt-12 txt-white txt-thin">
({this.state.percentage})%
</div>
) : null */}
{this.props.type === 'upload' ?
<div className="width width-155px padding-10px txt-site txt-11 txt-white txt-thin">
Uploading {this.state.percentage}%
</div> : null }
{this.props.type === 'upload' ?
<div className="width width-155px padding-10px txt-site txt-11 txt-white txt-thin">
Uploading {this.state.percentage}%
</div> : null}
{this.props.disableButtonUpload !== true ? (
<div className="width width-35px">
<button
className="btn btn-small-circle"
type="button"
onClick={this.state.uploadProgress === true ? null : this.onUpload}>
{/*<i className={this.state.iconButtonUpload} />*/}
{this.state.uploadProgress === true
? <i className={ 'fa fa-1x fa-spinner fa-spin'} /> :
<img src={Images.upload} />}
</button>
</div>
) : null}
</div>
{this.props.type === 'upload' ?
<div className="margin-top-15px">
<LinearProgress variant="determinate" value={this.state.percentage} />
</div> : null }
{/* this.state.uploadProgress === true
{this.props.disableButtonUpload !== true ? (
<div className="width width-35px">
<button
className="btn btn-small-circle"
type="button"
onClick={this.state.uploadProgress === true ? null : this.onUpload}>
{/*<i className={this.state.iconButtonUpload} />*/}
{this.state.uploadProgress === true
? <i className={'fa fa-1x fa-spinner fa-spin'} /> :
<img src={Images.upload} />}
</button>
</div>
) : null}
</div>
{this.props.type === 'upload' ?
<div className="margin-top-15px">
<LinearProgress variant="determinate" value={this.state.percentage} />
</div> : null}
{/* this.state.uploadProgress === true
? (
<div className="margin-15px">
<LinearProgress variant="determinate" value={this.state.percentage} />
</div>
) : null */}
</div>
: null }
</div>
: null}
{/* image */}
{/* <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