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

issue managdoc

parent 963725e6
......@@ -10,7 +10,6 @@ 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());
......@@ -34,6 +33,7 @@ export default class getAllDocument extends Component {
componentDidMount() {
this.getData()
console.log(this.props.userCompActive)
}
componentWillReceiveProps(props) {
......@@ -55,8 +55,12 @@ export default class getAllDocument extends Component {
if (response.data) {
if (response.ok) {
if (response.data.status == 'success') {
let dataTable = response.data.data.map((item, index) => {
return [
let dataTable = []
response.data.data.map((item, index) => {
let indexId = this.props.userCompActive.findIndex((val) => val == item.company_id)
console.log(indexId)
if (indexId !== -1) {
dataTable.push( [
index,
item.document_name,
item.description,
......@@ -67,8 +71,10 @@ export default class getAllDocument extends Component {
String(Number(item.document_size) / 1000 + ' KB'),
item.created_by,
item.created_at,
]
])
}
})
console.log(dataTable)
this.setState({ dataTable, loading: false })
let docPath = response.data.data.map((item) => {
return [
......@@ -276,16 +282,7 @@ 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%' }}>
......@@ -296,7 +293,7 @@ export default class getAllDocument extends Component {
{this.state.messageAlert}
</Alert>
</Snackbar>
{this.state.loading && loadingComponent}
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
// theme={getMuiTheme()}
......
......@@ -494,11 +494,11 @@ export default class CreateManagementDoc extends Component {
<button
type="button"
onClick={() =>
this.setState({ loading: true }, () => {
// {this.props.handleLoading(1)
setTimeout(() => {
this.validasi()
}, 100);
})
}, 100)
// }
}
>
<div style={{ width: 102, height: 30, backgroundColor: '#354960', borderRadius: 5, alignItems: 'center', display: 'flex', justifyContent: 'center' }}>
......
......@@ -13,6 +13,7 @@ import ManualBookETMS from './ManualBookETMS'
import PopUpKonfirmasi from "./PopUpKonfirmasi";
import Constant from '../../library/Constant'
import MuiAlert from '@material-ui/lab/Alert';
import PropagateLoader from "react-spinners/PropagateLoader"
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
......@@ -28,7 +29,8 @@ export default class DocumentManagement extends Component {
btnedit: false,
btndelete: false,
load: false,
name: ''
name: '',
userCompActive: []
}
}
......@@ -65,6 +67,7 @@ export default class DocumentManagement extends Component {
componentDidMount() {
this.getDataDocument()
this.getPermission()
this.getDetailUser()
}
getDataDocument(id, name) {
......@@ -102,7 +105,7 @@ export default class DocumentManagement extends Component {
}
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 })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', settingID, menuName, visibleCreate: false, loading: false})
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
......@@ -163,7 +166,77 @@ export default class DocumentManagement extends Component {
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() {
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={{ height: this.props.height, backgroundColor: '#f8f8f8' }}>
{/* {this.props.load && ()} */}
......@@ -172,13 +245,15 @@ export default class DocumentManagement extends Component {
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography>
</div>
<div style={{ padding: 20 }}>
{this.state.loading && loadingComponent}
<Paper style={{ padding: 20 }}>
<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">
<div style={{ display: 'grid', justifyContent: 'flex-end' }}>
<button
......@@ -211,7 +286,7 @@ export default class DocumentManagement extends Component {
)
})}
</Tabs>
{this.state.loadTable && (
{this.state.loadTable && this.state.visibleTrue && (
<AllDocument
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
......@@ -219,6 +294,7 @@ export default class DocumentManagement extends Component {
btndelete={this.state.btndelete}
load={this.state.load}
setId={this.state.id}
userCompActive={this.state.userCompActive}
/>
// this.state.id === 68542 ?
// <AuditTahunan
......@@ -282,6 +358,7 @@ export default class DocumentManagement extends Component {
createDocument={this.createDocument.bind(this)}
setting_id={this.state.id}
name={this.state.name}
handleLoading={this.handleLoading.bind(this)}
/>
)}
</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