Commit cfc267f6 authored by muhammad ridwan's avatar muhammad ridwan

removed upload / update

parent 890db147
...@@ -8,7 +8,6 @@ import ReactTooltip from 'react-tooltip'; ...@@ -8,7 +8,6 @@ import ReactTooltip from 'react-tooltip';
import api from '../../api'; import api from '../../api';
import PropagateLoader from "react-spinners/PropagateLoader" import PropagateLoader from "react-spinners/PropagateLoader"
import TableDocument from "./TableDocument"; import TableDocument from "./TableDocument";
import PopUpKonfirmasi from "../DocumentManagement/PopUpKonfirmasi";
import CreateCarfmDoc from "./CreateCarfmDoc"; import CreateCarfmDoc from "./CreateCarfmDoc";
const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -198,48 +197,13 @@ export default class CarfmDocument extends Component { ...@@ -198,48 +197,13 @@ export default class CarfmDocument extends Component {
}) })
} }
async createUploadDocument() {
this.setState({ visibleCreate: false, konfirmasi: false })
const formData = this.state.formData
formData.append("documentId", this.state.docId)
formData.append("updated", 1)
this.setState({ loading: true })
await 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.state.menuName)
this.setState({ konfirmasi: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success', visibleCreate: false, loading: false })
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
setTimeout(() => {
localStorage.removeItem(Constant.TOKEN)
window.location.reload();
}, 1000);
}
})
}
} else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'error', loading: false })
}
} else {
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}
})
}
async createDocument(payload) { //upload apinya disini async createDocument(payload) { //upload apinya disini
this.setState({ loading: true }) this.setState({ loading: true })
await api.create().uploadCarfmDocument(payload).then(response => { await api.create().uploadCarfmDocument(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 === "Data was Saved Successfully") {
this.setState({ konfirmasi: true, formData: payload, docId: response.data.data.document_id, loading: false })
}
else if (response.data.message === "Data was Saved Successfully") {
this.getDataCarfm('create') this.getDataCarfm('create')
this.setState({ visibleCreate: false, loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success'}) this.setState({ visibleCreate: false, loading: false, alert: true, messageAlert: response.data.message, tipeAlert: 'success'})
} }
...@@ -359,12 +323,6 @@ export default class CarfmDocument extends Component { ...@@ -359,12 +323,6 @@ export default class CarfmDocument extends Component {
)} )}
</div> </div>
{this.state.konfirmasi && (
<PopUpKonfirmasi
onClickClosePopUp={() => this.setState({ konfirmasi: false })}
uploadDocId={this.createUploadDocument.bind(this)}
/>
)}
{this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateCarfmDoc <CreateCarfmDoc
onClickClose={() => this.setState({ visibleCreate: false })} onClickClose={() => this.setState({ visibleCreate: false })}
......
...@@ -44,7 +44,6 @@ export default class CreateCarfmDoc extends Component { ...@@ -44,7 +44,6 @@ export default class CreateCarfmDoc extends Component {
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
fileType: '', fileType: '',
konfirmasi: false,
docId: '', docId: '',
sizeUpload: "1", sizeUpload: "1",
disabledPeriode: false, disabledPeriode: false,
......
...@@ -44,7 +44,6 @@ export default class CreateManagementDoc extends Component { ...@@ -44,7 +44,6 @@ export default class CreateManagementDoc extends Component {
tipeAlert: '', tipeAlert: '',
messageAlert: '', messageAlert: '',
fileType: '', fileType: '',
konfirmasi: false,
docId: '', docId: '',
sizeUpload: "1", sizeUpload: "1",
disabledPeriode: false disabledPeriode: false
......
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