Commit 20342c85 authored by Deni Rinaldi's avatar Deni Rinaldi

Merge branch 'faisal' into 'master'

update company

See merge request !133
parents 0eb344cf 4c88492d
...@@ -13,38 +13,91 @@ export default class CreatePerusahaan extends Component { ...@@ -13,38 +13,91 @@ export default class CreatePerusahaan extends Component {
this.state = { this.state = {
id: '', id: '',
company: '', company: '',
companyID: '',
parentCompany: '', parentCompany: '',
unitBisnis: '', unitBisnis: '',
totalReport: '', totalReport: '',
startDate: '', startDate: '',
endDate: '', endDate: '',
status: '',
types: null, types: null,
getTypes: null, getTypes: null,
perusahaan: null, perusahaan: null,
getPerusahaan: null, getPerusahaan: null,
errorNP: false,
errorPC: false,
errorSD: false,
errorED: false,
errorJL: false,
errorUB: false,
msgErrorNP: '',
msgErrorPC: '',
msgErrorSD: '',
msgErrorED: '',
msgErrorJL: '',
msgErrorUB: ''
} }
} }
render() {
let { type } = this.props
return type === 'edit' ? this.renderEdit() : this.renderCreate()
}
componentDidMount() { componentDidMount() {
this.getParentCompany() this.getParentCompany()
this.getAllUnitBisnis() this.getAllUnitBisnis()
if(this.props.type === 'edit') {
let data = this.props.data
this.getDetailPerusahaan(data.company_id,)
console.log(this.props.data);
} else {
let date = format(new Date, 'yyyy-MM-dd')
// console.log(date);
this.setState({
startDate: date,
endDate: date
})
}
} }
getParentCompany() { getDetailPerusahaan(id) {
api.create().getPerusahaanActive().then((response) => { api.create().getDetailPerusahaan(id).then(response => {
if (response.data.status === "success") {
console.log(response);
this.setState({
businessID: response.data.data.business_unit_id,
companyID: response.data.data.company_id,
status: response.data.data.status,
company: response.data.data.company_name,
parentID: response.data.data.parent,
parent: response.data.data.parent_name,
startDate: response.data.data.start_date,
endDate: response.data.data.end_date,
totalReport: response.data.data.total_report,
created: response.data.data.created,
updated: response.data.data.updated === null ? "" : response.data.data.updated
}, () => this.getAllUnitBisnis(), this.getCompanyActive())
}
})
}
getCompanyActive() {
api.create().getPerusahaanActive().then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let perusahaanData = data.map((item) => {
return { return {
company_id: item.company_id, company_id: item.company_id,
company_name: item.company_name company_name: item.company_name
} }
}) })
let index = perusahaanData.sort((a, b) => a.company_id - b.company_id).findIndex((val) => val.company_id == this.state.parentID)
let typeProps = { let typeProps = {
options: typeData.sort((a, b) => a.company_id - b.company_id), options: perusahaanData,
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data }) this.setState({ perusahaan: typeProps, perusahaanData: response.data.data, getPerusahaan: index == -1 ? perusahaanData[0] : perusahaanData[index] })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -53,8 +106,7 @@ export default class CreatePerusahaan extends Component { ...@@ -53,8 +106,7 @@ export default class CreatePerusahaan extends Component {
getAllUnitBisnis() { getAllUnitBisnis() {
api.create().getUnitBisnisActive().then(response => { api.create().getUnitBisnisActive().then(response => {
console.log(response); if (response.data.status === 'success') {
if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
let typeData = data.map((item) => { let typeData = data.map((item) => {
return { return {
...@@ -62,11 +114,35 @@ export default class CreatePerusahaan extends Component { ...@@ -62,11 +114,35 @@ export default class CreatePerusahaan extends Component {
business_unit_name: item.business_unit_name business_unit_name: item.business_unit_name
} }
}) })
// console.log(typeData)
let index = typeData.findIndex((val) => val.business_unit_id == this.state.businessID)
console.log(index)
let typeProps = { let typeProps = {
options: typeData, options: typeData,
getOptionLabel: (option) => option.business_unit_name, getOptionLabel: (option) => option.business_unit_name,
}; };
this.setState({ types: typeProps, typeData: response.data.data }) this.setState({ types: typeProps, typeData: response.data.data, getTypes: index == -1 ? typeData[0] : typeData[index] })
} else {
alert(response.data.message)
}
})
}
getParentCompany() {
api.create().getPerusahaanActive().then((response) => {
if (response.data.status === 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let typeProps = {
options: typeData.sort((a, b) => a.company_id - b.company_id),
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
} else { } else {
alert(response.data.message) alert(response.data.message)
} }
...@@ -78,10 +154,12 @@ export default class CreatePerusahaan extends Component { ...@@ -78,10 +154,12 @@ export default class CreatePerusahaan extends Component {
let isDate = type !== '' ? true : false let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') { if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => { this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
this.clearError()
console.log(this.state.startDate) console.log(this.state.startDate)
}) })
} else if (isDate && type == 'end_date') { } else if (isDate && type == 'end_date') {
this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => { this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
this.clearError()
console.log(this.state.endDate) console.log(this.state.endDate)
}) })
} else { } else {
...@@ -90,32 +168,80 @@ export default class CreatePerusahaan extends Component { ...@@ -90,32 +168,80 @@ export default class CreatePerusahaan extends Component {
} }
clearError() {
this.setState({
errorNP: false,
errorPC: false,
errorSD: false,
errorED: false,
errorJL: false,
msgErrorNP: '',
msgErrorPC: '',
msgErrorSD: '',
msgErrorED: '',
msgErrorJL: '',
})
}
validasiEdit() {
if (R.isEmpty(this.state.company)) {
this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
// } else if (R.isEmpty(this.state.totalReport)) {
// this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else if (R.isNil(this.state.startDate)) {
this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
} else if (R.isNil(this.state.endDate)) {
this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
} else {
let payload = {
"company_id": this.state.companyID,
"company_name": this.state.company,
"business_unit_id": this.state.getTypes.business_unit_id,
"parent": this.state.getPerusahaan.company_id,
// "total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
// console.log(payload);
this.props.updatePerusahaan(payload)
}
}
validasi() { validasi() {
if (R.isEmpty(this.state.company)) return alert("Nama perusahaan harus diisi."); if (R.isEmpty(this.state.company)) {
if (R.isEmpty(this.state.totalReport)) return alert("Total Report is Required."); this.setState({ errorNP: true, msgErrorNP: 'Nama perusahaan harus diisi' })
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.types)) {
if (R.isEmpty(this.state.startDate)) return alert("Tanggal Mulai is Required."); this.setState({ errorUB: true, msgErrorUB: 'Unit Bisnis harus diisi' })
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required."); } else if (R.isNil(this.state.startDate)) {
let payload = { this.setState({ errorSD: true, msgErrorSD: 'Start Date tidak boleh kosong' })
"company_name": this.state.company, } else if (R.isNil(this.state.endDate)) {
"parent": this.state.getPerusahaan.company_id, this.setState({ errorED: true, msgErrorED: 'End Date tidak boleh kosong' })
"business_unit_id": this.state.getTypes.business_unit_id, } else if (!R.isEmpty(this.state.startDate) && !R.isEmpty(this.state.endDate) && (this.state.startDate > this.state.endDate)) {
"total_report": this.state.totalReport, return alert("Masa Berlaku Tidak Boleh Kurang Dari Tanggal Mulai")
"start_date": this.state.startDate, } else if (R.isEmpty(this.state.totalReport)) {
"end_date": this.state.endDate this.setState({ errorJL: true, msgErrorJL: 'Total Report harus diisi' })
} else {
let payload = {
"company_name": this.state.company,
"parent": this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id,
"total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
console.log(payload);
this.props.createPerusahaan(payload)
} }
console.log(payload);
this.props.createPerusahaan(payload)
} }
render() { renderEdit() {
return ( return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}> <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' }}>Create Data</span> <span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Ubah Data</span>
</div> </div>
</div> </div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}> <div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
...@@ -135,6 +261,7 @@ export default class CreatePerusahaan extends Component { ...@@ -135,6 +261,7 @@ export default class CreatePerusahaan extends Component {
<div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}> <div style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
value={this.state.companyID}
id="id" id="id"
label="ID" label="ID"
disabled disabled
...@@ -151,7 +278,7 @@ export default class CreatePerusahaan extends Component { ...@@ -151,7 +278,7 @@ export default class CreatePerusahaan extends Component {
}} }}
/> />
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
{...this.state.types} {...this.state.types}
debug debug
...@@ -161,7 +288,129 @@ export default class CreatePerusahaan extends Component { ...@@ -161,7 +288,129 @@ export default class CreatePerusahaan extends Component {
value={this.state.getTypes} value={this.state.getTypes}
/> />
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
error={this.state.errorSD}
helperText={this.state.msgErrorSD}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
<div className="margin-top-10px" style={{ backgroundColor: '#e8e8e8', padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
value={this.state.status}
id="status"
label="Status"
disabled
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Dibuat</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.created}</Typography>
</div>
<div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '20%' }}>Diubah</Typography>
<Typography style={{ fontSize: 11 }}>: {this.state.updated == - null ? "" : this.props.data.updated}</Typography>
</div>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="perusahaan"
label="Nama Perusahaan"
value={this.state.company}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
error={this.state.errorNP}
helperText={this.state.msgErrorNP}
onChange={(e) => this.setState({ company: e.target.value }, () => this.clearError())}
>
</TextField>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.perusahaan}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />}
value={this.state.getPerusahaan}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
format="dd MMMM yyyy"
value={this.state.endDate}
minDate={this.state.startDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
error={this.state.errorED}
helperText={this.state.msgErrorED}
/>
</div>
{/* <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField <TextField
style={{ width: '100%' }} style={{ width: '100%' }}
id="report" id="report"
...@@ -178,10 +427,114 @@ export default class CreatePerusahaan extends Component { ...@@ -178,10 +427,114 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ totalReport: e.target.value })} onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())}
error={this.state.errorJL}
helperText={this.state.msgErrorJL}
> >
</TextField> </TextField>
</div> */}
</div>
</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 }}>Batal</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasiEdit()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div>
</div>
</div>
</div>
)
}
renderCreate() {
return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}>
<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="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
</button>
</div>
</div>
<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>
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })}
renderInput={(params) =>
<TextField
{...params}
label="Unit Bisnis"
margin="normal"
style={{marginTop: 7}}
onChange={(e) => this.handleChange(e, '')}
error={this.state.errorUB}
helperText={this.state.msgErrorUB}
InputProps={{ ...params.InputProps, style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
// onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => this.clearError())}
/>
}
value={this.state.types}
// value={this.state.getTypes}
// error={this.state.errorUB}
// helperText={this.state.msgErrorUB}
// onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue }, () => this.clearError())}
/>
</div>
<div style={{ padding: 10, borderRadius: 5 }}> <div style={{ padding: 10, borderRadius: 5 }}>
<DatePicker <DatePicker
margin="normal" margin="normal"
...@@ -253,11 +606,13 @@ export default class CreatePerusahaan extends Component { ...@@ -253,11 +606,13 @@ export default class CreatePerusahaan extends Component {
color: '#7e8085' color: '#7e8085'
} }
}} }}
onChange={(e) => this.setState({ company: e.target.value })} error={this.state.errorNP}
helperText={this.state.msgErrorNP}
onChange={(e) => this.setState({ company: e.target.value }, () => this.clearError())}
> >
</TextField> </TextField>
</div> </div>
<div style={{ padding: 10, borderRadius: 5 }}> <div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete <Autocomplete
{...this.state.perusahaan} {...this.state.perusahaan}
debug debug
...@@ -273,8 +628,11 @@ export default class CreatePerusahaan extends Component { ...@@ -273,8 +628,11 @@ export default class CreatePerusahaan extends Component {
id="endDate" id="endDate"
label="Berlaku Hingga" label="Berlaku Hingga"
format="dd MMMM yyyy" format="dd MMMM yyyy"
error={this.state.errorED}
helperText={this.state.msgErrorED}
minDate={this.state.startDate} minDate={this.state.startDate}
value={this.state.endDate == "" ? null : this.state.endDate} // value={this.state.endDate == "" ? null : this.state.endDate}
value={this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')} onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{ KeyboardButtonProps={{
'aria-label': 'change date', 'aria-label': 'change date',
...@@ -294,6 +652,29 @@ export default class CreatePerusahaan extends Component { ...@@ -294,6 +652,29 @@ export default class CreatePerusahaan extends Component {
style={{ padding: 0, margin: 0, width: '100%' }} style={{ padding: 0, margin: 0, width: '100%' }}
/> />
</div> </div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="report"
label="Jumlah Laporan"
value={this.state.totalReport}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
error={this.state.errorJL}
helperText={this.state.msgErrorJL}
onChange={(e) => this.setState({ totalReport: e.target.value }, () => this.clearError())}
>
</TextField>
</div>
</div> </div>
</div> </div>
......
import React, { Component } from 'react';
import { TextField, Typography } from '@material-ui/core';
import * as R from 'ramda';
import { DateTimePicker, KeyboardDatePicker, DatePicker } from "@material-ui/pickers";
import format from "date-fns/format";
import Autocomplete from '@material-ui/lab/Autocomplete';
import api from '../../../api';
import Images from '../../../assets/Images';
export default class CreatePerusahaan extends Component {
constructor(props) {
super(props)
this.state = {
id: '',
company: '',
parentCompany: '',
unitBisnis: '',
totalReport: '',
startDate: '',
endDate: '',
types: null,
getTypes: null,
perusahaan: null,
getPerusahaan: null,
}
}
componentDidMount() {
this.getParentCompany()
this.getAllUnitBisnis()
}
getParentCompany() {
api.create().getPerusahaanActive().then((response) => {
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
company_id: item.company_id,
company_name: item.company_name
}
})
let typeProps = {
options: typeData.sort((a, b) => a.company_id - b.company_id),
getOptionLabel: (option) => option.company_name,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
} else {
alert(response.data.message)
}
})
}
getAllUnitBisnis() {
api.create().getUnitBisnisActive().then(response => {
console.log(response);
if (response.data.status == 'success') {
let data = response.data.data
let typeData = data.map((item) => {
return {
business_unit_id: item.business_unit_id,
business_unit_name: item.business_unit_name
}
})
let typeProps = {
options: typeData,
getOptionLabel: (option) => option.business_unit_name,
};
this.setState({ types: typeProps, typeData: response.data.data })
} else {
alert(response.data.message)
}
})
}
handleChange(e, type) {
let data = this.state
let isDate = type !== '' ? true : false
if (isDate && type == 'start_date') {
this.setState({ startDate: format(e, 'yyyy-MM-dd'), endDate: null }, () => {
console.log(this.state.startDate)
})
} else if (isDate && type == 'end_date') {
this.setState({ endDate: format(e, 'yyyy-MM-dd') }, () => {
console.log(this.state.endDate)
})
} else {
// this.setState({...data, tempData: {...this.state.tempData, [e.target.name] : e.target.value}})
}
}
validasi() {
if (R.isEmpty(this.state.company)) return alert("Nama perusahaan harus diisi.");
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.");
if (R.isEmpty(this.state.endDate)) return alert("Tanggal Berakhir is Required.");
let payload = {
"company_name": this.state.company,
"parent": this.state.getPerusahaan.company_id,
"business_unit_id": this.state.getTypes.business_unit_id,
"total_report": this.state.totalReport,
"start_date": this.state.startDate,
"end_date": this.state.endDate
}
console.log(payload);
this.props.createPerusahaan(payload)
}
render() {
return (
<div className="test app-popup-show" style={{ paddingTop: 100 }}>
<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="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
<div className="popup-title">
<span style={{ color: '#fff', fontSize: 16, fontWeight: 'bold' }}>Create Data</span>
</div>
</div>
<div className="col-2 content-right" style={{ maxWidth: "inherit", alignSelf: 'center' }}>
<button
type="button"
className="btn btn-circle btn-white"
onClick={() => this.props.onClickClose()}
>
<img src={Images.close}/>
</button>
</div>
</div>
<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 }}>
<Autocomplete
{...this.state.types}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getTypes: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Unit Bisnis" />}
value={this.state.getTypes}
/>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="report"
label="Jumlah Laporan"
value={this.state.totalReport}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
onChange={(e) => this.setState({ totalReport: e.target.value })}
>
</TextField>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="startDate"
label="Berlaku Mulai"
format="dd MMMM yyyy"
value={this.state.startDate == "" ? null : this.state.startDate}
onChange={(e) => this.handleChange(e, 'start_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5, backgroundColor: '#e8e8e8', }}>
<TextField
style={{ width: '100%' }}
defaultValue={"Aktif"}
id="status"
label="Status"
disabled
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
/>
</div>
<div className="margin-top-10px" style={{ padding: 10, borderRadius: 5 }}>
<Typography style={{ fontSize: 11 }}>Dibuat : </Typography>
<Typography style={{ fontSize: 11 }}>Diubah : </Typography>
</div>
</div>
<div className="column-2">
<div style={{ padding: 10, borderRadius: 5 }}>
<TextField
style={{ width: '100%' }}
id="perusahaan"
label="Nama Perusahaan"
value={this.state.company}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
onChange={(e) => this.setState({ company: e.target.value })}
>
</TextField>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<Autocomplete
{...this.state.perusahaan}
debug
id="tipe"
onChange={(event, newInputValue) => this.setState({ getPerusahaan: newInputValue })}
renderInput={(params) => <TextField {...params} InputProps={{ ...params.InputProps, style: { fontSize: 11 } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} label="Parent Company" />}
value={this.state.getPerusahaan}
/>
</div>
<div style={{ padding: 10, borderRadius: 5 }}>
<DatePicker
margin="normal"
id="endDate"
label="Berlaku Hingga"
format="dd MMMM yyyy"
minDate={this.state.startDate}
value={this.state.endDate == "" ? null : this.state.endDate}
onChange={(e) => this.handleChange(e, 'end_date')}
KeyboardButtonProps={{
'aria-label': 'change date',
}}
inputProps={{
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
style={{ padding: 0, margin: 0, width: '100%' }}
/>
</div>
</div>
</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 }}>Batal</span>
</div>
</button>
</div>
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={() => this.validasi()}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Simpan</span>
</div>
</button>
</div>
</div>
</div>
</div>
);
}
}
...@@ -285,6 +285,7 @@ export default class Perusahaan extends Component { ...@@ -285,6 +285,7 @@ export default class Perusahaan extends Component {
this.setState({ visibleEdit: false }) this.setState({ visibleEdit: false })
api.create().updatePerusahaan(payload).then(response => { api.create().updatePerusahaan(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
} else { } else {
alert(response.data.message) alert(response.data.message)
...@@ -296,6 +297,7 @@ export default class Perusahaan extends Component { ...@@ -296,6 +297,7 @@ export default class Perusahaan extends Component {
this.setState({ visibleCreate: false }) this.setState({ visibleCreate: false })
api.create().createPerusahaan(payload).then(response => { api.create().createPerusahaan(payload).then(response => {
if (response.data.status == 'success') { if (response.data.status == 'success') {
alert(response.data.message)
this.getData() this.getData()
} else { } else {
alert(response.data.message) alert(response.data.message)
...@@ -580,7 +582,7 @@ export default class Perusahaan extends Component { ...@@ -580,7 +582,7 @@ export default class Perusahaan extends Component {
)} )}
{this.state.visibleEdit && ( {this.state.visibleEdit && (
<EditPerusahaan <CreatePerusahaan
type={"edit"} type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })} onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]} data={this.state.listData[this.state.selectIndex]}
...@@ -588,6 +590,15 @@ export default class Perusahaan extends Component { ...@@ -588,6 +590,15 @@ export default class Perusahaan extends Component {
/> />
)} )}
{/* {this.state.visibleEdit && (
<EditPerusahaan
type={"edit"}
onClickClose={() => this.setState({ visibleEdit: false })}
data={this.state.listData[this.state.selectIndex]}
updatePerusahaan={this.updatePerusahaan.bind(this)}
/>
)} */}
{this.state.popupError && ( {this.state.popupError && (
<PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} /> <PopUpFailedSave onClickClose={() => this.setState({ popupError: false })} />
)} )}
......
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