Commit 22f5a09c authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

issue managdoc

parent 963725e6
...@@ -10,7 +10,6 @@ import PopUpDelete from "./PopUpDelete"; ...@@ -10,7 +10,6 @@ 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());
...@@ -34,6 +33,7 @@ export default class getAllDocument extends Component { ...@@ -34,6 +33,7 @@ export default class getAllDocument extends Component {
componentDidMount() { componentDidMount() {
this.getData() this.getData()
console.log(this.props.userCompActive)
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
...@@ -55,20 +55,26 @@ export default class getAllDocument extends Component { ...@@ -55,20 +55,26 @@ export default class getAllDocument extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let dataTable = response.data.data.map((item, index) => { let dataTable = []
return [ response.data.data.map((item, index) => {
index, let indexId = this.props.userCompActive.findIndex((val) => val == item.company_id)
item.document_name, console.log(indexId)
item.description, if (indexId !== -1) {
item.company_name, dataTable.push( [
item.document_month, index,
item.document_periode, item.document_name,
item.document_type, item.description,
String(Number(item.document_size) / 1000 + ' KB'), item.company_name,
item.created_by, item.document_month,
item.created_at, item.document_periode,
] item.document_type,
String(Number(item.document_size) / 1000 + ' KB'),
item.created_by,
item.created_at,
])
}
}) })
console.log(dataTable)
this.setState({ dataTable, loading: false }) this.setState({ dataTable, loading: false })
let docPath = response.data.data.map((item) => { let docPath = response.data.data.map((item) => {
return [ return [
...@@ -276,16 +282,7 @@ export default class getAllDocument extends Component { ...@@ -276,16 +282,7 @@ 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%' }}>
...@@ -296,7 +293,7 @@ export default class getAllDocument extends Component { ...@@ -296,7 +293,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()}
......
...@@ -494,11 +494,11 @@ export default class CreateManagementDoc extends Component { ...@@ -494,11 +494,11 @@ export default class CreateManagementDoc extends Component {
<button <button
type="button" type="button"
onClick={() => onClick={() =>
this.setState({ loading: true }, () => { // {this.props.handleLoading(1)
setTimeout(() => { setTimeout(() => {
this.validasi() this.validasi()
}, 100); }, 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' }}>
......
...@@ -13,6 +13,7 @@ import ManualBookETMS from './ManualBookETMS' ...@@ -13,6 +13,7 @@ import ManualBookETMS from './ManualBookETMS'
import PopUpKonfirmasi from "./PopUpKonfirmasi"; import PopUpKonfirmasi from "./PopUpKonfirmasi";
import Constant from '../../library/Constant' import Constant from '../../library/Constant'
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
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} />);
...@@ -28,7 +29,8 @@ export default class DocumentManagement extends Component { ...@@ -28,7 +29,8 @@ export default class DocumentManagement extends Component {
btnedit: false, btnedit: false,
btndelete: false, btndelete: false,
load: false, load: false,
name: '' name: '',
userCompActive: []
} }
} }
...@@ -65,6 +67,7 @@ export default class DocumentManagement extends Component { ...@@ -65,6 +67,7 @@ export default class DocumentManagement extends Component {
componentDidMount() { componentDidMount() {
this.getDataDocument() this.getDataDocument()
this.getPermission() this.getPermission()
this.getDetailUser()
} }
getDataDocument(id, name) { getDataDocument(id, name) {
...@@ -102,7 +105,7 @@ export default class DocumentManagement extends Component { ...@@ -102,7 +105,7 @@ export default class DocumentManagement extends Component {
} }
else if (response.data.message === "Data was Saved Successfully") { 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', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
...@@ -163,7 +166,77 @@ export default class DocumentManagement extends Component { ...@@ -163,7 +166,77 @@ export default class DocumentManagement extends Component {
this.setState({ alert: false }) this.setState({ alert: false })
} }
handleLoading(tipe) {
this.setState({ loading: tipe == 0 ? false : true })
}
getDetailUser() {
let userId = localStorage.getItem(Constant.USER)
api.create().getDetailUser(userId).then((response) => {
if (response.data) {
if (response.ok) {
if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, visibleTrue: false }, () => {
this.getCompanyActive()
})
}
}
}
})
}
getCompanyActive() {
api.create().getPerusahaanActive().then((response) => {
if (response.data) {
if (response.data.status === 'success') {
let data = response.data.data
let compActive = []
let userCompActive = []
this.state.userCompany.map((item, index) => {
let indeks = data.findIndex((val) => val.company_id == item)
if (indeks !== -1 && String(data[indeks].status).toLocaleLowerCase() == 'active'){
userCompActive.push(item)
}
})
data.map(( item, index ) => {
if (String(item.status).toLocaleLowerCase() == 'active') {
compActive.push(item)
}
})
if (compActive.length == userCompActive.length){
this.setState({ btnadd: true})
} else {
this.setState({ btnadd: false})
}
this.setState({ userCompActive, visibleTrue: true })
console.log(userCompActive)
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', visibleTrue: true }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', listCompany: null, company: null, visibleTrue: true })
}
})
}
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 style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}>
{/* {this.props.load && ()} */} {/* {this.props.load && ()} */}
...@@ -172,13 +245,15 @@ export default class DocumentManagement extends Component { ...@@ -172,13 +245,15 @@ export default class DocumentManagement extends Component {
{this.state.messageAlert} {this.state.messageAlert}
</Alert> </Alert>
</Snackbar> </Snackbar>
<div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}> <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
{this.state.loading && loadingComponent}
<Paper style={{ padding: 20 }}> <Paper style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{this.state.btncreate && <span> {(this.state.btncreate && this.state.btnadd) && <span>
<a data-tip={'Add'} data-for="add"> <a data-tip={'Add'} data-for="add">
<div style={{ display: 'grid', justifyContent: 'flex-end' }}> <div style={{ display: 'grid', justifyContent: 'flex-end' }}>
<button <button
...@@ -211,7 +286,7 @@ export default class DocumentManagement extends Component { ...@@ -211,7 +286,7 @@ export default class DocumentManagement extends Component {
) )
})} })}
</Tabs> </Tabs>
{this.state.loadTable && ( {this.state.loadTable && this.state.visibleTrue && (
<AllDocument <AllDocument
data={this.state.listData[this.state.tab]} data={this.state.listData[this.state.tab]}
refresh={this.state.refresh} refresh={this.state.refresh}
...@@ -219,6 +294,7 @@ export default class DocumentManagement extends Component { ...@@ -219,6 +294,7 @@ export default class DocumentManagement extends Component {
btndelete={this.state.btndelete} btndelete={this.state.btndelete}
load={this.state.load} load={this.state.load}
setId={this.state.id} setId={this.state.id}
userCompActive={this.state.userCompActive}
/> />
// this.state.id === 68542 ? // this.state.id === 68542 ?
// <AuditTahunan // <AuditTahunan
...@@ -282,6 +358,7 @@ export default class DocumentManagement extends Component { ...@@ -282,6 +358,7 @@ export default class DocumentManagement extends Component {
createDocument={this.createDocument.bind(this)} createDocument={this.createDocument.bind(this)}
setting_id={this.state.id} setting_id={this.state.id}
name={this.state.name} name={this.state.name}
handleLoading={this.handleLoading.bind(this)}
/> />
)} )}
</div> </div>
......
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