Commit eaebc519 authored by syadziy's avatar syadziy

update fixing UAT

parent 6a83ab50
...@@ -23,16 +23,13 @@ export default class CarfmDocument extends Component { ...@@ -23,16 +23,13 @@ export default class CarfmDocument extends Component {
load: false, load: false,
name: '', name: '',
userCompActive: [], userCompActive: [],
isHasAccessDocument: true,
submenu_id : 0, submenu_id : 0,
submenu_name: "", submenu_name: "",
menu_title: "", menu_title: "",
loading: true, loading: false
finishLoad: false,
} }
} }
componentDidMount() { componentDidMount() {
this.getMenuName(); this.getMenuName();
} }
...@@ -52,7 +49,7 @@ export default class CarfmDocument extends Component { ...@@ -52,7 +49,7 @@ export default class CarfmDocument extends Component {
menu_title : item.menu_name.replace(/\b\w/g, c => c.toUpperCase()) menu_title : item.menu_name.replace(/\b\w/g, c => c.toUpperCase())
}, () => { }, () => {
this.getPermission(this.state.submenu_name) this.getPermission(this.state.submenu_name)
this.getDataCarfm(); // this.getDataCarfm();
this.getDetailUser(); this.getDetailUser();
}) })
} }
...@@ -64,44 +61,40 @@ export default class CarfmDocument extends Component { ...@@ -64,44 +61,40 @@ export default class CarfmDocument extends Component {
) )
} }
getDataCarfm(create){ // getDataCarfm(create){
let payload = { // let payload = {
submenu_id : this.state.submenu_id // submenu_id : this.state.submenu_id
} // }
api.create().getCarfmDocumentBySubmenu(payload).then( // api.create().getCarfmDocumentBySubmenu(payload).then(
response => { // response => {
if(response){ // if(response){
if(response.data.status === 'success'){ // if(response.data.status === 'success'){
let dataList = [] // let dataList = []
response.data.data.map((item, index) => { // response.data.data.map((item, index) => {
dataList.push(item) // dataList.push(item)
}) // })
// this.setState({
this.setState({ // listData: dataList,
isHasAccessDocument: true, // refresh: create == undefined ? '' : create,
listData: dataList, // loading: false
refresh: create == undefined ? '' : create // })
}) // } 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(() => {
} else { // localStorage.removeItem(Constant.TOKEN)
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { // window.location.reload();
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { // }, 1000);
setTimeout(() => { // }
localStorage.removeItem(Constant.TOKEN) // })
window.location.reload(); // }
}, 1000); // }else {
} // this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false })
}) // }
} // }
}else { // )
this.setState({ alert: true, messageAlert: response.problem, tipeAlert: 'error', loading: false }) // }
}
}
)
}
getPermission(subMenu) { getPermission(subMenu) {
let payload = { let payload = {
...@@ -117,9 +110,6 @@ export default class CarfmDocument extends Component { ...@@ -117,9 +110,6 @@ export default class CarfmDocument extends Component {
btndownload: response.data.data.download, btndownload: response.data.data.download,
load: true, load: true,
}) })
this.setState({
}, console.log(`btnview ${this.state.btnview}, btncreate ${this.state.btncreate}, btndownload ${this.state.btnview}`), console.log(response.data.data))
console.log("btn create " + this.state.btncreate); console.log("btn create " + this.state.btncreate);
} else { } else {
this.setState({ this.setState({
...@@ -138,7 +128,7 @@ export default class CarfmDocument extends Component { ...@@ -138,7 +128,7 @@ export default class CarfmDocument extends Component {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
this.setState({ userCompany: response.data.data.company, visibleTrue: false, loading: false }, () => { this.setState({ userCompany: response.data.data.company, visibleTrue: false }, () => {
this.getCompanyActive() this.getCompanyActive()
console.log(this.state.userCompany); console.log(this.state.userCompany);
}) })
...@@ -262,18 +252,18 @@ export default class CarfmDocument extends Component { ...@@ -262,18 +252,18 @@ export default class CarfmDocument extends Component {
</Alert> </Alert>
</Snackbar> </Snackbar>
<div className={"main-color"} <div className={"main-color"} style={{ height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20 }}>
style={{height: 78, display: 'flex', alignItems: 'center', paddingLeft: 20}}> <Typography style={{ fontSize: '16px', color: 'white' }}>{this.state.menu_title}</Typography>
<Typography style={{fontSize: '16px', color: 'white'}}>{this.state.menu_title}</Typography>
</div> </div>
{this.state.loading && loadingComponent}
<div style={{padding: 20}}> <div style={{padding: 20}}>
{this.state.loading && loadingComponent}
{this.state.btnview && ( {this.state.btnview && (
<Paper style={{padding: 20}}> <Paper style={{padding: 20}}>
<div style={{display: 'flex', justifyContent: 'flex-end'}}> <div style={{display: 'flex', justifyContent: 'flex-end'}}>
{console.log("renderbtn" + this.state.btncreate)} {/* {console.log("renderbtn" + this.state.btncreate)} */}
{(this.state.btncreate) && <span> {(this.state.btncreate) && (
<span>
<a data-tip={'Add'} data-for="add"> <a data-tip={'Add'} data-for="add">
<div style={{display: 'grid', justifyContent: 'flex-end'}}> <div style={{display: 'grid', justifyContent: 'flex-end'}}>
<button <button
...@@ -286,8 +276,8 @@ export default class CarfmDocument extends Component { ...@@ -286,8 +276,8 @@ export default class CarfmDocument extends Component {
</div> </div>
</a> </a>
<ReactTooltip border={true} id="add" place="bottom" type="light" effect="solid"/> <ReactTooltip border={true} id="add" place="bottom" type="light" effect="solid"/>
</span>} </span>
)}
</div> </div>
<div style={{display: 'flex'}}> <div style={{display: 'flex'}}>
...@@ -295,7 +285,7 @@ export default class CarfmDocument extends Component { ...@@ -295,7 +285,7 @@ export default class CarfmDocument extends Component {
<TableDocument <TableDocument
data={this.state.listData} data={this.state.listData}
refresh={this.state.refresh} refresh={this.state.refresh}
load={true} load={this.state.load}
userCompActive={this.state.userCompActive} userCompActive={this.state.userCompActive}
handleLoading={this.handleLoading.bind(this)} handleLoading={this.handleLoading.bind(this)}
name={this.state.name} name={this.state.name}
...@@ -304,26 +294,20 @@ export default class CarfmDocument extends Component { ...@@ -304,26 +294,20 @@ export default class CarfmDocument extends Component {
/>)} />)}
</div> </div>
</Paper>
)}
{!this.state.btnview && (
<Paper style={{ padding: 20 }}>
<label>You Don't Have Any Access in Document Management</label>
</Paper> </Paper>
)} )}
</div> </div>
{/* {this.state.visibleCreate && ( {this.state.visibleCreate && (
<CreateCarfmDoc <CreateCarfmDoc
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)} createDocument={this.createDocument.bind(this)}
handleLoading={this.handleLoading.bind(this)} handleLoading={this.handleLoading.bind(this)}
submenu_id={this.state.submenu_id} submenu_id={this.state.submenu_id}
menuName={this.state.menu_title}
/> />
)} */} )}
</div> </div>
); );
......
...@@ -23,8 +23,6 @@ export default class CreateCarfmDoc extends Component { ...@@ -23,8 +23,6 @@ export default class CreateCarfmDoc extends Component {
errorPerusahaan: false, errorPerusahaan: false,
msgErrorPerusahaan: '', msgErrorPerusahaan: '',
document: null, document: null,
documentData: null,
getDocument: null,
errorDocument: false, errorDocument: false,
msgErrorDocument: '', msgErrorDocument: '',
listPeriode: null, listPeriode: null,
...@@ -45,29 +43,25 @@ export default class CreateCarfmDoc extends Component { ...@@ -45,29 +43,25 @@ export default class CreateCarfmDoc extends Component {
fileType: '', fileType: '',
docId: '', docId: '',
sizeUpload: "1", sizeUpload: "1",
menuName: null,
saveDisable: false, saveDisable: false,
submitVal: 0 submitVal: 0
} }
} }
async componentDidMount() { componentDidMount() {
this.props.handleLoading(1) this.getDataCompany()
await this.getMenuName() this.getPeriode()
await this.getDataCompany() this.getMonth()
await this.getPeriode() this.getFileSize()
await this.getMonth()
await this.getFileSize()
this.props.handleLoading(0)
} }
async getFileSize() { getFileSize() {
let body = { let body = {
group: 'MAX_FILE_SIZE', group: 'MAX_FILE_SIZE',
company_id: 0, company_id: 0,
type: 'MAX_FILE_SIZE' type: 'MAX_FILE_SIZE'
} }
await api.create().getAllSettingByType(body).then(response => { api.create().getAllSettingByType(body).then(response => {
// console.log(response); // console.log(response);
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -95,8 +89,8 @@ export default class CreateCarfmDoc extends Component { ...@@ -95,8 +89,8 @@ export default class CreateCarfmDoc extends Component {
}) })
} }
async getDataCompany() { getDataCompany() {
await api.create().getPerusahaanUserActive().then((response) => { api.create().getPerusahaanUserActive().then((response) => {
if (response.data) { if (response.data) {
if (response.data.status == 'success') { if (response.data.status == 'success') {
let data = response.data.data let data = response.data.data
...@@ -111,10 +105,10 @@ export default class CreateCarfmDoc extends Component { ...@@ -111,10 +105,10 @@ export default class CreateCarfmDoc extends Component {
// company_name: 'Default' // company_name: 'Default'
// }) // })
let typeProps = { let typeProps = {
options: typeData.sort((a, b) => a.company_name.localeCompare(b.company_name)), options: typeData.sort((a, b) => a.company_name - b.company_name),
getOptionLabel: (option) => option.company_name, getOptionLabel: (option) => option.company_name,
}; };
this.setState({ perusahaan: typeProps}, () => console.log(this.state.perusahaan)) this.setState({ perusahaan: typeProps })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning' }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
...@@ -131,30 +125,8 @@ export default class CreateCarfmDoc extends Component { ...@@ -131,30 +125,8 @@ export default class CreateCarfmDoc extends Component {
}) })
} }
async getMenuName(){ getPeriode() {
api.create().getPeriodeTransaction().then(response => {
await api.create().getMenuByUser().then(
response => {
if(response.data){
if(response.data.status === 'success'){
response.data.data.map(
(item) => {
if(item.menu_id == this.props.submenu_id){
this.setState({
menuName : item.menu_name
}
);
}
}
)
}
}
}
)
}
async getPeriode() {
await api.create().getPeriodeTransaction().then(response => {
let dateNow = new Date let dateNow = new Date
let year = format(dateNow, 'yyyy') let year = format(dateNow, 'yyyy')
if (response.data) { if (response.data) {
...@@ -185,8 +157,8 @@ export default class CreateCarfmDoc extends Component { ...@@ -185,8 +157,8 @@ export default class CreateCarfmDoc extends Component {
}) })
} }
async getMonth() { getMonth() {
await api.create().getMonthTransaction().then(response => { api.create().getMonthTransaction().then(response => {
let dateNow = new Date let dateNow = new Date
// let bulan = format(dateNow, 'MMMM') // let bulan = format(dateNow, 'MMMM')
if (response.data) { if (response.data) {
...@@ -271,7 +243,7 @@ export default class CreateCarfmDoc extends Component { ...@@ -271,7 +243,7 @@ export default class CreateCarfmDoc extends Component {
formData.append("documentPeriode", this.state.periode.periode); formData.append("documentPeriode", this.state.periode.periode);
formData.append("documentMonth", this.state.monthId.month_id); formData.append("documentMonth", this.state.monthId.month_id);
this.setState({ formData }, () => { this.setState({ formData }, () => {
this.props.createDocument(this.state.formData, ) this.props.createDocument(this.state.formData)
}) })
} }
} }
...@@ -340,7 +312,7 @@ export default class CreateCarfmDoc extends Component { ...@@ -340,7 +312,7 @@ export default class CreateCarfmDoc extends Component {
<div style={{ padding: 10, borderRadius: 5, marginTop: "1.2em" }}> <div style={{ padding: 10, borderRadius: 5, marginTop: "1.2em" }}>
<TextField <TextField
value={this.state.menuName} value={this.props.menuName}
InputProps={{ style: { fontSize: 11 } }} InputProps={{ style: { fontSize: 11 } }}
InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }} InputLabelProps={{ style: { fontSize: 11, color: '#7e8085' } }}
placeholder="Category" placeholder="Category"
......
...@@ -57,7 +57,6 @@ export default class TableDocument extends Component { ...@@ -57,7 +57,6 @@ export default class TableDocument extends Component {
let dataTable = [] let dataTable = []
response.data.data.map((item, index) => { response.data.data.map((item, index) => {
let indexId = this.props.userCompActive.findIndex((val) => val == item.company_id) let indexId = this.props.userCompActive.findIndex((val) => val == item.company_id)
if (indexId !== -1) { if (indexId !== -1) {
dataTable.push( [ dataTable.push( [
index, index,
...@@ -73,22 +72,22 @@ export default class TableDocument extends Component { ...@@ -73,22 +72,22 @@ export default class TableDocument extends Component {
item.values item.values
]) ])
} }
}) })
// console.log(dataTable)
this.setState({ dataTable, loading: false })
let docPath = response.data.data.map((item) => { let docPath = response.data.data.map((item) => {
return [ return [
item.document_filepath item.document_filepath
] ]
}) })
this.setState({ docPath, loading: false })
let docId = response.data.data.map((item) => { let docId = response.data.data.map((item) => {
return [ return [
item.document_id item.document_id
] ]
}) })
this.setState({ docId, loading: false })
// console.log(dataTable)
this.setState({ dataTable, docPath, docId, loading: false })
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { 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")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
......
...@@ -22,6 +22,7 @@ export default class DocumentManagement extends Component { ...@@ -22,6 +22,7 @@ export default class DocumentManagement extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
alert: false,
tab: 0, tab: 0,
listData: [], listData: [],
id: 0, id: 0,
......
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