Commit 6a83ab50 authored by syadziy's avatar syadziy

update fixing UAT

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