Commit 47f45cd6 authored by faisalhamdi's avatar faisalhamdi

update company

parent ae8ec620
......@@ -29,8 +29,8 @@ export default class CreatePerusahaan extends Component {
this.setState({
id: data.company_id,
company: data.company_name,
parentCompany: data.parent,
unitBisnis: data.businessUnitId,
parentCompany: data.parentName,
unitBisnis: data.businessUnitName,
totalReport: data.total_report,
startDate: data.start_date,
endDate: data.end_date
......@@ -56,9 +56,9 @@ export default class CreatePerusahaan extends Component {
}
validasi() {
if (R.isEmpty(this.state.company)) return alert("Nama Perusahaan is Required.");
if (R.isEmpty(this.state.parentCompany)) return alert("Nama Perusahaan is Required.");
if (R.isEmpty(this.state.company)) return alert("Nama perusahaan harus diisi.");
if (R.isEmpty(this.state.unitBisnis)) return alert("Unit Bisnis is Required.");
if (R.isEmpty(this.state.parentCompany)) return alert("Parent Company is Required.");
if (R.isEmpty(this.state.totalReport)) return alert("Total Report is Required.");
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");
if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required.");
......@@ -355,6 +355,25 @@ export default class CreatePerusahaan extends Component {
<div className="border-bottom grid grid-2x grid-mobile-none gap-15px" style={{ padding: 20 }}>
<div className="column-1">
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="id"
label="ID"
disabled
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
......
......@@ -68,7 +68,7 @@ export default class Perusahaan extends Component {
if (response.data.status == 'success') {
let data = response.data.data
let listData = data.map((item, index) => {
return [index, item.company_id, item.company_name, item.parent, item.businessUnitId, item.total_report, item.status]
return [index, item.company_id, item.company_name, item.parentName, item.businessUnitName, item.total_report, item.status]
})
this.setState({ dataTable: listData, listData: response.data.data })
} else {
......@@ -132,6 +132,36 @@ export default class Perusahaan extends Component {
})
}
downloadFile = async () => {
let res = await fetch(
"https://trftia.eksad.com/tia-reporting-dev/public/attachment/download_file?fileName=CompanyTemplate&&fileType=xlsx"
)
res = await res.blob()
console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Template Perusahaan.xlsx';
a.click();
}
}
downloadDataTable = async () => {
let res = await fetch(
"https://trftia.eksad.com/tia-reporting-dev/public/company/export_company"
)
res = await res.blob()
console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = 'Perusahaan.xlsx';
a.click();
}
}
render() {
const columns = [{
name: "Action",
......@@ -247,23 +277,45 @@ export default class Perusahaan extends Component {
/>
</div>
<div style={{ width: '20%', justifyContent: 'space-around', display: 'flex', flexFlow: 'wrap' }}>
<img src={Images.template} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
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>
<img src={Images.download} />
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.downloadDataTable()}
>
<img src={Images.download} />
</button>
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
margin: 5
}}
onClick={() => null}
>
......@@ -273,7 +325,8 @@ export default class Perusahaan extends Component {
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent'
borderColor: 'transparent',
margin: 5
}}
onClick={() => this.setState({ visibleCreate: true })}
>
......
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