Commit 45cb862c authored by Deni Rinaldi's avatar Deni Rinaldi

yuhuuuu

parent 259d8c8a
...@@ -46,7 +46,7 @@ export default class AuditTahunan extends Component { ...@@ -46,7 +46,7 @@ export default class AuditTahunan extends Component {
item.company_name, item.company_name,
item.document_periode, item.document_periode,
item.document_type, item.document_type,
String(Number(item.document_size) / 1000 + ' MB'), String(Number(item.document_size) / 1000 + ' KB'),
item.created_by, item.created_by,
item.created_at, item.created_at,
] ]
......
...@@ -8,11 +8,6 @@ import { format } from 'date-fns'; ...@@ -8,11 +8,6 @@ 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 MuiAlert from '@material-ui/lab/Alert';
import PopUpKonfirmasi from "./PopUpKonfirmasi";
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class CreateManagementDoc extends Component { export default class CreateManagementDoc extends Component {
constructor(props) { constructor(props) {
...@@ -187,86 +182,9 @@ export default class CreateManagementDoc extends Component { ...@@ -187,86 +182,9 @@ export default class CreateManagementDoc extends Component {
formData.append("description", this.state.description); formData.append("description", this.state.description);
formData.append("extension", this.state.fileType); formData.append("extension", this.state.fileType);
this.setState({ formData }, ()=> { this.setState({ formData }, ()=> {
this.createDocument() this.props.createDocument(this.state.formData, this.props.setting_id)
})
}
}
createDocument(){
api.create().uploadDocument(this.state.formData).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?") {
let docId = response.data.data
this.setState({ docId })
this.setState({ konfirmasi: true })
// console.log(this.state.docId)
}
else if (response.data.message === "Upload Document Success") {
this.props.getDataDocument(this.props.setting_id)
this.props.onClickClose()
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
}) })
} }
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
createUploadDocument = (payload) => {
const docuID = Object.values(payload)
const formDatas = new FormData();
formDatas.append("file", this.state.file);
formDatas.append("companyId", this.state.getPerusahaan.company_id);
formDatas.append("settingId", this.state.getDocument.document_category_id);
formDatas.append("documentPeriode", this.state.periode.periode);
formDatas.append("description", this.state.description);
formDatas.append("extension", this.state.fileType);
formDatas.append("documentId", docuID[0]);
api.create().updateDocument(formDatas).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.props.getDataDocument(this.props.setting_id)
this.props.onClickClose()
this.setState({ konfirmasi: false })
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success' })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
closeAlert() {
this.setState({ alert: false })
} }
deleteFile(e){ deleteFile(e){
...@@ -277,11 +195,6 @@ export default class CreateManagementDoc extends Component { ...@@ -277,11 +195,6 @@ export default class CreateManagementDoc extends Component {
return ( return (
<div> <div>
<div className="test app-popup-show"> <div className="test app-popup-show">
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</Snackbar>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}> <div className="popup-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}> <div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
...@@ -429,15 +342,6 @@ export default class CreateManagementDoc extends Component { ...@@ -429,15 +342,6 @@ export default class CreateManagementDoc extends Component {
</div> </div>
</div> </div>
</div> </div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
data={this.state.docId}
// getList={() => this.getData.bind(this)}
// deleteAM={this.deleteAM.bind(this)}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
</div> </div>
) )
} }
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Tabs, Tab, Typography, Paper } from '@material-ui/core' import { Tabs, Tab, Typography, Paper, withStyles, Snackbar } from '@material-ui/core'
import ReactTooltip from 'react-tooltip' import ReactTooltip from 'react-tooltip'
import Images from '../../assets/Images' import Images from '../../assets/Images'
import ManualBookTia from './ManualBookTia' import ManualBookTia from './ManualBookTia'
...@@ -9,6 +9,12 @@ import CreateManagementDoc from './CreateManagementDoc' ...@@ -9,6 +9,12 @@ import CreateManagementDoc from './CreateManagementDoc'
import QReview from './QReview' import QReview from './QReview'
import BOD from './BOD' import BOD from './BOD'
import ManualBookETMS from './ManualBookETMS' import ManualBookETMS from './ManualBookETMS'
import PopUpKonfirmasi from "./PopUpKonfirmasi";
import Constant from '../../library/Constant'
import MuiAlert from '@material-ui/lab/Alert';
const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
export default class DocumentManagement extends Component { export default class DocumentManagement extends Component {
constructor(props) { constructor(props) {
...@@ -56,14 +62,95 @@ export default class DocumentManagement extends Component { ...@@ -56,14 +62,95 @@ export default class DocumentManagement extends Component {
}) })
} }
createDocument(payload, settingID) {
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 }, () => {
this.setState({ konfirmasi: true })
})
}
else if (response.data.message === "Upload Document Success") {
this.getDataDocument(settingID)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'success', settingID, visibleCreate: false })
}
else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
createUploadDocument() {
const formData = this.state.formData
formData.append("documentId", this.state.docId)
// const docuID = Object.values(payload)
// const formDatas = new FormData();
// formDatas.append("file", this.state.file);
// formDatas.append("companyId", this.state.getPerusahaan.company_id);
// formDatas.append("settingId", this.state.getDocument.document_category_id);
// formDatas.append("documentPeriode", this.state.periode.periode);
// formDatas.append("description", this.state.description);
// formDatas.append("extension", this.state.fileType);
// // formDatas.append("documentId", docuID[0]);
// console.log(payload);
api.create().updateDocument(formData).then(response => {
console.log(response)
if (response.data) {
if (response.ok) {
if (response.data.status === "success") {
this.getDataDocument(this.state.settingID)
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' }, () => {
if (response.data.message.includes("Someone Logged In")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error' })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error' })
}
})
}
getID(id) { getID(id) {
console.log(id); console.log(id);
this.setState({ id }) this.setState({ id })
} }
closeAlert() {
this.setState({ alert: false })
}
render() { render() {
return ( return (
<div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}> <div style={{ height: this.props.height, backgroundColor: '#f8f8f8' }}>
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert}
</Alert>
</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' }}>Management Document</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Management Document</Typography>
</div> </div>
...@@ -136,10 +223,19 @@ export default class DocumentManagement extends Component { ...@@ -136,10 +223,19 @@ export default class DocumentManagement extends Component {
</Paper> </Paper>
</div> </div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
// getList={() => this.getData.bind(this)}
// deleteAM={this.deleteAM.bind(this)}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateManagementDoc <CreateManagementDoc
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
getDataDocument={this.getDataDocument.bind(this)} // getDataDocument={this.getDataDocument.bind(this)}
createDocument={this.createDocument.bind(this)}
setting_id={this.state.id} setting_id={this.state.id}
/> />
)} )}
......
...@@ -15,10 +15,6 @@ export default class PopUpDeleteAM extends Component { ...@@ -15,10 +15,6 @@ export default class PopUpDeleteAM extends Component {
} }
componentDidMount() { componentDidMount() {
// if (this.props.type === 'delete') {
// this.getDetailAM()
// }
console.log(this.props.data)
} }
// getDetailAM() { // getDetailAM() {
...@@ -59,7 +55,7 @@ export default class PopUpDeleteAM extends Component { ...@@ -59,7 +55,7 @@ export default class PopUpDeleteAM extends Component {
render() { render() {
return ( return (
<div className="test app-popup-show"> <div className="test app-popup-show" style={{ zIndex: 2500}}>
<div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}> <div className="popup-content background-white border-radius" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}> <div style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<img src={Images.failed} /> <img src={Images.failed} />
......
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