Commit 6a83ab50 authored by syadziy's avatar syadziy

update fixing UAT

parent 8bde7f1c
import React, {Component} from 'react' import React, { Component } from 'react'
import {withStyles} from '@material-ui/core/styles'; import { withStyles } from '@material-ui/core/styles';
import {createMuiTheme, MuiThemeProvider, Paper, Snackbar, Tab, Tabs, Typography} from '@material-ui/core'; import { Paper, Snackbar, Typography } from '@material-ui/core';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import Constant from '../../library/Constant'; import Constant from '../../library/Constant';
import Images from '../../assets/Images'; import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip'; 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 "./TableCafrmDocument";
import CreateCarfmDoc from "./CreateCarfmDoc"; import CreateCarfmDoc from "./CreateCarfmDocument";
const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />); const Alert = withStyles({})((props) => <MuiAlert elevation={6} variant="filled" {...props} />);
...@@ -33,34 +33,27 @@ export default class CarfmDocument extends Component { ...@@ -33,34 +33,27 @@ export default class CarfmDocument extends Component {
} }
async componentDidMount() { componentDidMount() {
this.getMenuName();
// this.getPermission()
await this.getMenuName();
await this.getPermission(this.state.submenu_name)
await this.getDataCarfm();
await this.getDetailUser();
await this.setState({
finishLoad: true
})
} }
async getMenuName(){ getMenuName(){
api.create().getMenuByUser().then(
await api.create().getMenuByUser().then(
response => { response => {
if(response.data){ if(response.data){
if(response.data.status === 'success'){ if(response.data.status === 'success'){
response.data.data.map( response.data.data.map(
(item) => { (item) => {
let arr = window.location.href.split('/'); let arr = window.location.href.split('/');
if (item.class_id == arr.slice(-1)[0]){
if(item.class_id == arr.slice(-1)[0]){
this.setState({ this.setState({
submenu_id : item.menu_id, submenu_id : item.menu_id,
submenu_name : item.menu_name.toLowerCase(), submenu_name : item.menu_name.toLowerCase(),
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.getDataCarfm();
this.getDetailUser();
}) })
} }
} }
...@@ -71,11 +64,11 @@ export default class CarfmDocument extends Component { ...@@ -71,11 +64,11 @@ export default class CarfmDocument extends Component {
) )
} }
async getDataCarfm(create){ getDataCarfm(create){
let payload = { let payload = {
submenu_id : this.state.submenu_id submenu_id : this.state.submenu_id
} }
await 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'){
...@@ -110,11 +103,11 @@ export default class CarfmDocument extends Component { ...@@ -110,11 +103,11 @@ export default class CarfmDocument extends Component {
) )
} }
async getPermission(subMenu) { getPermission(subMenu) {
let payload = { let payload = {
menu: subMenu menu: subMenu
} }
await api.create().getPermission(payload).then(response => { api.create().getPermission(payload).then(response => {
if (response.data) { if (response.data) {
console.log(`status get permission ${response.data.status}`); console.log(`status get permission ${response.data.status}`);
if (response.data.status === "success") { if (response.data.status === "success") {
...@@ -139,9 +132,9 @@ export default class CarfmDocument extends Component { ...@@ -139,9 +132,9 @@ export default class CarfmDocument extends Component {
}) })
} }
async getDetailUser() { getDetailUser() {
let userId = localStorage.getItem(Constant.USER) let userId = localStorage.getItem(Constant.USER)
await api.create().getDetailUser(userId).then((response) => { api.create().getDetailUser(userId).then((response) => {
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
if (response.data.status === 'success') { if (response.data.status === 'success') {
...@@ -155,8 +148,8 @@ export default class CarfmDocument extends Component { ...@@ -155,8 +148,8 @@ export default class CarfmDocument extends Component {
}) })
} }
async getCompanyActive() { getCompanyActive() {
await api.create().getPerusahaanActive().then((response) => { api.create().getPerusahaanActive().then((response) => {
console.log("getcompanyactive start"); console.log("getcompanyactive start");
console.log(response.data.data); console.log(response.data.data);
console.log("getcompanyactive stop"); console.log("getcompanyactive stop");
...@@ -200,9 +193,9 @@ export default class CarfmDocument extends Component { ...@@ -200,9 +193,9 @@ export default class CarfmDocument extends Component {
}) })
} }
async createDocument(payload) { //upload apinya disini createDocument(payload) { //upload apinya disini
this.setState({ loading: true }) this.setState({ loading: true })
await api.create().uploadCarfmDocument(payload).then(response => { api.create().uploadCarfmDocument(payload).then(response => {
// console.log(response) // console.log(response)
if (response.data) { if (response.data) {
if (response.ok) { if (response.ok) {
...@@ -260,10 +253,9 @@ export default class CarfmDocument extends Component { ...@@ -260,10 +253,9 @@ export default class CarfmDocument extends Component {
/> />
</div> </div>
); );
return ( return (
<div style={{height: this.props.height, backgroundColor: '#f8f8f8'}}> <div style={{height: this.props.height, backgroundColor: '#f8f8f8'}}>
{/* {this.props.load && ()} */}
<Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}> <Snackbar open={this.state.alert} autoHideDuration={6000} onClose={() => this.closeAlert()}>
<Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}> <Alert onClose={() => this.closeAlert()} severity={this.state.tipeAlert}>
{this.state.messageAlert} {this.state.messageAlert}
...@@ -275,13 +267,10 @@ export default class CarfmDocument extends Component { ...@@ -275,13 +267,10 @@ export default class CarfmDocument extends Component {
<Typography style={{fontSize: '16px', color: 'white'}}>{this.state.menu_title}</Typography> <Typography style={{fontSize: '16px', color: 'white'}}>{this.state.menu_title}</Typography>
</div> </div>
<div style={{padding: 20}}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent}
<div style={{padding: 20}}>
{this.state.btnview && this.state.finishLoad && ( {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>
...@@ -302,8 +291,8 @@ export default class CarfmDocument extends Component { ...@@ -302,8 +291,8 @@ export default class CarfmDocument extends Component {
</div> </div>
<div style={{display: 'flex'}}> <div style={{display: 'flex'}}>
{this.state.visibleTrue && (
{this.state.visibleTrue && (<TableDocument <TableDocument
data={this.state.listData} data={this.state.listData}
refresh={this.state.refresh} refresh={this.state.refresh}
load={true} load={true}
...@@ -319,15 +308,14 @@ export default class CarfmDocument extends Component { ...@@ -319,15 +308,14 @@ export default class CarfmDocument extends Component {
</Paper> </Paper>
)} )}
{!this.state.btnview && (
{!this.state.btnview && this.state.finishLoad && (
<Paper style={{ padding: 20 }}> <Paper style={{ padding: 20 }}>
<label>You Don't Have Any Access in Document Management</label> <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)}
...@@ -335,7 +323,7 @@ export default class CarfmDocument extends Component { ...@@ -335,7 +323,7 @@ export default class CarfmDocument extends Component {
handleLoading={this.handleLoading.bind(this)} handleLoading={this.handleLoading.bind(this)}
submenu_id={this.state.submenu_id} submenu_id={this.state.submenu_id}
/> />
)} )} */}
</div> </div>
); );
......
...@@ -20,7 +20,7 @@ import SubHolding from '../container/Reports/SubHolding'; ...@@ -20,7 +20,7 @@ import SubHolding from '../container/Reports/SubHolding';
import SummaryTriputra from '../container/SummaryTriputra/SummaryOfTriputra'; import SummaryTriputra from '../container/SummaryTriputra/SummaryOfTriputra';
import MasterDataCAT from '../container/MasterData/MasterDataCAT/MasterDataCAT'; import MasterDataCAT from '../container/MasterData/MasterDataCAT/MasterDataCAT';
import ProgressReport from '../container/ProgressReport/ProgressReport'; import ProgressReport from '../container/ProgressReport/ProgressReport';
import CarfmDocument from "../container/CRFM/CarfmDocument"; import CarfmDocument from "../container/CAFRM/CafrmDocument";
const routes = [ const routes = [
{ {
......
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