Commit 0f02fd51 authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

Merge branch 'master' of http://103.44.149.204/d.arizona/tia-dev into rifka

parents e7bd862a bd7e13f7
......@@ -49,7 +49,7 @@ export default class AuditTahunan extends Component {
item.company_name,
item.document_periode,
item.document_type,
String(Number(item.document_size) / 1000 + ' MB'),
String(Number(item.document_size) / 1000 + ' KB'),
item.created_by,
item.created_at,
]
......
......@@ -8,11 +8,6 @@ import { format } from 'date-fns';
import UploadFile from "../../library/Upload";
import { ExcelRenderer } from 'react-excel-renderer';
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 {
constructor(props) {
......@@ -187,88 +182,11 @@ export default class CreateManagementDoc extends Component {
formData.append("description", this.state.description);
formData.append("extension", this.state.fileType);
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){
this.setState({ file: null})
}
......@@ -277,11 +195,6 @@ export default class CreateManagementDoc extends Component {
return (
<div>
<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-panel grid grid-2x main-color" style={{ height: 64, borderTopRightRadius: 8, borderTopLeftRadius: 8 }}>
<div className="col-1" style={{ maxWidth: "inherit", display: 'flex', alignItems: 'center' }}>
......@@ -429,15 +342,6 @@ export default class CreateManagementDoc extends Component {
</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>
)
}
......
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 Images from '../../assets/Images'
import ManualBookTia from './ManualBookTia'
......@@ -9,6 +9,12 @@ import CreateManagementDoc from './CreateManagementDoc'
import QReview from './QReview'
import BOD from './BOD'
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 {
constructor(props) {
......@@ -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) {
console.log(id);
this.setState({ id })
}
closeAlert() {
this.setState({ alert: false })
}
render() {
return (
<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 }}>
<Typography style={{ fontSize: '16px', color: 'white' }}>Management Document</Typography>
</div>
......@@ -104,42 +191,51 @@ export default class DocumentManagement extends Component {
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68541 ?
<ManualBookTia
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68544 ?
<QReview
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68543 ?
<BOD
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68545 ?
<ManualBookETMS
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
<span>Test2</span>
:
this.state.id === 68541 ?
<ManualBookTia
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68544 ?
<QReview
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68543 ?
<BOD
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
this.state.id === 68545 ?
<ManualBookETMS
data={this.state.listData[this.state.tab]}
refresh={this.state.refresh}
/>
:
<span>Test2</span>
)}
</div>
</Paper>
</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 && (
<CreateManagementDoc
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}
/>
)}
......
......@@ -15,10 +15,6 @@ export default class PopUpDeleteAM extends Component {
}
componentDidMount() {
// if (this.props.type === 'delete') {
// this.getDetailAM()
// }
console.log(this.props.data)
}
onClickUpload() {
let payload = this.props.data
......@@ -27,7 +23,7 @@ export default class PopUpDeleteAM extends Component {
render() {
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 style={{ display: 'flex', justifyContent: 'center', paddingTop: 20 }}>
<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