Commit 9905a31f authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'rifka' into 'master'

update index api dan validasi apprv matrix

See merge request !145
parents 5e620906 6969cbbf
......@@ -115,7 +115,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const updateAM = (body) => api.post('/approval_matrix/update_approval_matrix', body)
const updateVAM = (body) => api.post('/approval_matrix/visual_approval_matrix', body)
const checkUploadAM = (body) => api.post('/approval_matrix/check_import_approval_matrix', body)
const uploadAM = (body) => api.post('/approval_matrix/check_import_approval_matrix', body)
const uploadAM = (body) => api.post('approval_matrix/import_approval_matrix', body)
//User
const getUser = () => api.get('user/get_all_user')
......
......@@ -46,7 +46,7 @@ export default class ApprovalMatrix extends Component {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
if (err) {
console.log(err);
// console.log(err);
}
else {
let judul = resp.rows[2]
......@@ -55,7 +55,7 @@ export default class ApprovalMatrix extends Component {
isi.map((item, index) => {
if (item.length > 0) {
payload.push({
// id: index + 1,
id: index + 1,
approval_type_name: item[0],
orders: item[1],
fullname: item[2],
......@@ -70,7 +70,8 @@ export default class ApprovalMatrix extends Component {
}
this.setState({ payload: body, buttonError: false })
api.create().checkUploadAM(body).then(response => {
console.log(response.data)
// console.log(response.data)
if(response.data){
if (response.data.status === "success") {
let dataRow = response.data.data.map((item, index) => {
return [
......@@ -90,7 +91,6 @@ export default class ApprovalMatrix extends Component {
name: "Tipe Persetujuan",
options: {
customBodyRender: (val, tableMeta) => {
// console.log(tableMeta)
let check = null
if (tableMeta.rowData[7] != null) {
check = tableMeta.rowData[7].findIndex((val) => val.field.includes('approval_type_name'))
......@@ -252,10 +252,11 @@ export default class ApprovalMatrix extends Component {
rows: dataRow
});
}
// console.log(response);
} else {
this.setState({
dataLoaded: false,
});
}
})
}
});
......@@ -401,10 +402,9 @@ export default class ApprovalMatrix extends Component {
uploadAM() {
api.create().uploadAM(this.state.payload).then(response => {
console.log(response.data)
console.log(response)
if (response.data) {
if (response.data.status === "success") {
// console.log(this.state.payload)
this.getData()
this.setState({ visibleAM: true, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
......@@ -547,6 +547,7 @@ export default class ApprovalMatrix extends Component {
/>
</div>
<div style={{ width: '30%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template">
<button
style={{
backgroundColor: 'transparent',
......@@ -557,8 +558,11 @@ export default class ApprovalMatrix extends Component {
}}
onClick={() => this.downloadFile()}
>
<img src={Images.template} title="Download Template" />
<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',
......@@ -570,8 +574,11 @@ export default class ApprovalMatrix extends Component {
}}
onClick={() => this.setState({ visibleUpload: true })}
>
<img src={Images.upload} title="Upload File" />
<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',
......@@ -583,8 +590,11 @@ export default class ApprovalMatrix extends Component {
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} title="Download File" />
<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',
......@@ -596,8 +606,11 @@ export default class ApprovalMatrix extends Component {
}}
onClick={() => this.setState({ visibleVisual: true, visibleAM: false })}
>
<img src={Images.visualisasi} title="Visualisasi" />
<img src={Images.visualisasi} />
</button>
</a>
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" />
<a data-tip={'Tambah'} data-for="create">
<button
style={{
backgroundColor: 'transparent',
......@@ -611,6 +624,8 @@ export default class ApprovalMatrix extends Component {
>
<img src={Images.add} title="Tambah Approval Matrix" />
</button>
</a>
<ReactTooltip border={true} id="create" place="bottom" type="light" effect="solid" />
</div >
</div>
<div style={{ padding: 25, width: '100%' }}>
......@@ -718,7 +733,7 @@ export default class ApprovalMatrix 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' })
......
......@@ -28,6 +28,10 @@ export default class CreateApprovalMatrix extends Component {
msgErrOrder: '',
errorType: false,
msgErrType: '',
errorApproved: false,
msgErrApproved: '',
errorOperator: false,
msgErrOperator: '',
errorStartDate: false,
errorEndDate: false,
msgErrorStartDate: "",
......@@ -140,6 +144,10 @@ export default class CreateApprovalMatrix extends Component {
msgErrOrder: "",
errorType: false,
msgErrType: '',
errorApproved: false,
msgErrApproved: '',
errorOperator: false,
msgErrOperator: '',
errorStartDate: false,
errorEndDate: false,
msgErrorStartDate: "",
......@@ -149,13 +157,18 @@ export default class CreateApprovalMatrix extends Component {
validasi() {
if (R.isNil(this.state.typeId)) {
return alert("Tipe Persetujuan tidak boleh kosong");
this.setState({ errorType: true, msgErrType: 'Tipe Persetujuan tidak boleh kosong' })
}
else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrOrder: 'Order tidak boleh kosong'})
}
else if (R.isNil(this.state.userId)) return alert("Pemberi Persetujuan tidak boleh kosong");
else if (R.isNil(this.state.operatorId)) return alert("Operator tidak boleh kosong");
else if (R.isNil(this.state.userId)) {
// return alert("Pemberi Persetujuan tidak boleh kosong");
this.setState({ errorApproved: true, msgErrApproved: 'Pemberi Persetujuan tidak boleh kosong' })
}
else if (R.isNil(this.state.operatorId)) {
this.setState({ errorOperator: true, msgErrOperator: 'Operator tidak boleh kosong' })
}
else if (R.isNil(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Tanggal Mulai tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) {
......@@ -225,29 +238,26 @@ export default class CreateApprovalMatrix extends Component {
<Autocomplete
{...this.state.types}
id="tipe"
onChange={(event, newInputValue) => this.setState({typeId:newInputValue})}
onChange={(event, newInputValue) => this.setState({typeId:newInputValue}, ()=> this.clearError())}
debug
renderInput={(params) =>
<TextField
{...params}
label="Tipe Persetujuan"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorType}
helperText={this.state.msgErrType}
InputLabelProps={{
style: {
fontSize: 11,
fontFamily: 'Nunito Sans, sans-serif',
color: '#7e8085'
}
}}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputProps={{ ...params.InputProps, style: { fontSize: 11, fontFamily: 'Nunito Sans, sans-serif' } }}
/>
}
value={this.state.typeId}
error={this.state.errorType}
helperText={this.state.msgErrType}
// inputProps={{
// style: {
// fontSize: 11
// }
// }}
/>
</div>
</div>
......@@ -284,12 +294,15 @@ export default class CreateApprovalMatrix extends Component {
<Autocomplete
{...this.state.approvedBy}
id="approvedby"
onChange={(event, newInputValue) => this.setState({userId:newInputValue})}
onChange={(event, newInputValue) => this.setState({userId:newInputValue}, ()=> this.clearError())}
// disableClearable
debug
renderInput={(params) =>
<TextField {...params}
label="Pemberi Persetujuan"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorApproved}
helperText={this.state.msgErrApproved}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -299,12 +312,6 @@ export default class CreateApprovalMatrix extends Component {
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.userId}
// inputProps={{
// style: {
// fontSize: 11
// }
// }}
// style={{ padding: 0, margin: 0, width: '100%'}}
/>
</div>
</div>
......@@ -317,10 +324,13 @@ export default class CreateApprovalMatrix extends Component {
id="operator"
// disableClearable
debug
onChange={(event, newInputValue) => this.setState({operatorId:newInputValue})}
onChange={(event, newInputValue) => this.setState({operatorId:newInputValue}, ()=> this.clearError())}
renderInput={(params) =>
<TextField {...params}
label="Operator"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorOperator}
helperText={this.state.msgErrOperator}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -330,12 +340,6 @@ export default class CreateApprovalMatrix extends Component {
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
/>}
value={this.state.operatorId}
// inputProps={{
// style: {
// fontSize: 11
// }
// }}
// style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
......
......@@ -22,6 +22,12 @@ export default class EditApprovalMatrix extends Component {
getTypes: null,
operators: null,
getOperators: null,
errorType: false,
msgErrType: '',
errorApproved: false,
msgErrApproved: '',
errorOperator: false,
msgErrOperator: '',
errorOrder: false,
msgErrOrder: '',
errorStartDate: false,
......@@ -153,6 +159,12 @@ export default class EditApprovalMatrix extends Component {
clearError() {
this.setState({
errorType: false,
msgErrType: '',
errorApproved: false,
msgErrApproved: '',
errorOperator: false,
msgErrOperator: '',
errorOrder: false,
msgErrOrder: "",
errorStartDate: false,
......@@ -164,14 +176,17 @@ export default class EditApprovalMatrix extends Component {
validasi() {
if (R.isNil(this.state.getTypes)) {
return alert("Tipe Persetujuan tidak boleh kosong");
this.setState({ errorType: true, msgErrType: 'Tipe Persetujuan tidak boleh kosong' })
}
else if (R.isEmpty(this.state.order)) {
this.setState({ errorOrder: true, msgErrOrder: 'Order tidak boleh kosong'})
}
else if (R.isNil(this.state.getApprovedBy)) return alert("Pemberi Persetujuan tidak boleh kosong");
else if (R.isNil(this.state.getOperators)) return alert("Operator tidak boleh kosong");
else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai");
else if (R.isNil(this.state.getApprovedBy)) {
this.setState({ errorApproved: true, msgErrApproved: 'Pemberi Persetujuan tidak boleh kosong' })
}
else if (R.isNil(this.state.getOperators)) {
this.setState({ errorOperator: true, msgErrOperator: 'Operator tidak boleh kosong' })
}
else if (R.isEmpty(this.state.startDate)) {
this.setState({ errorStartDate: true, msgErrorStartDate: 'Tanggal Mulai tidak boleh kosong' })
} else if (R.isEmpty(this.state.endDate)) {
......@@ -246,10 +261,13 @@ export default class EditApprovalMatrix extends Component {
option
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({getTypes:newInputValue})}
onChange={(event, newInputValue) => this.setState({getTypes:newInputValue}, ()=> this.clearError())}
renderInput={(params) =>
<TextField {...params}
label="Tipe Persetujuan"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorType}
helperText={this.state.msgErrType}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -298,10 +316,13 @@ export default class EditApprovalMatrix extends Component {
option
debug
id="approvedby"
onChange={(event, newInputValue) => this.setState({getApprovedBy: newInputValue})}
onChange={(event, newInputValue) => this.setState({getApprovedBy: newInputValue}, ()=> this.clearError())}
renderInput={(params) =>
<TextField {...params}
label="Pemberi Persetujuan"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorApproved}
helperText={this.state.msgErrApproved}
InputLabelProps={{
style: {
fontSize: 11,
......@@ -321,12 +342,15 @@ export default class EditApprovalMatrix extends Component {
<Autocomplete
{...this.state.operators}
option
disableClearable
debug
id="operator"
onChange={(event, newInputValue) => this.setState({getOperators: newInputValue})}
onChange={(event, newInputValue) => this.setState({getOperators: newInputValue}, ()=> this.clearError())}
renderInput={(params) =>
<TextField {...params}
label="Operator"
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorOperator}
helperText={this.state.msgErrOperator}
InputLabelProps={{
style: {
fontSize: 11,
......
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