Commit e0eb4e0d authored by Rifka Kurnia Irfiana's avatar Rifka Kurnia Irfiana

upload all extension

parent c63d30d4
...@@ -56,7 +56,6 @@ export default class CreateManagementDoc extends Component { ...@@ -56,7 +56,6 @@ export default class CreateManagementDoc extends Component {
this.getPeriode() this.getPeriode()
this.getMonth() this.getMonth()
this.getFileSize() this.getFileSize()
console.log(this.props.name)
} }
getFileSize() { getFileSize() {
...@@ -79,7 +78,6 @@ export default class CreateManagementDoc extends Component { ...@@ -79,7 +78,6 @@ export default class CreateManagementDoc extends Component {
}) })
} }
// sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1" // sizeUpload: response.data.data[0] ? response.data.data[0].value === undefined ? "1" : response.data.data[0].value : "1"
console.log(this.state.sizeUpload)
} }
} }
}) })
...@@ -223,13 +221,11 @@ export default class CreateManagementDoc extends Component { ...@@ -223,13 +221,11 @@ export default class CreateManagementDoc extends Component {
} }
fileHandler = (event) => { fileHandler = (event) => {
console.log(event)
// console.log(event)
let fileObj = event let fileObj = event
let length = event.name.split(".").length let length = event.name.split(".").length
let fileType = event.name.split(".")[length - 1] let fileType = event.name.split(".")[length - 1]
console.log(fileType) // console.log(fileType)
if (fileType === 'zip') { if (fileType === 'zip' || 'rar') {
this.setState({ file: event, fileType: String(fileType) }) this.setState({ file: event, fileType: String(fileType) })
} else { } else {
ExcelRenderer(fileObj, (err, resp) => { ExcelRenderer(fileObj, (err, resp) => {
...@@ -269,7 +265,7 @@ export default class CreateManagementDoc extends Component { ...@@ -269,7 +265,7 @@ export default class CreateManagementDoc extends Component {
object[key] = value; object[key] = value;
}); });
var json = JSON.stringify(object); var json = JSON.stringify(object);
console.log(object) // console.log(object)
} }
} else { } else {
...@@ -428,7 +424,7 @@ export default class CreateManagementDoc extends Component { ...@@ -428,7 +424,7 @@ export default class CreateManagementDoc extends Component {
type={this.state.uploadStatus} type={this.state.uploadStatus}
percentage={this.state.percentage} percentage={this.state.percentage}
result={this.state.result} result={this.state.result}
acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf", "zip"]} acceptedFiles={["xls", "xlsx", "pdf", "PDF", "docx", "doc", "pptx", "ppt", "ods", "odf", "txt", "csv", "zip", "rar"]}
intent={"management"} intent={"management"}
onHandle={(dt) => { onHandle={(dt) => {
this.fileHandler(dt) this.fileHandler(dt)
......
...@@ -101,7 +101,7 @@ export default class DocumentManagement extends Component { ...@@ -101,7 +101,7 @@ export default class DocumentManagement extends Component {
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 === "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({ formData: payload, docId: response.data.data.document_id, settingID, menuName }, () => {
this.setState({ konfirmasi: true }) this.setState({ konfirmasi: true })
}) })
} }
...@@ -131,16 +131,7 @@ export default class DocumentManagement extends Component { ...@@ -131,16 +131,7 @@ export default class DocumentManagement extends Component {
createUploadDocument() { createUploadDocument() {
const formData = this.state.formData const formData = this.state.formData
formData.append("documentId", this.state.docId) formData.append("documentId", this.state.docId)
// const docuID = Object.values(payload) formData.append("updated", 1)
// 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 => { api.create().updateDocument(formData).then(response => {
console.log(response) console.log(response)
if (response.data) { if (response.data) {
......
...@@ -58,7 +58,6 @@ export default class EditManagementDoc extends Component { ...@@ -58,7 +58,6 @@ export default class EditManagementDoc extends Component {
this.getFileSize() this.getFileSize()
if (this.props.type === 'edit') { if (this.props.type === 'edit') {
this.getDetailDoc() this.getDetailDoc()
console.log(this.props)
} }
} }
...@@ -270,15 +269,19 @@ export default class EditManagementDoc extends Component { ...@@ -270,15 +269,19 @@ export default class EditManagementDoc extends Component {
let fileObj = event let fileObj = event
let length = event.name.split(".").length let length = event.name.split(".").length
let fileType = event.name.split(".")[length - 1] let fileType = event.name.split(".")[length - 1]
ExcelRenderer(fileObj, (err, resp) => { if (fileType === 'zip' || 'rar') {
// console.log(fileType) this.setState({ file: event, fileType: String(fileType) })
if (err) { } else {
console.log(err); ExcelRenderer(fileObj, (err, resp) => {
} // console.log(fileType)
else { if (err) {
this.setState({ file: event, fileType: String(fileType) }) console.log(err);
} }
}) else {
this.setState({ file: event, fileType: String(fileType) })
}
})
}
} }
validasi() { validasi() {
......
...@@ -60,7 +60,7 @@ class Upload extends Component { ...@@ -60,7 +60,7 @@ class Upload extends Component {
// console.log(sizeFile); // console.log(sizeFile);
if (this.props.intent === 'management') { if (this.props.intent === 'management') {
if (acceptedFiles) { if (acceptedFiles) {
if (this.props.acceptedFiles.includes(fileType)) { // if (this.props.acceptedFiles.includes(fileType)) {
if ((acceptedFiles[0].size / 1000).toFixed(0) < (this.props.sizeUpload * 1000)) { if ((acceptedFiles[0].size / 1000).toFixed(0) < (this.props.sizeUpload * 1000)) {
this.setState({ this.setState({
file: acceptedFiles[0], file: acceptedFiles[0],
...@@ -77,10 +77,10 @@ class Upload extends Component { ...@@ -77,10 +77,10 @@ class Upload extends Component {
this.setState({ alertMessage: `The file is too large. Allowed maximum size is ${this.props.sizeUpload} MB`, alert: true }) this.setState({ alertMessage: `The file is too large. Allowed maximum size is ${this.props.sizeUpload} MB`, alert: true })
// alert('File Tidak Boleh Lebih Dari 1MB') // alert('File Tidak Boleh Lebih Dari 1MB')
} }
} else { // } else {
this.setState({ alertMessage: 'File extension not allowed', alert: true }) // this.setState({ alertMessage: 'File extension not allowed', alert: true })
// alert('File Tidak Mendukung') // // alert('File Tidak Mendukung')
} // }
} }
else { else {
this.setState({ this.setState({
......
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