Commit 43fc86b5 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

taxplan dan managdoc

parent 04c368bd
...@@ -723,9 +723,10 @@ export default class TaxPlanning extends Component { ...@@ -723,9 +723,10 @@ export default class TaxPlanning extends Component {
async downloadAllData() { async downloadAllData() {
let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}` let url = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
let sub_null = `https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}`
console.log(url); console.log(url);
let res = await fetch( let res = await fetch(
`https://tia.eksad.com/tia-reporting-dev/public/transaction/master_budget/export_master_budget?submission_id=${this.props.submissionID}&&report_id=${this.props.report_id}&&company_id=${this.props.company.company_id}&&year=${this.props.periode}&&revision=${this.props.revision}` this.props.submissionID == null ? sub_null : url
) )
res = await res.blob() res = await res.blob()
this.setState({ loading: false }) this.setState({ loading: false })
......
...@@ -10,7 +10,7 @@ import PopUpDelete from "./PopUpDelete"; ...@@ -10,7 +10,7 @@ import PopUpDelete from "./PopUpDelete";
import api from '../../api'; import api from '../../api';
import CreateManagementDoc from './CreateManagementDoc'; import CreateManagementDoc from './CreateManagementDoc';
import EditManagementDoc from './EditManagementDoc'; import EditManagementDoc from './EditManagementDoc';
import PropagateLoader from "react-spinners/PropagateLoader"
var ct = require("../../library/CustomTable"); var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable()); const getMuiTheme = () => createMuiTheme(ct.customTable());
...@@ -33,8 +33,6 @@ export default class getAllDocument extends Component { ...@@ -33,8 +33,6 @@ export default class getAllDocument extends Component {
} }
componentDidMount() { componentDidMount() {
console.log(this.props.data)
console.log(this.props.setId)
this.getData() this.getData()
} }
...@@ -51,7 +49,7 @@ export default class getAllDocument extends Component { ...@@ -51,7 +49,7 @@ export default class getAllDocument extends Component {
let payload = { let payload = {
"setting_id": this.props.data.setting_id "setting_id": this.props.data.setting_id
} }
this.setState({ loading: true })
api.create().getAllDocument(payload).then(response => { api.create().getAllDocument(payload).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
...@@ -71,19 +69,19 @@ export default class getAllDocument extends Component { ...@@ -71,19 +69,19 @@ export default class getAllDocument extends Component {
item.created_at, item.created_at,
] ]
}) })
this.setState({ dataTable }) this.setState({ dataTable, loading: false })
let docPath = response.data.data.map((item) => { let docPath = response.data.data.map((item) => {
return [ return [
item.document_filepath item.document_filepath
] ]
}) })
this.setState({ docPath }) this.setState({ docPath, loading: false })
let docId = response.data.data.map((item) => { let docId = response.data.data.map((item) => {
return [ return [
item.document_id item.document_id
] ]
}) })
this.setState({ docId }) this.setState({ docId, loading: false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
...@@ -203,7 +201,6 @@ export default class getAllDocument extends Component { ...@@ -203,7 +201,6 @@ export default class getAllDocument extends Component {
customBodyRender: (val, tableMeta) => { customBodyRender: (val, tableMeta) => {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
{/* {this.state.btnedit && <span> */}
<a data-tip={'Download'} data-for="download"> <a data-tip={'Download'} data-for="download">
<button <button
style={{ style={{
...@@ -219,7 +216,6 @@ export default class getAllDocument extends Component { ...@@ -219,7 +216,6 @@ export default class getAllDocument extends Component {
</button> </button>
</a> </a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" /> <ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{/* </span>} */}
{this.props.btnedit && <span> {this.props.btnedit && <span>
<a data-tip={'Edit'} data-for="edit"> <a data-tip={'Edit'} data-for="edit">
<button <button
...@@ -272,6 +268,18 @@ export default class getAllDocument extends Component { ...@@ -272,6 +268,18 @@ export default class getAllDocument extends Component {
}, },
"Type", "File Size", "Created By", "Created Date" "Type", "File Size", "Created By", "Created Date"
] ]
const loadingComponent = (
<div style={{ position: 'absolute', zIndex: 110, top: 0, left: 0, width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', background: 'rgba(255,255,255,0.8)' }}>
<PropagateLoader
// css={override}
size={20}
color={"#274B80"}
loading={this.state.loading}
/>
</div>
);
return ( return (
<div style={{ width: '100%' }}> <div style={{ width: '100%' }}>
{this.props.load && ( {this.props.load && (
...@@ -281,6 +289,7 @@ export default class getAllDocument extends Component { ...@@ -281,6 +289,7 @@ export default class getAllDocument extends Component {
{this.state.messageAlert} {this.state.messageAlert}
</Alert> </Alert>
</Snackbar> </Snackbar>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}> <MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable <MUIDataTable
theme={getMuiTheme()} theme={getMuiTheme()}
......
...@@ -99,7 +99,7 @@ export default class CreateManagementDoc extends Component { ...@@ -99,7 +99,7 @@ export default class CreateManagementDoc extends Component {
// company_name: 'Default' // company_name: 'Default'
// }) // })
let typeProps = { let typeProps = {
options: typeData.sort((a, b) => a.company_id - b.company_id), options: typeData.sort((a, b) => a.company_name - b.company_name),
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 })
...@@ -482,7 +482,13 @@ export default class CreateManagementDoc extends Component { ...@@ -482,7 +482,13 @@ export default class CreateManagementDoc extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> <div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button <button
type="button" type="button"
onClick={() => this.validasi()} onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.validasi()
}, 100);
})
}
> >
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span> <span style={{ color: '#fff', fontSize: 11 }}>Save</span>
......
...@@ -68,12 +68,6 @@ export default class DocumentManagement extends Component { ...@@ -68,12 +68,6 @@ export default class DocumentManagement extends Component {
} }
getDataDocument(id, name) { getDataDocument(id, name) {
// let payload = {
// "setting_group_id": 7,
// "setting_type_id": 167,
// "company_id": 0
// }
api.create().getDocumentCategory().then(response => { api.create().getDocumentCategory().then(response => {
console.log(response); console.log(response);
if (response) { if (response) {
...@@ -96,21 +90,22 @@ export default class DocumentManagement extends Component { ...@@ -96,21 +90,22 @@ export default class DocumentManagement extends Component {
} }
createDocument(payload, settingID, menuName) { createDocument(payload, settingID, menuName) {
this.setState({ loading: true })
api.create().uploadDocument(payload).then(response => { api.create().uploadDocument(payload).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.message === "The Document Already Exists in The System, Do You Want to Overwrite It?") { if (response.data.message === "The Document Already Exists in The System, Do You Want to Overwrite It?") {
this.setState({ formData: payload, docId: response.data.data.document_id, settingID, menuName }, () => { this.setState({ formData: payload, docId: response.data.data.document_id, settingID, menuName, loading: false }, () => {
this.setState({ konfirmasi: true }) this.setState({ konfirmasi: true })
}) })
} }
else if (response.data.message === "Upload Document Success") { else if (response.data.message === "Data was Saved Successfully") {
this.getDataDocument(settingID, menuName) this.getDataDocument(settingID, menuName)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', settingID, menuName, visibleCreate: false }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', settingID, menuName, visibleCreate: false, loading: false })
} }
else { else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
...@@ -120,10 +115,10 @@ export default class DocumentManagement extends Component { ...@@ -120,10 +115,10 @@ export default class DocumentManagement extends Component {
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
} }
}) })
} }
...@@ -132,15 +127,16 @@ export default class DocumentManagement extends Component { ...@@ -132,15 +127,16 @@ export default class DocumentManagement extends Component {
const formData = this.state.formData const formData = this.state.formData
formData.append("documentId", this.state.docId) formData.append("documentId", this.state.docId)
formData.append("updated", 1) formData.append("updated", 1)
this.setState({ loading: true })
api.create().updateDocument(formData).then(response => { api.create().updateDocument(formData).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.getDataDocument(this.state.settingID, this.state.menuName) this.getDataDocument(this.state.settingID, this.state.menuName)
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleCreate: false }) this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleCreate: false, loading: false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) { if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => { setTimeout(() => {
localStorage.removeItem(Constant.TOKEN) localStorage.removeItem(Constant.TOKEN)
...@@ -150,10 +146,10 @@ export default class DocumentManagement extends Component { ...@@ -150,10 +146,10 @@ export default class DocumentManagement extends Component {
}) })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
} }
} else { } else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' }) this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: 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