Commit 636ef873 authored by Deni Rinaldi's avatar Deni Rinaldi

push

parent b6c5d5a1
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles } from '@material-ui/core'; import { Typography, Paper, TextField, MenuItem, Select, FormControlLabel, Snackbar, withStyles, createMuiTheme, MuiThemeProvider } from '@material-ui/core';
import MUIDataTable from 'mui-datatables'; import MUIDataTable from 'mui-datatables';
import Images from '../assets/Images'; import Images from '../assets/Images';
import BalanceSheet from './BudgetTahunan/BalanceSheet'; import BalanceSheet from './BudgetTahunan/BalanceSheet';
...@@ -17,6 +17,9 @@ import { format } from 'date-fns'; ...@@ -17,6 +17,9 @@ import { format } from 'date-fns';
import Constant from '../library/Constant'; import Constant from '../library/Constant';
import PropagateLoader from "react-spinners/PropagateLoader" import PropagateLoader from "react-spinners/PropagateLoader"
var ct = require("../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const Alert = withStyles({ const Alert = withStyles({
})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); })((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -500,11 +503,13 @@ export default class BudgetTahunan extends Component { ...@@ -500,11 +503,13 @@ export default class BudgetTahunan extends Component {
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<MUIDataTable <MuiThemeProvider theme={getMuiTheme()}>
data={this.state.dataTable} <MUIDataTable
columns={columns} data={this.state.dataTable}
options={options} columns={columns}
/> options={options}
/>
</MuiThemeProvider>
</div> </div>
<div style={{ display: 'flex', marginTop: 20 }}> <div style={{ display: 'flex', marginTop: 20 }}>
<div style={{ width: '50%' }}> <div style={{ width: '50%' }}>
......
...@@ -40,7 +40,8 @@ export default class CreateManagementDoc extends Component { ...@@ -40,7 +40,8 @@ export default class CreateManagementDoc extends Component {
messageAlert: '', messageAlert: '',
fileType: '', fileType: '',
konfirmasi: false, konfirmasi: false,
docId:'' docId:'',
sizeUpload: "1"
} }
} }
...@@ -49,6 +50,25 @@ export default class CreateManagementDoc extends Component { ...@@ -49,6 +50,25 @@ export default class CreateManagementDoc extends Component {
this.getDataDocument() this.getDataDocument()
this.getPeriode() this.getPeriode()
this.getMonth() this.getMonth()
this.getFileSize()
}
getFileSize(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
} }
getDataCompany() { getDataCompany() {
...@@ -352,6 +372,7 @@ export default class CreateManagementDoc extends Component { ...@@ -352,6 +372,7 @@ export default class CreateManagementDoc extends Component {
this.deleteFile(e) this.deleteFile(e)
}} }}
onUpload={() => alert('sukses')} onUpload={() => alert('sukses')}
sizeUpload={Number(this.state.sizeUpload)}
/> />
</div> </div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}> <div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
......
...@@ -43,16 +43,36 @@ export default class EditManagementDoc extends Component { ...@@ -43,16 +43,36 @@ export default class EditManagementDoc extends Component {
docId: '', docId: '',
document_name: "", document_name: "",
document_size: 0, document_size: 0,
loadUpload: false loadUpload: false,
sizeUpload: "1"
} }
} }
componentDidMount() { componentDidMount() {
this.getFileSize()
if (this.props.type === 'edit') { if (this.props.type === 'edit') {
this.getDetailDoc() this.getDetailDoc()
} }
} }
getFileSize(){
let body = {
group: 'MAX_FILE_SIZE',
company_id: 0,
type: 'MAX_FILE_SIZE'
}
api.create().getAllSettingByType(body).then(response => {
console.log(response);
if (response.data) {
if (response.data.status === "success") {
this.setState({
sizeUpload: response.data.data[0].value
})
}
}
})
}
getDetailDoc() { getDetailDoc() {
api.create().getDetailDocument(this.props.idoc).then(response => { api.create().getDetailDocument(this.props.idoc).then(response => {
console.log(response) console.log(response)
...@@ -68,10 +88,12 @@ export default class EditManagementDoc extends Component { ...@@ -68,10 +88,12 @@ export default class EditManagementDoc extends Component {
period: data.document_periode, period: data.document_periode,
getMonthName: data.document_month, getMonthName: data.document_month,
description: data.description, description: data.description,
file: data.document_filepath,
document_name: data.document_name, document_name: data.document_name,
document_size: data.document_size, document_size: data.document_size,
// id: data.approval_matrix_id, // id: data.approval_matrix_id,
// status: data.status, // status: data.status,
fileType: data.document_type,
created: data.created, created: data.created,
updated: data.updated === null ? "" : data.updated, updated: data.updated === null ? "" : data.updated,
loadUpload: true loadUpload: true
...@@ -247,6 +269,7 @@ export default class EditManagementDoc extends Component { ...@@ -247,6 +269,7 @@ export default class EditManagementDoc extends Component {
} }
validasi() { validasi() {
console.log(this.state.file);
if (R.isNil(this.state.getPerusahaan)) { if (R.isNil(this.state.getPerusahaan)) {
this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' }) this.setState({ errorPerusahaan: true, msgErrorPerusahaan: 'Company Cannot be Empty' })
} else if (R.isNil(this.state.getDocument)) { } else if (R.isNil(this.state.getDocument)) {
...@@ -397,6 +420,7 @@ export default class EditManagementDoc extends Component { ...@@ -397,6 +420,7 @@ export default class EditManagementDoc extends Component {
value={this.state.file} value={this.state.file}
docSize={this.state.document_size} docSize={this.state.document_size}
docName={this.state.document_name} docName={this.state.document_name}
sizeUpload={Number(this.state.sizeUpload)}
/> />
)} )}
</div> </div>
...@@ -431,37 +455,6 @@ export default class EditManagementDoc extends Component { ...@@ -431,37 +455,6 @@ export default class EditManagementDoc extends Component {
> >
</TextField> </TextField>
</div> </div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<TextField
style={{ width: '100%' }}
id="description"
label="Description"
value={this.state.description}
inputProps={{
min: 0,
style: {
fontSize: 11
}
}}
InputLabelProps={{
style: {
fontSize: 11,
color: '#7e8085'
}
}}
name="Description"
onChange={(e) => {
this.setState({
description: e.target.value
})
this.clearMessage()
}}
error={this.state.errorDesc}
helperText={this.state.msgErrorDesc}
>
</TextField>
</div>
<div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}> <div className="margin-top-10px" style={{ paddingLeft: 30, paddingRight: 30, borderRadius: 5, paddingBottom: 20 }}>
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography> <Typography style={{ fontSize: 11, width: '12%' }}>Created By</Typography>
......
...@@ -57,11 +57,11 @@ class Upload extends Component { ...@@ -57,11 +57,11 @@ class Upload extends Component {
let length = acceptedFiles[0].name.split(".").length let length = acceptedFiles[0].name.split(".").length
let fileType = acceptedFiles[0].name.split(".")[length - 1] let fileType = acceptedFiles[0].name.split(".")[length - 1]
formData.append('file', acceptedFiles[0]) formData.append('file', acceptedFiles[0])
console.log(fileType); // 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 (this.state.sizeFile < 10000) { if ((acceptedFiles[0].size / 1000).toFixed(0) < (this.state.sizeUpload * 1000)) {
this.setState({ this.setState({
file: acceptedFiles[0], file: acceptedFiles[0],
typeFile: fileType, typeFile: fileType,
...@@ -74,7 +74,7 @@ class Upload extends Component { ...@@ -74,7 +74,7 @@ class Upload extends Component {
}) })
this.props.onHandle(acceptedFiles[0]) this.props.onHandle(acceptedFiles[0])
} else { } else {
this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 10MB', alert: true }) this.setState({ alertMessage: `The file is too large. Allowed maximum size is ${this.state.sizeUpload}MB`, alert: true })
// alert('File Tidak Boleh Lebih Dari 1MB') // alert('File Tidak Boleh Lebih Dari 1MB')
} }
} else { } else {
...@@ -149,10 +149,10 @@ class Upload extends Component { ...@@ -149,10 +149,10 @@ class Upload extends Component {
if (strProps.includes(strState)) { if (strProps.includes(strState)) {
if (this.props.intent === 'management') { if (this.props.intent === 'management') {
if (this.state.sizeFile < 10000) { if (this.state.sizeFile < this.state.sizeUpload * 1000) {
this.props.onUpload() this.props.onUpload()
} else { } else {
this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 10MB', alert: true }) this.setState({ alertMessage: 'The file is too large. Allowed maximum size is 1MB', alert: true })
// alert('File Tidak Boleh Lebih Dari 1MB') // alert('File Tidak Boleh Lebih Dari 1MB')
} }
} else { } else {
...@@ -213,7 +213,7 @@ class Upload extends Component { ...@@ -213,7 +213,7 @@ class Upload extends Component {
{this.state.docName} {this.state.docName}
</div> </div>
<div className="txt-site txt-11 txt-white txt-thin"> <div className="txt-site txt-11 txt-white txt-thin">
{this.state.docSize} KB {this.state.docSize/1000} KB
</div> </div>
</div> </div>
</div> </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