Commit 37416bc8 authored by EKSAD's avatar EKSAD

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

parents c2e98b3b 06654911
...@@ -39,6 +39,9 @@ export default class ApprovalMatrix extends Component { ...@@ -39,6 +39,9 @@ export default class ApprovalMatrix extends Component {
rows: null, rows: null,
dataLoaded: false, dataLoaded: false,
popupError: false, popupError: false,
alert: false,
tipeAlert: '',
messageAlert: '',
btncreate: false, btncreate: false,
btnedit: false, btnedit: false,
load: false, load: false,
...@@ -75,10 +78,11 @@ export default class ApprovalMatrix extends Component { ...@@ -75,10 +78,11 @@ export default class ApprovalMatrix extends Component {
this.setState({ payload: body, buttonError: false }) this.setState({ payload: body, buttonError: false })
api.create().checkUploadAM(body).then(response => { api.create().checkUploadAM(body).then(response => {
// console.log(response.data) // console.log(response.data)
let dataRow = []
if(response.data){ if(response.data){
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => { dataRow = response.data.data.map((item, index) => {
return [ return [
index + 1, index + 1,
item.approval_type_name, item.approval_type_name,
...@@ -91,7 +95,7 @@ export default class ApprovalMatrix extends Component { ...@@ -91,7 +95,7 @@ export default class ApprovalMatrix extends Component {
] ]
}) })
let columns = [ let columns = [
"ID", "Data",
{ {
name: "Approval Type", name: "Approval Type",
options: { options: {
...@@ -257,7 +261,7 @@ export default class ApprovalMatrix extends Component { ...@@ -257,7 +261,7 @@ export default class ApprovalMatrix extends Component {
rows: dataRow rows: dataRow
}); });
} else { } else {
this.setState({ dataLoaded: false, alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) { if (response.data.message.includes("Token")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
...@@ -267,7 +271,7 @@ export default class ApprovalMatrix extends Component { ...@@ -267,7 +271,7 @@ export default class ApprovalMatrix extends Component {
}) })
} }
} else { } else {
this.setState({ dataLoaded: false, alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ this.setState({
...@@ -303,6 +307,8 @@ export default class ApprovalMatrix extends Component { ...@@ -303,6 +307,8 @@ export default class ApprovalMatrix extends Component {
load: true load: true
}) })
} }
} else {
this.setState({ load: true })
} }
}) })
} }
...@@ -820,7 +826,7 @@ export default class ApprovalMatrix extends Component { ...@@ -820,7 +826,7 @@ export default class ApprovalMatrix 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>
......
...@@ -215,7 +215,6 @@ export default class CreateApprovalMatrix extends Component { ...@@ -215,7 +215,6 @@ export default class CreateApprovalMatrix extends Component {
this.setState({ errorOrder: true, msgErrOrder: 'Order Cannot be Empty.'}) this.setState({ errorOrder: true, msgErrOrder: 'Order Cannot be Empty.'})
} }
else if (R.isNil(this.state.userId)) { else if (R.isNil(this.state.userId)) {
// return alert("Pemberi Persetujuan tidak boleh kosong");
this.setState({ errorApproved: true, msgErrApproved: 'Approver Name Cannot be Empty.' }) this.setState({ errorApproved: true, msgErrApproved: 'Approver Name Cannot be Empty.' })
} }
else if (R.isNil(this.state.operatorId)) { else if (R.isNil(this.state.operatorId)) {
......
...@@ -653,7 +653,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -653,7 +653,7 @@ export default class FixedAssetsMovement extends Component {
<div style={{ flex: 1, padding: 20, width: '100%' }}> <div style={{ flex: 1, padding: 20, width: '100%' }}>
<Paper style={{ paddingTop: 10, paddingBottom: 20 }}> <Paper style={{ paddingTop: 10, paddingBottom: 20 }}>
<div style={{ borderBottom: 'solid 1px #c4c4c4' }} > <div style={{ borderBottom: 'solid 1px #c4c4c4' }} >
<Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Master Budget - Fixed Assets Movement</Typography> <Typography style={{ fontSize: '12px', color: '#4b4b4b', margin: 10 }}>Budget Tahunan - Fixed Assets Movement</Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
<div> <div>
...@@ -685,7 +685,7 @@ export default class FixedAssetsMovement extends Component { ...@@ -685,7 +685,7 @@ export default class FixedAssetsMovement extends Component {
onClick={() => this.props.onClickClose()} onClick={() => this.props.onClickClose()}
> >
<div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}> <div style={{ backgroundColor: '#019ce5', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Kembali</Typography> <Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Back</Typography>
</div> </div>
</button> </button>
</div> </div>
......
...@@ -249,6 +249,8 @@ export default class CreatePerusahaan extends Component { ...@@ -249,6 +249,8 @@ export default class CreatePerusahaan extends Component {
validasiEdit() { validasiEdit() {
if (R.isEmpty(this.state.company)) { if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty.' }) this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty.' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPC: true, msgErrorPC: 'Parent Company Cannot be Empty.' })
} else if (R.isNil(this.state.getTypes)) { } else if (R.isNil(this.state.getTypes)) {
this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty.' }) this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty.' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
...@@ -260,7 +262,8 @@ export default class CreatePerusahaan extends Component { ...@@ -260,7 +262,8 @@ export default class CreatePerusahaan extends Component {
"company_id": this.state.companyID, "company_id": this.state.companyID,
"company_name": this.state.company, "company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id, // "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"parent": this.state.getPerusahaan.company_id,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
} }
...@@ -271,6 +274,8 @@ export default class CreatePerusahaan extends Component { ...@@ -271,6 +274,8 @@ export default class CreatePerusahaan extends Component {
validasi() { validasi() {
if (R.isEmpty(this.state.company)) { if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty.' }) this.setState({ errorNP: true, msgErrorNP: 'Company Name Cannot be Empty.' })
} else if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPC: true, msgErrorPC: 'Parent Company Cannot be Empty.' })
} else if (R.isNil(this.state.getTypes)) { } else if (R.isNil(this.state.getTypes)) {
this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty.' }) this.setState({ errorUB: true, msgErrorUB: 'Business Unit Cannot be Empty.' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
...@@ -281,7 +286,8 @@ export default class CreatePerusahaan extends Component { ...@@ -281,7 +286,8 @@ export default class CreatePerusahaan extends Component {
else { else {
let payload = { let payload = {
"company_name": this.state.company, "company_name": this.state.company,
"parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id, // "parent": this.state.getPerusahaan == null ? null : this.state.getPerusahaan.company_id,
"parent": this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id, "business_unit_id": this.state.getTypes.business_unit_id,
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
...@@ -452,8 +458,17 @@ export default class CreatePerusahaan extends Component { ...@@ -452,8 +458,17 @@ export default class CreatePerusahaan extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })} onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearError())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />} renderInput={(params) =>
<TextField
{...params}
label="Parent Company"
error={this.state.errorPC}
helperText={this.state.msgErrorPC}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
value={this.state.getPerusahaan} value={this.state.getPerusahaan}
/> />
</div> </div>
...@@ -662,9 +677,18 @@ export default class CreatePerusahaan extends Component { ...@@ -662,9 +677,18 @@ export default class CreatePerusahaan extends Component {
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
id="tipe" id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })} onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue }, ()=> this.clearError())}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />} renderInput={(params) =>
value={this.state.getPerusahaan} <TextField
{...params}
label="Parent Company"
error={this.state.errorPC}
helperText={this.state.msgErrorPC}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
/>
}
value={this.state.perusahaan}
/> />
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
......
...@@ -43,7 +43,8 @@ export default class UnitBisnis extends Component { ...@@ -43,7 +43,8 @@ export default class UnitBisnis extends Component {
messageAlert: '', messageAlert: '',
create: false, create: false,
edit: false, edit: false,
load: false load: false,
judul: ''
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
} }
...@@ -56,8 +57,6 @@ export default class UnitBisnis extends Component { ...@@ -56,8 +57,6 @@ export default class UnitBisnis extends Component {
console.log(err); console.log(err);
} }
else { else {
let judul = resp.rows[2]
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
let payload = [] let payload = []
isi.map((item, index) => { isi.map((item, index) => {
...@@ -73,7 +72,8 @@ export default class UnitBisnis extends Component { ...@@ -73,7 +72,8 @@ export default class UnitBisnis extends Component {
let body = { let body = {
business_unit: payload business_unit: payload
} }
this.setState({ payload: body, buttonError: false }) console.log(resp.rows[1])
this.setState({ payload: body, buttonError: false, judul: resp.rows[1][0] })
api.create().checkUploadUnitBisnis(body).then(response => { api.create().checkUploadUnitBisnis(body).then(response => {
console.log(response) console.log(response)
let dataRow = [] let dataRow = []
...@@ -174,7 +174,7 @@ export default class UnitBisnis extends Component { ...@@ -174,7 +174,7 @@ export default class UnitBisnis extends Component {
} }
] ]
console.log(dataRow); // console.log(dataRow);
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
...@@ -623,7 +623,8 @@ export default class UnitBisnis extends Component { ...@@ -623,7 +623,8 @@ export default class UnitBisnis extends Component {
</button> </button>
<button <button
type="button" type="button"
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadUnitBisnis()} disabled={this.state.buttonError == true ? true : false}
onClick={() => this.uploadUnitBisnis()}
style={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
...@@ -682,7 +683,11 @@ export default class UnitBisnis extends Component { ...@@ -682,7 +683,11 @@ export default class UnitBisnis extends Component {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
}} }}
onUpload={() => this.setState({ visibleUpload: false, visibleUnitBisnis: false })} onUpload={() => {
this.state.judul === "MASTER DATA - BUSINESS UNIT" ?
this.setState({ visibleUpload: false, visibleUnitBisnis: false }) :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning'})
}}
/> />
</div> </div>
</div> </div>
......
...@@ -38,7 +38,8 @@ export default class UserRole extends Component { ...@@ -38,7 +38,8 @@ export default class UserRole extends Component {
messageAlert: '', messageAlert: '',
buttonCreate: false, buttonCreate: false,
buttonEdit: false, buttonEdit: false,
load: false load: false,
judul: ''
} }
} }
...@@ -60,6 +61,7 @@ export default class UserRole extends Component { ...@@ -60,6 +61,7 @@ export default class UserRole extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
console.log(response.data);
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]
...@@ -102,7 +104,7 @@ export default class UserRole extends Component { ...@@ -102,7 +104,7 @@ export default class UserRole extends Component {
} }
} }
}) })
} }
searchUser() { searchUser() {
let payload = { let payload = {
...@@ -146,7 +148,7 @@ export default class UserRole extends Component { ...@@ -146,7 +148,7 @@ export default class UserRole extends Component {
// let judul = resp.rows[0] // let judul = resp.rows[0]
let isi = resp.rows.slice(3) let isi = resp.rows.slice(3)
let payload = [] let payload = []
console.log(isi) // console.log(isi)
isi.map((item, index) => { isi.map((item, index) => {
if (item.length > 0) { if (item.length > 0) {
payload.push({ payload.push({
...@@ -162,7 +164,8 @@ export default class UserRole extends Component { ...@@ -162,7 +164,8 @@ export default class UserRole extends Component {
let body = { let body = {
user: payload user: payload
} }
this.setState({ payload: body, rows: []}) console.log(resp.rows[1])
this.setState({ payload: body, rows: [], judul: resp.rows[1][0] })
api.create().checkUploadUser(body).then(response => { api.create().checkUploadUser(body).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -218,6 +221,7 @@ export default class UserRole extends Component { ...@@ -218,6 +221,7 @@ export default class UserRole extends Component {
check = tableMeta.rowData[6].findIndex((val) => val.field.includes('role')) check = tableMeta.rowData[6].findIndex((val) => val.field.includes('role'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
console.log('masuk')
} }
} }
return ( return (
...@@ -243,6 +247,7 @@ export default class UserRole extends Component { ...@@ -243,6 +247,7 @@ export default class UserRole extends Component {
check = tableMeta.rowData[6].findIndex((val) => val.field.includes('start_date')) check = tableMeta.rowData[6].findIndex((val) => val.field.includes('start_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
console.log('masuk')
} }
} }
return ( return (
...@@ -268,6 +273,7 @@ export default class UserRole extends Component { ...@@ -268,6 +273,7 @@ export default class UserRole extends Component {
check = tableMeta.rowData[6].findIndex((val) => val.field.includes('end_date')) check = tableMeta.rowData[6].findIndex((val) => val.field.includes('end_date'))
if (check > -1) { if (check > -1) {
this.setState({ buttonError: true }) this.setState({ buttonError: true })
console.log('masuk')
} }
} }
return ( return (
...@@ -373,7 +379,41 @@ export default class UserRole extends Component { ...@@ -373,7 +379,41 @@ export default class UserRole extends Component {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
}) })
} }
createUser(payload) {
api.create().createUser(payload).then((response) => {
// console.log(response)
// if (String(response.data.status).toLocaleUpperCase === 'Success' || String(response.data.status).toLocaleUpperCase === 'success') {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', create: false })
this.getUser()
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
// } else {
// alert(response.data.message)
// this.props.onClickClose()
// this.props.refresh()
// }
})
}
_handleKeyDown(e) { _handleKeyDown(e) {
if (e.key === 'Enter') { if (e.key === 'Enter') {
...@@ -387,10 +427,10 @@ export default class UserRole extends Component { ...@@ -387,10 +427,10 @@ 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) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
console.log(response)
this.getUser() this.getUser()
this.setState({ visibleUser: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' }) this.setState({ visibleUser: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else { } else {
...@@ -472,7 +512,7 @@ export default class UserRole extends Component { ...@@ -472,7 +512,7 @@ export default class UserRole extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<span style={{ color: tableMeta.rowData[6] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{titleCase(val)}</span> <span style={{ color: tableMeta.rowData[6] === "Active" ? "#656565" : 'rgba(0, 0, 0, 0.25)' }}>{val}</span>
</div > </div >
); );
} }
...@@ -675,7 +715,8 @@ export default class UserRole extends Component { ...@@ -675,7 +715,8 @@ export default class UserRole extends Component {
</button> </button>
<button <button
type="button" type="button"
onClick={() => this.state.buttonError ? this.setState({ popupError: true }) : this.uploadUser()} disabled={this.state.buttonError === true ? true : false}
onClick={() => this.uploadUser()}
style={{}} style={{}}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
...@@ -690,6 +731,7 @@ export default class UserRole extends Component { ...@@ -690,6 +731,7 @@ export default class UserRole extends Component {
onClickClose={this.closeAdd.bind(this)} onClickClose={this.closeAdd.bind(this)}
refresh={this.getUser.bind(this)} refresh={this.getUser.bind(this)}
data={this.state.indexData} data={this.state.indexData}
createUser={this.createUser.bind(this)}
/> />
)} )}
{this.state.edit && ( {this.state.edit && (
...@@ -706,7 +748,7 @@ export default class UserRole extends Component { ...@@ -706,7 +748,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 main-color" style={{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>
...@@ -731,7 +773,11 @@ export default class UserRole extends Component { ...@@ -731,7 +773,11 @@ export default class UserRole extends Component {
this.fileHandler(dt) this.fileHandler(dt)
this.setState({ uploadStatus: 'idle', percentage: '0' }) this.setState({ uploadStatus: 'idle', percentage: '0' })
}} }}
onUpload={() => this.setState({ visibleUpload: false, visibleUser: false })} onUpload={() => {
this.state.judul === 'MASTER DATA - USER' ?
this.setState({ visibleUpload: false, visibleUser: false }) :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/> />
</div> </div>
</div> </div>
......
...@@ -94,7 +94,8 @@ export default class AddUser extends Component { ...@@ -94,7 +94,8 @@ export default class AddUser extends Component {
let data = this.state let data = this.state
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type === 'start_date') { if (isDate && type === 'start_date') {
this.setState({ ...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null, this.setState({
...data, startDate: format(e, 'yyyy-MM-dd'), endDate: null,
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -107,7 +108,8 @@ export default class AddUser extends Component { ...@@ -107,7 +108,8 @@ export default class AddUser extends Component {
msgErrorED: '', msgErrorED: '',
}) })
} else if (isDate && type === 'end_date') { } else if (isDate && type === 'end_date') {
this.setState({ ...data, endDate: format(e, 'yyyy-MM-dd') , this.setState({
...data, endDate: format(e, 'yyyy-MM-dd'),
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -120,7 +122,8 @@ export default class AddUser extends Component { ...@@ -120,7 +122,8 @@ export default class AddUser extends Component {
msgErrorED: '', msgErrorED: '',
}) })
} else { } else {
this.setState({ ...data, [e.target.name]: e.target.value, this.setState({
...data, [e.target.name]: e.target.value,
errorFullname: false, errorFullname: false,
errorEmail: false, errorEmail: false,
errorRoleName: false, errorRoleName: false,
...@@ -163,23 +166,20 @@ export default class AddUser extends Component { ...@@ -163,23 +166,20 @@ export default class AddUser extends Component {
} else if (R.isEmpty(this.state.email)) { } else if (R.isEmpty(this.state.email)) {
this.setState({ errorEmail: true, msgErrorEM: 'Email Cannot be Empty.' }) this.setState({ errorEmail: true, msgErrorEM: 'Email Cannot be Empty.' })
} else if (!isEmail) { } else if (!isEmail) {
this.setState({ errorEmail: true, msgErrorEM: 'Email Format Not Recognized.' }) this.setState({ errorEmail: true, msgErrorEM: 'Please enter a valid email address.' })
} else if (R.isNil(this.state.role)) { } else if (R.isNil(this.state.role)) {
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name Cannot be Empty.' }) this.setState({ errorRoleName: true, msgErrorRN: 'Role Cannot be Empty.' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' }) this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty.' }) this.setState({ errorEndDate: true, msgErrorED: 'Valid To Cannot be Empty.' })
} else if (this.state.company.length < 1) {
this.setState({ alert: true, messageAlert: 'Authorization company cannot be empty', tipeAlert: 'warning' })
} }
// else if (this.state.privileges.length < 1) { // else if (this.state.privileges.length < 1) {
// alert('Hak Akses belum di pilih !!') // alert('Hak Akses belum di pilih !!')
// } // }
else { else {
this.createUser()
}
}
createUser() {
let payload = { let payload = {
"role_id": this.state.role.role_id, "role_id": this.state.role.role_id,
"email": this.state.email, "email": this.state.email,
...@@ -189,40 +189,8 @@ export default class AddUser extends Component { ...@@ -189,40 +189,8 @@ export default class AddUser extends Component {
"start_date": this.state.startDate, "start_date": this.state.startDate,
"end_date": this.state.endDate "end_date": this.state.endDate
} }
api.create().createUser(payload).then((response) => { this.props.createUser(payload)
// console.log(response)
// if (String(response.data.status).toLocaleUpperCase === 'Success' || String(response.data.status).toLocaleUpperCase === 'success') {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
setTimeout(() => {
this.props.onClickClose()
this.props.refresh()
}, 750);
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Token")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
} }
// } else {
// alert(response.data.message)
// this.props.onClickClose()
// this.props.refresh()
// }
})
} }
getRole() { getRole() {
...@@ -307,7 +275,7 @@ export default class AddUser extends Component { ...@@ -307,7 +275,7 @@ export default class AddUser extends Component {
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items,indexs) => { item.children.map((items, indexs) => {
this.handleItemClick(items) this.handleItemClick(items)
}) })
} }
...@@ -321,7 +289,7 @@ export default class AddUser extends Component { ...@@ -321,7 +289,7 @@ export default class AddUser extends Component {
} }
if (item.children !== null) { if (item.children !== null) {
if (item.children.length > 0) { if (item.children.length > 0) {
item.children.map((items,indexs) => { item.children.map((items, indexs) => {
this.handleItemClick(items) this.handleItemClick(items)
}) })
} }
...@@ -346,7 +314,7 @@ export default class AddUser extends Component { ...@@ -346,7 +314,7 @@ export default class AddUser extends Component {
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)? (data.children.length > 0? padding : padding + 30) : padding + 30}}> <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', paddingLeft: !R.isNil(data.children) ? (data.children.length > 0 ? padding : padding + 30) : padding + 30 }}>
{R.isNil(data.children) ? {R.isNil(data.children) ?
null null
: :
...@@ -505,7 +473,7 @@ export default class AddUser extends Component { ...@@ -505,7 +473,7 @@ export default class AddUser extends Component {
<div className="column-2"> <div className="column-2">
<div className=""> <div className="">
<TextField <TextField
style={{ width: '100%' , marginTop: 7}} style={{ width: '100%', marginTop: 7 }}
id="fullname" id="fullname"
name="fullname" name="fullname"
label="Full Name" label="Full Name"
...@@ -537,7 +505,7 @@ export default class AddUser extends Component { ...@@ -537,7 +505,7 @@ export default class AddUser extends Component {
<div className="column-1"> <div className="column-1">
<div className="margin-bottom-20px"> <div className="margin-bottom-20px">
<TextField <TextField
style={{ width: '100%' , marginTop: 7}} style={{ width: '100%', marginTop: 7 }}
id="email" id="email"
name="email" name="email"
label="Email" label="Email"
...@@ -569,14 +537,14 @@ export default class AddUser extends Component { ...@@ -569,14 +537,14 @@ export default class AddUser extends Component {
<Autocomplete <Autocomplete
{...this.state.listRole} {...this.state.listRole}
id="role" id="role"
onChange={(event, newInputValue) => this.setState({ role: newInputValue }, ()=> this.clearError())} onChange={(event, newInputValue) => this.setState({ role: newInputValue }, () => this.clearError())}
debug debug
renderInput={(params) => renderInput={(params) =>
<TextField <TextField
{...params} {...params}
label="Role" label="Role"
margin="normal" margin="normal"
style={{marginTop: 7}} style={{ marginTop: 7 }}
onChange={(e) => this.handleChange(e, '')} onChange={(e) => this.handleChange(e, '')}
error={this.state.errorRoleName} error={this.state.errorRoleName}
helperText={this.state.msgErrorRN} helperText={this.state.msgErrorRN}
......
...@@ -178,9 +178,9 @@ export default class EditUser extends Component { ...@@ -178,9 +178,9 @@ export default class EditUser extends Component {
} else if (R.isEmpty(this.state.tempData.email)) { } else if (R.isEmpty(this.state.tempData.email)) {
this.setState({ errorEmail: true, msgErrorEM: 'Email Cannot be Empty.' }) this.setState({ errorEmail: true, msgErrorEM: 'Email Cannot be Empty.' })
} else if (!isEmail) { } else if (!isEmail) {
this.setState({ errorEmail: true, msgErrorEM: 'Email Format Not Recognized.' }) this.setState({ errorEmail: true, msgErrorEM: 'Please enter a valid email address.' })
} else if (R.isNil(this.state.role)) { } else if (R.isNil(this.state.role)) {
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name Cannot be Empty.' }) this.setState({ errorRoleName: true, msgErrorRN: 'Role Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.start_date)) { } else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' }) this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.end_date)) { } else if (R.isNil(this.state.tempData.end_date)) {
......
...@@ -111,7 +111,7 @@ export default class AddRole extends Component { ...@@ -111,7 +111,7 @@ export default class AddRole extends Component {
validasi() { validasi() {
if (R.isEmpty(this.state.roleName)) { if (R.isEmpty(this.state.roleName)) {
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name Cannot be Empty.' }) this.setState({ errorRoleName: true, msgErrorRN: 'User Role Cannot be Empty.' })
} else if (R.isNil(this.state.startDate)) { } else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' }) this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' })
} else if (R.isNil(this.state.endDate)) { } else if (R.isNil(this.state.endDate)) {
......
...@@ -124,7 +124,7 @@ export default class EditRole extends Component { ...@@ -124,7 +124,7 @@ export default class EditRole extends Component {
validasi() { validasi() {
if (R.isEmpty(this.state.tempData.role_name)) { if (R.isEmpty(this.state.tempData.role_name)) {
this.setState({ errorRoleName: true, msgErrorRN: 'Role Name Cannot be Empty.' }) this.setState({ errorRoleName: true, msgErrorRN: 'User Role Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.start_date)) { } else if (R.isNil(this.state.tempData.start_date)) {
this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' }) this.setState({ errorStartDate: true, msgErrorSD: 'Valid From Cannot be Empty.' })
} else if (R.isNil(this.state.tempData.end_date)) { } else if (R.isNil(this.state.tempData.end_date)) {
......
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