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"; ...@@ -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")) {
...@@ -136,16 +134,16 @@ export default class getAllDocument extends Component { ...@@ -136,16 +134,16 @@ export default class getAllDocument extends Component {
} }
deleteDoc = (payload) => { deleteDoc = (payload) => {
this.setState({ popupDel: false }) this.setState({ popupDel: false, loading: true })
api.create().deleteDocument(payload).then(response => { api.create().deleteDocument(payload).then(response => {
console.log(response.data) console.log(response.data)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
this.getData() 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 { } 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)
...@@ -155,24 +153,25 @@ export default class getAllDocument extends Component { ...@@ -155,24 +153,25 @@ export default class getAllDocument 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 })
} }
}) })
} }
updateDocument(payload) { updateDocument(payload) {
this.setState({ loading: true })
api.create().updateDocument(payload).then(response => { api.create().updateDocument(payload).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.getData() 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 { } 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)
...@@ -182,10 +181,10 @@ export default class getAllDocument extends Component { ...@@ -182,10 +181,10 @@ export default class getAllDocument 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 })
} }
}) })
} }
...@@ -203,7 +202,6 @@ export default class getAllDocument extends Component { ...@@ -203,7 +202,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 +217,6 @@ export default class getAllDocument extends Component { ...@@ -219,7 +217,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
...@@ -257,7 +254,13 @@ export default class getAllDocument extends Component { ...@@ -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", name: "Period Month",
options: { options: {
...@@ -272,6 +275,18 @@ export default class getAllDocument extends Component { ...@@ -272,6 +275,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,9 +296,10 @@ export default class getAllDocument extends Component { ...@@ -281,9 +296,10 @@ 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()}
data={this.state.dataTable} data={this.state.dataTable}
columns={columns} columns={columns}
options={options} options={options}
......
...@@ -9,6 +9,7 @@ import { format } from 'date-fns'; ...@@ -9,6 +9,7 @@ import { format } from 'date-fns';
import UploadFile from "../../library/Upload"; import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer'; import { ExcelRenderer } from 'react-excel-renderer';
import * as R from 'ramda' import * as R from 'ramda'
import PropagateLoader from "react-spinners/PropagateLoader"
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -99,7 +100,7 @@ export default class CreateManagementDoc extends Component { ...@@ -99,7 +100,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 })
...@@ -305,6 +306,16 @@ export default class CreateManagementDoc extends Component { ...@@ -305,6 +306,16 @@ export default class CreateManagementDoc extends Component {
} }
render() { 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 ( return (
<div> <div>
<div className="test app-popup-show"> <div className="test app-popup-show">
...@@ -482,7 +493,13 @@ export default class CreateManagementDoc extends Component { ...@@ -482,7 +493,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 })
} }
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,6 +127,7 @@ export default class DocumentManagement extends Component { ...@@ -132,6 +127,7 @@ 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) {
...@@ -140,7 +136,7 @@ export default class DocumentManagement extends Component { ...@@ -140,7 +136,7 @@ export default class DocumentManagement extends Component {
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 })
} 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 })
} }
}) })
} }
......
...@@ -529,7 +529,13 @@ export default class EditManagementDoc extends Component { ...@@ -529,7 +529,13 @@ export default class EditManagementDoc 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>
......
...@@ -54,7 +54,13 @@ export default class PopUpDelete extends Component { ...@@ -54,7 +54,13 @@ export default class PopUpDelete 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.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' }}> <div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
<span style={{ color: '#fff', fontSize: 11 }}>Delete</span> <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