Commit ffa7a76b authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'deni-dev(pc)' into 'master'

senin siang

See merge request !250
parents 6ea8906c e14b3aca
...@@ -91,7 +91,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -91,7 +91,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const uploadUnitBisnis = (body) => api.post('/business_unit/import_business_unit', body) const uploadUnitBisnis = (body) => api.post('/business_unit/import_business_unit', body)
const getUnitBisnisActive = () => api.get('business_unit/get_all_business_unit_active') const getUnitBisnisActive = () => api.get('business_unit/get_all_business_unit_active')
const getDetailUnitBisnis = (id) => api.get(`business_unit/get_business_unit_by_id/${id}`) const getDetailUnitBisnis = (id) => api.get(`business_unit/get_business_unit_by_id/${id}`)
const deleteUnitBisnis = (id) => api.post(`business_unit/delete_business_unit/${id}`)
// Perusahaan // Perusahaan
const getPerusahaan = () => api.get('company/get_all_company') const getPerusahaan = () => api.get('company/get_all_company')
...@@ -154,6 +154,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -154,6 +154,7 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
const checkUploadParameter = (body) => api.post('setting/check_import', body) const checkUploadParameter = (body) => api.post('setting/check_import', body)
const uploadParameter = (body) => api.post('/setting/import_setting', body) const uploadParameter = (body) => api.post('/setting/import_setting', body)
const searchParameter = (body) => api.post('setting/search_setting', body) const searchParameter = (body) => api.post('setting/search_setting', body)
const deleteParameter = (id) => api.post(`setting/delete_setting/${id}`)
//Transaction //Transaction
const getReportTypeBody = (body) => api.post('transaction/get_all_report', body) const getReportTypeBody = (body) => api.post('transaction/get_all_report', body)
...@@ -268,7 +269,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') => ...@@ -268,7 +269,9 @@ const create = (baseURL = 'https://tia.eksad.com/tia-reporting-dev/public/') =>
getPeriodeTransaction, getPeriodeTransaction,
getRevision, getRevision,
deleteAttachment, deleteAttachment,
getDetailReportMB getDetailReportMB,
deleteUnitBisnis,
deleteParameter
} }
} }
......
...@@ -44,6 +44,7 @@ const Images = { ...@@ -44,6 +44,7 @@ const Images = {
logout: require('./setting.png'), logout: require('./setting.png'),
setting: require('./logout.png'), setting: require('./logout.png'),
failedCopy: require('./failed-copy.svg'), failedCopy: require('./failed-copy.svg'),
failed: require('./failed.svg'),
triputraLogo: require('./triputra-logo.png'), triputraLogo: require('./triputra-logo.png'),
photo: require('./photo.svg'), photo: require('./photo.svg'),
camera: require('./camera.svg'), camera: require('./camera.svg'),
......
<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72">
<g fill="none" fill-rule="evenodd">
<g>
<g>
<g>
<g transform="translate(-685 -449) translate(420 393) translate(265 56)">
<circle cx="36" cy="36" r="36" fill="#ED8080"/>
<path fill="#FF3939" d="M36 72c19.882 0 36-16.118 36-36S55.882 0 36 0"/>
<circle cx="35.95" cy="35.95" r="31.95" fill="#FFF" fill-rule="nonzero"/>
<g fill="#FF3939" transform="translate(31 17)">
<rect width="11" height="24" rx="3"/>
<circle cx="5.5" cy="32.5" r="5.5"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
...@@ -621,11 +621,10 @@ export default class CreateParameter extends Component { ...@@ -621,11 +621,10 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => { onChange={(e) => {
let coba = String(e.target.value).replace(/[^\d]/g, '');
this.setState({ this.setState({
tempData: { tempData: {
...this.state.tempData, ...this.state.tempData,
value: coba value: e.target.value
} }
}) })
this.clearMessage() this.clearMessage()
...@@ -1006,9 +1005,8 @@ export default class CreateParameter extends Component { ...@@ -1006,9 +1005,8 @@ export default class CreateParameter extends Component {
}} }}
name="value" name="value"
onChange={(e) => { onChange={(e) => {
let coba = String(e.target.value).replace(/[^\d]/g, '');
this.setState({ this.setState({
value: coba value: e.target.value
}) })
this.clearMessage() this.clearMessage()
} }
......
...@@ -11,6 +11,7 @@ import ReactTooltip from 'react-tooltip'; ...@@ -11,6 +11,7 @@ import ReactTooltip from 'react-tooltip';
import UploadFile from "../../../library/Upload"; import UploadFile from "../../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import Constant from '../../../library/Constant'; import Constant from '../../../library/Constant';
import PopUpDelete from '../../../library/PopUpDelete';
var ct = require("../../../library/CustomTable"); var ct = require("../../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -114,6 +115,11 @@ export default class Parameter extends Component { ...@@ -114,6 +115,11 @@ export default class Parameter extends Component {
rowData: rowData, rowData: rowData,
visibleEdit: true visibleEdit: true
}) })
} else if (type === 'delete') {
this.setState({
rowData: rowData,
visibleDelete: true
})
} else { } else {
this.setState({ this.setState({
rowData: rowData, rowData: rowData,
...@@ -268,14 +274,14 @@ export default class Parameter extends Component { ...@@ -268,14 +274,14 @@ export default class Parameter extends Component {
if (item.length > 0) { if (item.length > 0) {
payload.push({ payload.push({
id: index + 1, id: index + 1,
group: item[0] === undefined ? "" : item[0] , group: item[0] === undefined ? "" : item[0],
parameter: item[1] === undefined ? "" : item[1], parameter: item[1] === undefined ? "" : item[1],
company: item[2] === undefined ? "" : item[2], company: item[2] === undefined ? "" : item[2],
description: item[3], description: item[3] === undefined ? "" : item[3],
orders: item[4], orders: item[4] === undefined ? "" : item[4],
value: item[5], value: item[5] === undefined ? "" : item[5],
min_value: item[6], min_value: item[6] === undefined ? "" : item[6],
max_value: item[7], max_value: item[7] === undefined ? "" : item[7],
start_date: item[8] === undefined ? "" : item[8], start_date: item[8] === undefined ? "" : item[8],
end_date: item[9] === undefined ? "" : item[9], end_date: item[9] === undefined ? "" : item[9],
}) })
...@@ -290,7 +296,7 @@ export default class Parameter extends Component { ...@@ -290,7 +296,7 @@ export default class Parameter extends Component {
}); });
} }
checkUpload(){ checkUpload() {
api.create().checkUploadParameter(this.state.payload).then(response => { api.create().checkUploadParameter(this.state.payload).then(response => {
console.log(response); console.log(response);
if (response.data) { if (response.data) {
...@@ -329,9 +335,9 @@ export default class Parameter extends Component { ...@@ -329,9 +335,9 @@ export default class Parameter extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[11][check].message} data-for="group"> <a data-tip={tableMeta.rowData[11][check].message} data-for="group">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="group" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="group" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -354,9 +360,9 @@ export default class Parameter extends Component { ...@@ -354,9 +360,9 @@ export default class Parameter extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[11][check].message} data-for="parameter"> <a data-tip={tableMeta.rowData[11][check].message} data-for="parameter">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="parameter" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="parameter" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -379,9 +385,9 @@ export default class Parameter extends Component { ...@@ -379,9 +385,9 @@ export default class Parameter extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[11][check].message} data-for="company"> <a data-tip={tableMeta.rowData[11][check].message} data-for="company">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="company" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="company" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -529,9 +535,9 @@ export default class Parameter extends Component { ...@@ -529,9 +535,9 @@ export default class Parameter extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[11][check].message} data-for="start_date"> <a data-tip={tableMeta.rowData[11][check].message} data-for="start_date">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="start_date" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="start_date" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -554,9 +560,9 @@ export default class Parameter extends Component { ...@@ -554,9 +560,9 @@ export default class Parameter extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[11] != null && check > -1 ? {tableMeta.rowData[11] != null && check > -1 ?
<a data-tip={tableMeta.rowData[11][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[11][check].message} data-for="enddate">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -577,7 +583,7 @@ export default class Parameter extends Component { ...@@ -577,7 +583,7 @@ export default class Parameter extends Component {
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow, rows: dataRow,
visibleUpload: false, visibleUpload: false,
visibleParameter: false visibleParameter: false
}); });
} else { } else {
...@@ -641,6 +647,33 @@ export default class Parameter extends Component { ...@@ -641,6 +647,33 @@ export default class Parameter extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
deleteParameter(payload) {
let id = String(payload[1])
api.create().deleteParameter(id).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getAllParameter()
this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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' })
}
})
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -649,21 +682,39 @@ export default class Parameter extends Component { ...@@ -649,21 +682,39 @@ export default class Parameter extends Component {
filter: false, filter: false,
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> this.state.edit && (
{this.state.edit && ( <div style={{ display: 'flex' }}>
<button <a data-tip={'Edit'} data-for="edit">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent' cursor: 'pointer',
}} borderColor: 'transparent',
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')} marginRight: 15
// onClick={()=> console.log(tableMeta)} }}
> // onClick={() => console.log(tableMeta)}
<img src={Images.editCopy} /> onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
</button> >
)} <img src={Images.editCopy} />
</div > </button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
<a data-tip={'Delete'} data-for="delete">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
>
<img src={Images.delete} />
</button>
</a>
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</div >
)
); );
} }
} }
...@@ -983,6 +1034,16 @@ export default class Parameter extends Component { ...@@ -983,6 +1034,16 @@ export default class Parameter extends Component {
</div> </div>
</div> </div>
)} )}
{this.state.visibleDelete && (
<PopUpDelete
rowData={this.state.rowData}
intent={'parameter'}
onClickClose={() => this.setState({ visibleDelete: false })}
onClickDelete={this.deleteParameter.bind(this)}
/>
)}
</div> </div>
); );
} }
......
...@@ -89,7 +89,7 @@ export default class ReportItems extends Component { ...@@ -89,7 +89,7 @@ export default class ReportItems extends Component {
}); });
} }
checkUpload(){ checkUpload() {
api.create().checkUploadReportItems(this.state.payload).then(response => { api.create().checkUploadReportItems(this.state.payload).then(response => {
console.log(response) console.log(response)
let dataRow = [] let dataRow = []
...@@ -453,7 +453,7 @@ export default class ReportItems extends Component { ...@@ -453,7 +453,7 @@ export default class ReportItems extends Component {
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow, visibleUpload: false, rows: dataRow, visibleUpload: false,
itemReport: false itemReport: false
}); });
} else { } else {
...@@ -513,7 +513,9 @@ export default class ReportItems extends Component { ...@@ -513,7 +513,9 @@ export default class ReportItems extends Component {
let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => { let listData = data.sort((a, b) => a.item_report_id - b.item_report_id).map((item, index) => {
return [index, item.item_report_id, item.report_name, item.company_name, item.order, item.description, item.parent, item.uom, item.weight, item.type_item_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_item_report_name, item.status]
}) })
this.setState({ dataTable: listData, listData: response.data.data }) this.setState({ dataTable: listData, listData: response.data.data }, () => {
console.log(this.state.dataTable);
})
} else { } else {
this.setState({ 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")) {
...@@ -683,7 +685,7 @@ export default class ReportItems extends Component { ...@@ -683,7 +685,7 @@ export default class ReportItems extends Component {
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
...@@ -863,8 +865,8 @@ export default class ReportItems extends Component { ...@@ -863,8 +865,8 @@ export default class ReportItems extends Component {
this.state.load && ( this.state.load && (
<div> <div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -182 }}> <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', paddingRight: 25, paddingLeft: 25, marginTop: -182 }}>
<label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '50%', }}>Master Data - Report Items</label> <label style={{ color: 'white', fontSize: 16, alignSelf: 'center', width: '50%', }}>Master Data - Report Items</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' }}> {/* <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 }} /> <img src={Images.searchBlack} style={{ marginRight: 10 }} />
<InputBase <InputBase
style={{ width: '100%' }} style={{ width: '100%' }}
...@@ -874,38 +876,23 @@ export default class ReportItems extends Component { ...@@ -874,38 +876,23 @@ export default class ReportItems extends Component {
inputProps={{ 'aria-label': 'naked' }} inputProps={{ 'aria-label': 'naked' }}
/> />
</div> */} </div> */}
<div style={{ width: '50%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}> <div style={{ width: '50%', justifyContent: 'flex-end', display: 'flex', flexFlow: 'wrap' }}>
<a data-tip={'Download Template'} data-for="template"> <a data-tip={'Download Template'} data-for="template">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => this.downloadFile()} onClick={() => this.downloadFile()}
> >
<img src={Images.template} /> <img src={Images.template} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="template" place="bottom" type="light" effect="solid" />
{this.state.buttonCreate && ( {this.state.buttonCreate && (
<a data-tip={'Upload'} data-for="upload"> <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 <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -913,44 +900,70 @@ export default class ReportItems extends Component { ...@@ -913,44 +900,70 @@ export default class ReportItems extends Component {
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5
}} }}
onClick={() => this.downloadDataTable()} onClick={() => null}
> >
<img src={Images.download} /> <img src={Images.upload} onClick={() => this.setState({ visibleUpload: true })} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="visualisasi" place="bottom" type="light" effect="solid" /> )}
<a data-tip={'Visualization'} data-for="visualisasi"> <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="visualisasi" place="bottom" type="light" effect="solid" />
<a data-tip={'Visualization'} 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="tambah" place="bottom" type="light" effect="solid" />
{this.state.buttonCreate && (
<a data-tip={'Add New'} data-for="tambah">
<button <button
style={{ style={{
backgroundColor: 'transparent', backgroundColor: 'transparent',
cursor: 'pointer', cursor: 'pointer',
borderColor: 'transparent', borderColor: 'transparent',
margin: 5 margin: 5,
marginRight: 20
}} }}
onClick={() => this.setState({ visualisasi: true, itemReport: false })}
> >
<img src={Images.visualisasi} /> <img src={Images.add} onClick={() => this.setState({ add: true })} />
</button> </button>
</a> </a>
<ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" /> )}
{this.state.buttonCreate && ( <ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
<a data-tip={'Add New'} data-for="tambah">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5,
marginRight: 20
}}
>
<img src={Images.add} onClick={() => this.setState({ add: true })} />
</button>
</a>
)}
<ReactTooltip border={true} id="tambah" place="bottom" type="light" effect="solid" />
</div>
</div> </div>
</div>
<div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
</div> </div>
) )
: :
...@@ -1048,10 +1061,10 @@ export default class ReportItems extends Component { ...@@ -1048,10 +1061,10 @@ export default class ReportItems extends Component {
}} }}
onUpload={() => { onUpload={() => {
this.state.judul === "MASTER DATA - REPORT ITEMS" ? this.state.judul === "MASTER DATA - REPORT ITEMS" ?
this.checkUpload() : this.checkUpload() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning'}) this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}} }}
/> />
</div> </div>
</div> </div>
......
...@@ -13,6 +13,7 @@ import { ExcelRenderer } from 'react-excel-renderer'; ...@@ -13,6 +13,7 @@ import { ExcelRenderer } from 'react-excel-renderer';
import api from "../../api"; import api from "../../api";
import { isThisSecond } from "date-fns"; import { isThisSecond } from "date-fns";
import PopUpFailedSave from "../../library/PopUpFailedSave"; import PopUpFailedSave from "../../library/PopUpFailedSave";
import PopUpDelete from "../../library/PopUpDelete";
import Constant from "../../library/Constant"; import Constant from "../../library/Constant";
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
...@@ -29,6 +30,7 @@ export default class UnitBisnis extends Component { ...@@ -29,6 +30,7 @@ export default class UnitBisnis extends Component {
this.state = { this.state = {
visibleCreate: false, visibleCreate: false,
visibleEdit: false, visibleEdit: false,
visibleDelete: false,
dataTable: [], dataTable: [],
listData: [], listData: [],
data: [], data: [],
...@@ -45,6 +47,8 @@ export default class UnitBisnis extends Component { ...@@ -45,6 +47,8 @@ export default class UnitBisnis extends Component {
edit: false, edit: false,
load: false, load: false,
judul: '', judul: '',
rowData: [],
unitBisnisName: ''
// visibleLoad: true // visibleLoad: true
} }
this.fileHandler = this.fileHandler.bind(this); this.fileHandler = this.fileHandler.bind(this);
...@@ -80,7 +84,7 @@ export default class UnitBisnis extends Component { ...@@ -80,7 +84,7 @@ export default class UnitBisnis extends Component {
}); });
} }
checkUpload(){ checkUpload() {
api.create().checkUploadUnitBisnis(this.state.payload).then(response => { api.create().checkUploadUnitBisnis(this.state.payload).then(response => {
console.log(response) console.log(response)
let dataRow = [] let dataRow = []
...@@ -111,9 +115,9 @@ export default class UnitBisnis extends Component { ...@@ -111,9 +115,9 @@ export default class UnitBisnis extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[3] != null && check > -1 ? {tableMeta.rowData[3] != null && check > -1 ?
<a data-tip={tableMeta.rowData[3][check].message} data-for="unitbisnis"> <a data-tip={tableMeta.rowData[3][check].message} data-for="unitbisnis">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="unitbisnis" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="unitbisnis" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -136,9 +140,9 @@ export default class UnitBisnis extends Component { ...@@ -136,9 +140,9 @@ export default class UnitBisnis extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[3] != null && check > -1 ? {tableMeta.rowData[3] != null && check > -1 ?
<a data-tip={tableMeta.rowData[3][check].message} data-for="startdate"> <a data-tip={tableMeta.rowData[3][check].message} data-for="startdate">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="startdate" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -161,9 +165,9 @@ export default class UnitBisnis extends Component { ...@@ -161,9 +165,9 @@ export default class UnitBisnis extends Component {
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{tableMeta.rowData[3] != null && check > -1 ? {tableMeta.rowData[3] != null && check > -1 ?
<a data-tip={tableMeta.rowData[3][check].message} data-for="enddate"> <a data-tip={tableMeta.rowData[3][check].message} data-for="enddate">
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
</a> : </a> :
<span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "-" : val}</span> <span style={{ color: check != null && check > -1 ? "red" : 'black' }}>{val === "" ? "Empty" : val}</span>
} }
<ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="enddate" place="bottom" type="light" effect="solid" />
</div > </div >
...@@ -183,7 +187,7 @@ export default class UnitBisnis extends Component { ...@@ -183,7 +187,7 @@ export default class UnitBisnis extends Component {
this.setState({ this.setState({
dataLoaded: true, dataLoaded: true,
cols: columns, cols: columns,
rows: dataRow, visibleUpload: false, rows: dataRow, visibleUpload: false,
visibleUnitBisnis: false visibleUnitBisnis: false
}); });
} else { } else {
...@@ -273,6 +277,12 @@ export default class UnitBisnis extends Component { ...@@ -273,6 +277,12 @@ export default class UnitBisnis extends Component {
rowData: rowData, rowData: rowData,
visibleEdit: true visibleEdit: true
}) })
} else if (type === 'delete') {
this.setState({
rowData: rowData,
unitBisnisName: String(rowData[2]),
visibleDelete: true
})
} else { } else {
this.setState({ this.setState({
rowData: rowData, rowData: rowData,
...@@ -431,6 +441,34 @@ export default class UnitBisnis extends Component { ...@@ -431,6 +441,34 @@ export default class UnitBisnis extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
deleteUnitBisnis(payload) {
console.log(payload);
let id = String(payload[1])
api.create().deleteUnitBisnis(id).then(response => {
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getData()
this.setState({ visibleDelete: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} 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' })
}
})
}
render() { render() {
const columns = [{ const columns = [{
name: "Action", name: "Action",
...@@ -439,21 +477,39 @@ export default class UnitBisnis extends Component { ...@@ -439,21 +477,39 @@ export default class UnitBisnis extends Component {
sort: false, sort: false,
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> this.state.edit && (
{this.state.edit && ( <div style={{ display: 'flex' }}>
<button <a data-tip={'Edit'} data-for="edit">
style={{ <button
backgroundColor: 'transparent', style={{
cursor: 'pointer', backgroundColor: 'transparent',
borderColor: 'transparent', cursor: 'pointer',
}} borderColor: 'transparent',
// onClick={() => console.log(tableMeta)} marginRight: 15
onClick={() => this.openPopUp(tableMeta.rowData, 'edit')} }}
> // onClick={() => console.log(tableMeta)}
<img src={Images.editCopy} /> onClick={() => this.openPopUp(tableMeta.rowData, 'edit')}
</button> >
)} <img src={Images.editCopy} />
</div > </button>
</a>
<ReactTooltip border={true} id="edit" place="bottom" type="light" effect="solid" />
<a data-tip={'Delete'} data-for="delete">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, 'delete')}
>
<img src={Images.delete} />
</button>
</a>
<ReactTooltip border={true} id="delete" place="bottom" type="light" effect="solid" />
</div >
)
); );
} }
} }
...@@ -697,6 +753,16 @@ export default class UnitBisnis extends Component { ...@@ -697,6 +753,16 @@ export default class UnitBisnis extends Component {
</div> </div>
)} )}
{this.state.visibleDelete && (
<PopUpDelete
rowData={this.state.rowData}
name={this.state.unitBisnisName}
onClickClose={() => this.setState({ visibleDelete: false })}
onClickDelete={this.deleteUnitBisnis.bind(this)}
/>
)}
{/* {this.state.visibleLoad && ( {/* {this.state.visibleLoad && (
<div className="test app-popup-show"> <div className="test app-popup-show">
<div className="popup-content" style={{ textAlign: 'center'}}> <div className="popup-content" style={{ textAlign: 'center'}}>
......
import React, { Component } from 'react';
import Images from '../assets/Images';
import { Typography } from '@material-ui/core';
export default class PopUpDelete extends Component {
render() {
return (
<div className="test app-popup-show">
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} />
</div>
<div style={{ display: 'grid', justifyContent: 'center', marginTop: 20, paddingBottom: 20 }}>
<span style={{ textAlign: 'center', fontSize: 14, fontWeight: 'bold', fontFamily: 'Nunito Sans, sans-serif' }}>
{this.props.intent === 'parameter' ?
`Delete [${this.props.rowData[2]}, ${this.props.rowData[3]}, ${this.props.rowData[4]}, ${this.props.rowData[7] === "" ? this.props.rowData[8] + ' + ' + this.props.rowData[9] : this.props.rowData[7]}]?`
:
`Delete ${this.props.name}?`
}
</span>
</div>
<div className="border-top grid grid-2x" style={{ height: 56, backgroundColor: '#f5f5f5', paddingLeft: 20, paddingRight: 20 }}>
<div className="column-1" style={{ alignSelf: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickClose()}
>
<div style={{ width: 102, height: 30, border: 'solid 1px #354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#354960', fontSize: 11 }}>Cancel</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.props.onClickDelete(this.props.rowData)}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
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