Commit ebd6bdc4 authored by Dida Adams Arizona's avatar Dida Adams Arizona

Merge branch 'rifka' into 'master'

taxplan managdoc

See merge request !430
parents 05a0c2a1 672e1044
This diff is collapsed.
......@@ -10,7 +10,7 @@ import PopUpDelete from "./PopUpDelete";
import api from '../../api';
import CreateManagementDoc from './CreateManagementDoc';
import EditManagementDoc from './EditManagementDoc';
import PropagateLoader from "react-spinners/PropagateLoader"
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
......@@ -33,8 +33,6 @@ export default class getAllDocument extends Component {
}
componentDidMount() {
console.log(this.props.data)
console.log(this.props.setId)
this.getData()
}
......@@ -51,7 +49,7 @@ export default class getAllDocument extends Component {
let payload = {
"setting_id": this.props.data.setting_id
}
this.setState({ loading: true })
api.create().getAllDocument(payload).then(response => {
console.log(response)
if (response.data) {
......@@ -71,19 +69,19 @@ export default class getAllDocument extends Component {
item.created_at,
]
})
this.setState({ dataTable })
this.setState({ dataTable, loading: false })
let docPath = response.data.data.map((item) => {
return [
item.document_filepath
]
})
this.setState({ docPath })
this.setState({ docPath, loading: false })
let docId = response.data.data.map((item) => {
return [
item.document_id
]
})
this.setState({ docId })
this.setState({ docId, loading: false })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In")) {
......@@ -136,16 +134,16 @@ export default class getAllDocument extends Component {
}
deleteDoc = (payload) => {
this.setState({ popupDel: false })
this.setState({ popupDel: false, loading: true })
api.create().deleteDocument(payload).then(response => {
console.log(response.data)
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
this.getData()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', loading: false })
} 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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
......@@ -155,24 +153,25 @@ export default class getAllDocument extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
updateDocument(payload) {
this.setState({ loading: true })
api.create().updateDocument(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getData()
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleEdit: false })
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleEdit: false, loading: false })
} 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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
......@@ -182,10 +181,10 @@ export default class getAllDocument extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
......@@ -203,7 +202,6 @@ export default class getAllDocument extends Component {
customBodyRender: (val, tableMeta) => {
return (
<div style={{ display: 'flex' }}>
{/* {this.state.btnedit && <span> */}
<a data-tip={'Download'} data-for="download">
<button
style={{
......@@ -219,7 +217,6 @@ export default class getAllDocument extends Component {
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{/* </span>} */}
{this.props.btnedit && <span>
<a data-tip={'Edit'} data-for="edit">
<button
......@@ -257,7 +254,13 @@ export default class getAllDocument extends Component {
);
}
}
}, "File Name", "Description", "Company Name",
}, "File Name", "Description",
{
name: "Company Name",
options: {
display: String(this.props.data.value).includes('Manual Book TIA') ? false : true
}
},
{
name: "Period Month",
options: {
......@@ -272,6 +275,18 @@ export default class getAllDocument extends Component {
},
"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 (
<div style={{ width: '100%' }}>
{this.props.load && (
......@@ -281,9 +296,10 @@ export default class getAllDocument extends Component {
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
// theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns}
options={options}
......
......@@ -9,6 +9,7 @@ import { format } from 'date-fns';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda'
import PropagateLoader from "react-spinners/PropagateLoader"
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
......@@ -99,7 +100,7 @@ export default class CreateManagementDoc extends Component {
// company_name: 'Default'
// })
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,
};
this.setState({ perusahaan: typeProps, perusahaanData: response.data.data })
......@@ -305,6 +306,16 @@ export default class CreateManagementDoc extends Component {
}
render() {
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 (
<div>
<div className="test app-popup-show">
......@@ -482,7 +493,13 @@ export default class CreateManagementDoc extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<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' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
......
......@@ -68,12 +68,6 @@ export default class DocumentManagement extends Component {
}
getDataDocument(id, name) {
// let payload = {
// "setting_group_id": 7,
// "setting_type_id": 167,
// "company_id": 0
// }
api.create().getDocumentCategory().then(response => {
console.log(response);
if (response) {
......@@ -96,21 +90,22 @@ export default class DocumentManagement extends Component {
}
createDocument(payload, settingID, menuName) {
this.setState({ loading: true })
api.create().uploadDocument(payload).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
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 })
})
}
else if (response.data.message === "Upload Document Success") {
else if (response.data.message === "Data was Saved Successfully") {
this.getDataDocument(settingID, menuName)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', settingID, menuName, visibleCreate: false })
}
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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
......@@ -120,10 +115,10 @@ export default class DocumentManagement extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
......@@ -132,6 +127,7 @@ export default class DocumentManagement extends Component {
const formData = this.state.formData
formData.append("documentId", this.state.docId)
formData.append("updated", 1)
this.setState({ loading: true })
api.create().updateDocument(formData).then(response => {
console.log(response)
if (response.data) {
......@@ -140,7 +136,7 @@ export default class DocumentManagement extends Component {
this.getDataDocument(this.state.settingID, this.state.menuName)
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleCreate: false })
} 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")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
......@@ -150,10 +146,10 @@ export default class DocumentManagement extends Component {
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
......
......@@ -529,7 +529,13 @@ export default class EditManagementDoc extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<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' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Save</span>
......
......@@ -54,7 +54,13 @@ export default class PopUpDelete extends Component {
<div className="column-2" style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}>
<button
type="button"
onClick={()=> this.onClickDelete()}
onClick={() =>
this.setState({ loading: true }, () => {
setTimeout(() => {
this.onClickDelete()
}, 100);
})
}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span>
......
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