Commit c888d956 authored by ardiansyah's avatar ardiansyah

Merge branch 'ENV-DEV' into 'ENV-STAGING'

Env dev

See merge request !1918
parents ab2964a2 f07c1b0f
......@@ -48,7 +48,6 @@ class Login extends Component {
componentDidMount() {
this.getUser()
var email = localStorage.getItem(Constant.EMAIL)
console.log(email)
}
getWindowDimensions() {
......@@ -112,6 +111,7 @@ class Login extends Component {
} else {
localStorage.setItem(Constant.TOKEN, datas.token)
localStorage.setItem(Constant.USER, datas.user_id)
localStorage.setItem(Constant.ROLE, datas.role_id)
if (this.state.rememberMe) {
localStorage.setItem(Constant.EMAIL, this.state.email)
localStorage.setItem(Constant.PASSWORD, this.state.password)
......
This diff is collapsed.
......@@ -65,7 +65,8 @@ export default class ProfitLoss extends Component {
handleDoubleClick: 0,
fromUpload: false,
defaultCurrencyUpload: this.props.defaultCurrency,
visibleAlertSave: false
visibleAlertSave: false,
visibleButtonUpload: false
}
this.handleValue = this.handleValue.bind(this)
this.fileHandler = this.fileHandler.bind(this);
......@@ -475,27 +476,105 @@ export default class ProfitLoss extends Component {
})
}
uploadSimulasi() {
checkUploadSimulasi() {
let payload = {
...this.state.payload,
currency_id: this.state.defaultCurrencyUpload?.id
}
this.setState({ loading: true, dataTable: [] })
// let dataDelete = this.state.dataDelete
// api.create().getIdDeleteFromExcel(payload).then((response) => {
// if (response.data) {
// // // // // // console.log(response.data)
// let idDelete = response.data.data.item_report_id
// if (idDelete.length > 0) {
// idDelete.map((item, index) => {
// dataDelete.push(item)
// })
// this.setState({ dataDelete })
// }
// }
// })
console.log(payload)
api.create().uploadSimulasiMB(payload).then(response => {
api.create().checkUploadMB(payload).then(response => {
// console.log(JSON.stringify(this.state.payload));
console.log(response)
if (response.data) {
if (response.data.status === 'success') {
this.setState({ visibleUpload: false, visibleProfitLoss: false, loading: true, visibleButtonUpload: true })
let dataTable = response.data.data.map((item, index) => {
return [
item.type_report_id,
item.item_report_id,
item.parent,
item.formula,
item.level,
item.item_report,
item.notes,
Number(item.total_actual_before).toFixed(1),
Number(item.january).toFixed(1),
Number(item.february).toFixed(1),
Number(item.march).toFixed(1),
Number(item.april).toFixed(1),
Number(item.may).toFixed(1),
Number(item.june).toFixed(1),
Number(item.july).toFixed(1),
Number(item.august).toFixed(1),
Number(item.september).toFixed(1),
Number(item.october).toFixed(1),
Number(item.november).toFixed(1),
Number(item.december).toFixed(1),
Number(item.total_current_year).toFixed(1),
Number(item.total_next_year).toFixed(1),
Number(item.total_more_year).toFixed(1),
item.orders,
item.error
]
})
this.setState({ dataTable, dataLoaded: true, loading: false, buttonError: false, editable: true, fromUpload: true }, () => {
this.state.dataTable.map(item => {
if (item[24].length > 0) {
// console.log('masuk')
this.setState({ buttonError: true, errorPreview: true, editable: true })
}
})
// console.log(this.state.buttonError)
})
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
}
})
}
uploadSimulasi(type) {
let data = []
this.state.dataTable.map(i => {
data.push({
item_report_id: i[1],
notes: String(i[6]),
total_actual_before: String(Number(i[7]).toFixed(1)),
january: String(Number(i[8]).toFixed(1)),
february: String(Number(i[9]).toFixed(1)),
march: String(Number(i[10]).toFixed(1)),
april: String(Number(i[11]).toFixed(1)),
may: String(Number(i[12]).toFixed(1)),
june: String(Number(i[13]).toFixed(1)),
july: String(Number(i[14]).toFixed(1)),
august: String(Number(i[15]).toFixed(1)),
september: String(Number(i[16]).toFixed(1)),
october: String(Number(i[17]).toFixed(1)),
november: String(Number(i[18]).toFixed(1)),
december: String(Number(i[19]).toFixed(1)),
total_current_year: String(Number(i[20]).toFixed(1)),
total_next_year: String(Number(i[21]).toFixed(1)),
total_more_year: String(Number(i[22]).toFixed(1)),
})
})
let body = {
submission_id: this.props.submissionID,
company_id: this.props.company.company_id,
periode: this.props.periode,
report_id: this.props.report_id,
currency_id: this.state.defaultCurrencyUpload?.id,
profit_loss: data,
status: type
}
console.log(body)
api.create().uploadSimulasiMB(body).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
......@@ -3419,13 +3498,37 @@ export default class ProfitLoss extends Component {
}}
onUpload={() => {
String(this.state.judul).includes("MASTER") && String(this.state.judul).includes("BUDGET") && String(this.state.judul).includes("PROFIT") && String(this.state.judul).includes("LOSS") ?
this.uploadSimulasi() :
this.checkUploadSimulasi() :
this.setState({ alert: true, messageAlert: "Invalid Template", tipeAlert: 'warning' })
}}
/>
</div>
<div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div>
{this.state.visibleButtonUpload &&
<div style={{ display: 'flex', justifyContent: 'flex-end', margin: '0px 32px 16px' }}>
<div>
<button
type="button"
// disabled={this.state.buttonError}
onClick={() =>
this.setState({ handleDoubleClick: 1, loading: true }, () => {
this.uploadSimulasi('submitted')
})}
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
outline: 'none',
}}
>
<div style={{ backgroundColor: '#354960', width: 105, height: 25, borderRadius: 3, justifyContent: 'center', display: 'flex', alignItems: 'center' }}>
<Typography style={{ fontSize: '11px', color: '#fff', textAlign: 'center' }}>Save Data</Typography>
</div>
</button>
</div>
</div>
}
{/* <div style={{ padding: '0px 30px 29px', fontSize: 17, color: 'red' }}><b>Warning:</b> Valid currency for uploading data is <b>{this.props.defaultCurrency.id == 1 ? "IDR" : "USD"}</b></div> */}
</div>
</div>
)}
......
This diff is collapsed.
......@@ -96,7 +96,7 @@ export default class CashFlowMR extends Component {
componentDidMount() {
// this.getItemHierarki()
console.log(this.props.PLBSFAMSubmitted)
this.handleViewOnly()
// this.handleViewOnly()
this.getSettingControl()
}
......
This diff is collapsed.
const Constant = {
TOKEN: null,
USER: 0,
ROLE: 'role_id',
EMAIL: 'TOKEN',
PASSWORD: 'PASSWORD',
URL_BE_DEV: '${process.env.REACT_APP_URL_MAIN_BE}',
......
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