Commit 65a675de authored by Deni Rinaldi's avatar Deni Rinaldi

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

1

See merge request !68
parents 436844fb 0c16c603
......@@ -83,6 +83,7 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
const createUnitBisnis = (body) => api.post('/business_unit/create_business_unit', body)
const updateUnitBisnis = (body) => api.post('/business_unit/update_business_unit', body)
const searchUnitBisnis = (body) => api.post('/business_unit/search_business_unit', body)
const checkUploadUnitBisnis = (body) => api.post('/business_unit/check_import', body)
// Perusahaan
const getPerusahaan = () => api.get('company/get_all_company')
......@@ -148,7 +149,8 @@ const create = (baseURL = 'https://trftia.eksad.com/tia-reporting-dev/public/')
createUser,
updateUser,
deleteUser,
downloadTemplate
downloadTemplate,
checkUploadUnitBisnis
}
}
......
......@@ -37,18 +37,40 @@ export default class UnitBisnis extends Component {
fileHandler = (event) => {
let fileObj = event
ExcelRenderer(fileObj, (err, resp) => {
console.log(resp)
if (err) {
console.log(err);
}
else {
let judul = resp.rows[0]
let isi = resp.rows.slice(1)
// let body = isi.map((item) => {
// return {
// item
// ]
// })
console.log(JSON.stringify(isi));
let judul = resp.rows[2]
let isi = resp.rows.slice(3)
let payload = []
isi.map((item, index) => {
payload.push({
id: index + 1,
business_unit_name: item[0],
start_date: item[1],
end_date: item[2],
})
})
let body = {
business_unit: payload
}
api.create().checkUploadUnitBisnis(body).then(response => {
console.log(response);
let dataRow = response.data.data.map((item, index) => {
return [
index+1,
item.business_unit_name,
item.start_date,
item.end_date,
item.error
]
})
})
// console.log(JSON.stringify(payload));
this.setState({
dataLoaded: true,
cols: judul,
......
......@@ -204,7 +204,7 @@ export default class CreateUnitBisnis extends Component {
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Hingga"
label="Berakhir Hingga"
format="dd MMMM yyyy"
value={this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
......@@ -381,7 +381,7 @@ export default class CreateUnitBisnis extends Component {
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
label="Berakhir Hingga"
format="dd MMMM yyyy"
value={this.state.endDate == "" ? null : this.state.endDate}
onChange={(e) => this.handleChange(e, '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