Facebook
From akoto, 5 Years ago, written in Plain Text.
This paste is a reply to ApproveRestrictedPayeeCTR from akoto - go back
Embed
Viewing differences between ApproveRestrictedPayeeCTR and RestrictedPayeeStore
/**
 * ApproveRestrictedPayeeCTR.RestrictedPayeeStore.js
 */

import React, { Component {
  observable,
  extendObservable,
  action,
  asMap,
  reaction,
  autorunm,
  toJS
} from "react";
"mobx";
import Helmet from "react-helmet";
"underscore";
import ClientConfig from "../config/ClientConfig";
import { BaseContainers, BaseMiddlewares } from "frontend-react-f4-base-commons";
const { ClientMiddleware } = BaseMiddlewares;
import { 
BaseComponents } from "frontend-react-f4-base-ui";
import { BaseContext } from "frontend-react-f4-base-commons";
import { observer } from "mobx-react";
import TextArea 
CitrineFunctionCodes from "../../components/TextArea/TextArea";
/enums/CitrineFunctionCodes";
import moment from "moment";
const { strings } = BaseComponents;
import { Modal } from "antd";
import MaintenanceApprovalConfirmPanel 
YesOrNoEnum from "../../components/MaintenanceApprovalConfirmPanel/MaintenanceApprovalConfirmPanel";
import MaintenanceApprovalPanel from "../../components/MaintenanceApprovalPanel/MaintenanceApprovalPanel";
import CitrineFunctionCodes from "../../enums/CitrineFunctionCodes";
import MaintenanceApprovalAckPanel from "../../components/MaintenanceApprovalAckPanel/MaintenanceApprovalAckPanel";
import ViewPage from "../../components/ViewPage/ViewPage";
import AckMessage from "../../components/AckMessage/AckMessage";
import _ from "underscore";
import ApproveRejectViewPageActionPanel from "../../components/ApproveRejectViewPageActionPanel/ApproveRejectViewPageActionPanel";

import BoNewViewPage from "../../components/BoNewViewPage/BoNewViewPage";
import NewViewRestrictedPayeePanel from "../../components/NewViewRestrictedPayeePanel/NewViewRestrictedPayeePanel";

const { connect } = BaseContext;
const { F4ContentContainer } = BaseContainers;
const { strings, F4Stepper, Feedback } = BaseComponents;

import ClientConfig from "../../config/ClientConfig";

@observer
@connect
/enums/YesOrNoEnum";

export default 
class ApproveRestrictedPayeeCTR extends Component RestrictedPayeeStore {
  constructor(props) constructor(RestrictedPayeeStore) {
    super(props);

if (RestrictedPayeeStore) {
      Object.assign(this, RestrictedPayeeStore);
    }

    this.state = reset();
    this.resetInputs();
    this.resetErrorList();
    this.resetSearchFields();
    this.resetApprovalFields();
  }

  @action
  reset() {
    extendObservable(this, 
{
      pages: copyFromStore: null,
      hasManualAuth: false,
      hasUploadAuth: false,
      isManual: true,

      clickedNext: false,
      clickedBack: false,
      previousData: null,
      dataTableRef: null,
      isforView: false,
      dataTableStore: 
{
        initial: 0,
        confirm: 1,
        ack: 2,
        view: 3,
        viewForConfirmAck: 4,
        ackForSingle: 5
getTotal: null
      },
      showErrorModal: selectedMenuOnAdd: 0,
      selectedMenuOnEdit: 0,
      selectedMenuOnApprove: 0,
      selectedMenuOnSearch: 0,
      fields: {
        payeeName: strings.global_restrictedpayeenm,
        amount: strings.global_amount,
        isAllowed: strings.global_isallowed,
        charToIgnore: strings.global_character_ignore
      },
      copyFromFields: [
        {
          key: "amount"
        }
      ],
      payeeFields: [
        {
          key: "payeeName",
          label: strings.global_restrictedpayeenm
        },
        {
          key: "amount",
          label: strings.global_amount
        },
        {
          key: "isAllowed",
          label: strings.global_isallowed
        },
        {
          key: "charToIgnore",
          label: strings.global_character_ignore
        }
      ],
      payeeSaved: null,
      refNoDeleteMultiple: null,

      isForApproval: 
false,
      errorModalMsg: "",
      readOnly: false,
      prevPage: 
ackMessage: {
        header: null,
        refNo: null
      },
      approveListReqModel: {
        localUserCd: null,
        maintenanceList: null,
        isApprove: false
      },
      approvalConfirmProps: {
        action: null,
        remarks: "",
        dataList: null
      },
      approvalAckProps: {
        dataList: null,
        action: null,
        remarks: null,
        refNo: null,
        message: null
      },
      viewPageMaintenanceData: null,
      uploadFields: {
        payeeName: null,
        amount: 0,
        isAllowed: false,
        charToIgnore: null
      },
      searchFilter: {
        payeeName: null,
        amount: 0,
        isAllowed: false,
        charToIgnore: null,
        restrictedPayeeDate: null,
        filterList: [],
        isInquiry: true,
        maker: null,
        requiresApprovalFuncCd:
          CitrineFunctionCodes.RESTRICTED_PAYEE_NM_REQUIRES_APPROVAL
      },
      // transactionOptionsRadioButton: [
      //   {
      //     value: 
0,
      isForView: false,
      clickedApprove: false,
      clickedReject: false
//     label: "Disallow Payee"
      //   },
      //   {
      //     value: 1,
      //     label: "Allow Payee but with Override"
      //   }
      // ],
      isAllowed: [
        {
          value: 0,
          label: "Disallow Payee"
        },
        {
          value: 1,
          label: "Allow Payee but with Override"
        }
      ]
    });
  }

  @observable responseBody = null;
  @observable restrictedPayeeList = null;
  @observable restrictedPayeeDtlString = null;

  @action getFieldLabel(key) {
    let field = _.findWhere(this.payeeFields, {
      key: key
    });
    return field ? field.label : "";
  }

  @action resetErrorList() {
    extendObservable(this, {
      errors: []
    });
  }

  @action initializeMaintenanceModel(data, actnFuncCd, userCd, grpId) {
    let isAdd = actnFuncCd === CitrineFunctionCodes.RESTRICTED_PAYEE_NM_ADD;
    let editFuncCd =
      actnFuncCd === isAdd
        ? null
        : CitrineFunctionCodes.RESTRICTED_PAYEE_NM_EDIT;
    let deleteFuncCd = isAdd
      ? null
      : CitrineFunctionCodes.RESTRICTED_PAYEE_NM_DEL;

    return {
      localUserCd: userCd,
      requiresApprovalFuncCd:
        CitrineFunctionCodes.RESTRICTED_PAYEE_NM_REQUIRES_APPROVAL,
      actnFuncCd: actnFuncCd,
      approveRejectFuncCd:
        CitrineFunctionCodes.RESTRICTED_PAYEE_NM_APPROVE_REJECT,
      addFuncCd: isAdd ? CitrineFunctionCodes.RESTRICTED_PAYEE_NM_ADD : null,
      editFuncCd: editFuncCd,
      deleteFuncCd: deleteFuncCd,
      modelNm: strings.global_payee,
      grpId: grpId,
      isAdd: isAdd,
      dtlString: JSON.stringify({
        id: isAdd ? null : data.id,
        cd: isAdd ? null : data.cd,
        funcCd: data.funcCd,
        payeeName: data.payeeName,
        amount: data.amount,
        charToIgnore: data.charToIgnore,
        isAllowed: data.isAllowed,
        version: isAdd ? null : data.version
      }),
      filterValues: [
        data.payeeName,
        data.amount,
        data.isAllowed,
        data.charToIgnore
      ],
      uniqueCds: [data.payeeName]
    };
  }

  componentDidMount() @action resetInputs() {
    const { RestrictedPayeeStore } = this.context.store;
    const { onLoadResults } = this.props;
    RestrictedPayeeStore.resetApprovalFields();
    if (onLoadResults && onLoadResults === true) 
extendObservable(this, {
      this.onSearch();
    }
restrictedPayeeInputs: {
        localUserCd: null,
        id: null,
        payeeName: "",
        amount: 0,
        isAllowed: true,
        isAllowedStr: "",
        transactionOptionRadioButton: 0,
        charToIgnore: null,
        showEdit: false
      }
    });
  }

  redirectTo = pageNo => @action resetSearchFields() {
    const { RestrictedPayeeStore } = this.context.store;
    RestrictedPayeeStore.selectedMenuOnApprove = pageNo;
  };

  confirmOnClickBack = () => {
    const { MaintenanceStore, RestrictedPayeeStore } = this.context.store;
    MaintenanceStore.approveList = null;
    RestrictedPayeeStore.resetApprovalFields();
    this.redirectTo(
      this.state.isForView ? this.state.pages.view : this.state.pages.initial
    );
    this.setState({ isForView: false });
  };

  confirmOnClickSubmit = (isApprove, succCB) => {
    const { auth, RestrictedPayeeStore, SettingsStore } = this.context.store;

    SettingsStore.isScreenLoading = true;
    this.setState({ prevPage: this.state.pages.confirm });
    RestrictedPayeeStore.approveListReqModel.localUserCd =
      auth.sessionUser.user.cd;
    RestrictedPayeeStore.approveListReqModel.isApprove = isApprove;
    RestrictedPayeeStore.approveListReqModel.remarks =
      RestrictedPayeeStore.approvalConfirmProps.remarks;
    RestrictedPayeeStore.approveListReqModel.maintenanceList =
      RestrictedPayeeStore.approvalConfirmProps.dataList;

    if (isApprove) 
extendObservable(this, {
      RestrictedPayeeStore.validateApproval(
        RestrictedPayeeStore.approveListReqModel.maintenanceList,
        res => 
searchRestrictedPayeeFields: [
        
{
          console.log("Res on validate Approval", res);
          if (res.body && res.body.error) {
            if (res.body.error.errors) 
index: "payeeName",
          label: strings.global_restrictedpayeenm,
          type: "text",
          content: null,
          value: null
        },
        {
          index: "amount",
          label: strings.global_amount,
          type: "text",
          content: null,
          value: null
        },
        {
          index: "isAllowed",
          label: strings.global_action,
          type: "radio",
          content: [
            
{
              _.each(res.body.error.errors, errStr => {
                RestrictedPayeeStore.errors.push(errStr.message);
              });
            } else if (res.body.error.message) 
value: 1,
              // label: YesOrNoEnum.getDescriptionFromKey(1)
              label: "Allow Payee but with Override"
            },
            
{
              RestrictedPayeeStore.errors.push(res.body.error.message);
value: 0,
              // label: YesOrNoEnum.getDescriptionFromKey(0)
              label: "Disallow Payee"
            },
            {
              value: 2,
              label: strings.global_all
            }
            SettingsStore.isScreenLoading = false;\n            this.setState({ clickedApprove: false });\n            succCB && succCB();\n          } else           ],
          value: 2,
          defaultValue: 2
        }
      ]
    });
  }

  @action
  resetSearchFilters() {
    extendObservable(this, {});
  }

  @action
  resetApprovalFields() {
    extendObservable(this, {
      approvalFields: [
        {
          index: "refNo",
          label: strings.global_refno,
          type: "text",
          content: null,
          value: null
        },
        {
          index: "filterOne",
          label: strings.global_restrictedpayeenm,
          type: "text",
          content: null,
          value: null,
          filterType: 
{
            this.approveList(isApprove, succCB);
            // SettingsStore.isScreenLoading = false;
isEq: true,
            isCaseSensitive: true
          }
        },
        {
          index: "filterTwo",
          label: strings.global_amount,
          type: "text",
          content: null,
          value: null,
          filterType: {
            isEq: true,
            isCaseSensitive: true
          }
        },
        // {
        //   index: "filterThree",
        //   label: strings.global_isallowed,
        //   type: "text",
        //   content: null,
        //   value: null,
        //   filterType: {
        //     isEq: true,
        //     isCaseSensitive: true
        //   }
        // },
        // {
        //   index: "filterFour",
        //   label: "Characters To Ignore",
        //   type: "text",
        //   content: null,
        //   value: null,
        //   filterType: {
        //     isEq: true,
        //     isCaseSensitive: true
        //   }
        // },
        {
          index: "fromDate",
          label: strings.global_creatddt,
          type: "dateBetween",
          content: null,
          value: moment()
            .subtract(2, "months")
            .add(1, "days"),
          children: null
        },
        {
          index: "toDate",
          label: strings.global_creatddt,
          type: "dateBetween",
          content: null,
          value: moment(),
          children: null
        }
      );
]
    });
  }

  @action
  hasErrors(responseBody) {
    if (responseBody && !responseBody.error) {
      return false;
    } else {
      this.approveList(isApprove, succCB);
      // SettingsStore.isScreenLoading = false;
    }
  };

  approveList = (isApprove, succCB) => {
    const { RestrictedPayeeStore, SettingsStore } = this.context.store;

    
let message errorMessage isApprove
      ? strings.formatString(
          strings.feedback_success_approval,
          strings.global_restrictedpayeenm,
          "approved"
        )
      : strings.formatString(
          strings.feedback_success_approval,
          strings.global_restrictedpayeenm,
          "rejected"
        );
    let messageSingle = isApprove
      ? "Restricted Payee Name was approved."
      : "Restricted Payee Name was rejected.";
    RestrictedPayeeStore.approveList(
      RestrictedPayeeStore.approveListReqModel,
      res => 
null;
      if (
        responseBody &&
        responseBody.error &&
        responseBody.statusCode != 500
      ) 
{
        console.log("Approve List: ", res);
        
if (!res.body && res.text) (responseBody.error.errors) {
          RestrictedPayeeStore.approvalAckProps errorMessage {
            dataList: RestrictedPayeeStore.approvalConfirmProps.dataList,
            action: isApprove
              ? strings.global_approve.toLowerCase()
              : strings.global_reject.toLowerCase(),
            remarks: RestrictedPayeeStore.approvalConfirmProps.remarks,
            refNo: res.text,
            message: this.state.isForView ? messageSingle : message
          };
          if (this.state.isForView) {
            let maintenanceList =
              RestrictedPayeeStore.approvalAckProps.dataList;
            RestrictedPayeeStore.restrictedPayeeDtlString =
              maintenanceList &&
              maintenanceList.length > 0 &&
              JSON.parse(maintenanceList[0].dtlString);
            this.redirectTo(this.state.pages.ackForSingle);
            this.setState({
              prevPage: this.state.pages.ackForSingle
            });
          
responseBody.error.errors;
        
} else {
            this.redirectTo(this.state.pages.ack);
            this.setState({ prevPage: this.state.pages.ack });
          }
          SettingsStore.isScreenLoading 
if (responseBody.error.message) {
          errorMessage 
false;
          succCB && succCB();
responseBody.error.message;
        } else {
          if (res.body.error.errors) {
            _.each(res.body.error.errors, errStr => {
              RestrictedPayeeStore.errors.push(errStr.message);
            });
          } else if (res.body.error.message) {
            RestrictedPayeeStore.errors.push(res.body.error.message);
          }
          SettingsStore.isScreenLoading 
errorMessage false;
          succCB && succCB();
responseBody.message;
        }
      } else {
        errorMessage = this.feedbackBadErrloginMessage;
      }
      this.setErrors(errorMessage);
      return true;
    }
  }

  @action
  setErrors = error => {
    if (this.isString(error)) {
      this.errors = [error];
    } else if (this.isArray(error)) {
      this.errors = _.map(error, e => e.message);
    }
  };

  @action
  isString(value) {
    return typeof value === "string" || value instanceof String;
  }

  @action
  isArray(value) {
    return value && typeof value === "object" && value.constructor === Array;
  }

  @action
  validateRestrictedPayee(restrictedPayeeReqModel, succCB, errCB) {
    console.log("Endpoint on RestrictedPayeeStore.validateRestrictedPayee");
    this.errors = [];

    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeValidate,
      restrictedPayeeReqModel,
      succCB,
      err => {
        this.hasErrors(err);
        errCB && errCB(err);
      }
    );
  };

  onClickRefNo = data => 
}

  @action
  addRestrictedPayee(restrictedPayeeReqModel, succCB, errCB) 
{
    const { RestrictedPayeeStore, MaintenanceStore } = this.context.store;
    RestrictedPayeeStore.resetErrorList();
    RestrictedPayeeStore.viewPageMaintenanceData = data;

    MaintenanceStore.remarks = null;
    RestrictedPayeeStore.resetApprovalFields();
    this.redirectTo(this.state.pages.view);
    this.setState({
      readOnly: false,
      prevPage: this.state.pages.confirm,
      isForView: true
    });
  };

  onClickRefNoForConfirmAck = data => {
    const { RestrictedPayeeStore, MaintenanceStore } = this.context.store;
    RestrictedPayeeStore.viewPageMaintenanceData = data;
    this.redirectTo(this.state.pages.viewForConfirmAck);
    this.setState({ readOnly: true });
  };

  onClickApprove = (maintenanceList, remarks, succCB) => {
    const {
      RestrictedPayeeStore,
      MaintenanceStore,
      auth,
      SettingsStore
    } = this.context.store;
    MaintenanceStore.errors = [];
    SettingsStore.isScreenLoading = true;
    this.setState({ clickedApprove: true });
    RestrictedPayeeStore.validateApproval(maintenanceList, res => {
      
console.log("Res log("Endpoint on Validate Payee Approval: ", res);
      if (res.body && res.body.error) {
        if (res.body.error.errors) {
          _.each(res.body.error.errors, errStr 
restrictedPayeeStore.addrestrictedPayee");
    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeAdd,
      restrictedPayeeReqModel,
      succCB,
      err 
=> {
            MaintenanceStore.errors.push(errStr.message);
            RestrictedPayeeStore.errors.push(errStr.message);
          });
        } else if (res.body.error.message) {
          MaintenanceStore.errors.push(res.body.error.message);
          RestrictedPayeeStore.errors.push(res.body.error.message);
        }
        MaintenanceStore.remarks = null;
        SettingsStore.isScreenLoading = false;
{
        this.setState({ clickedApprove: false });
        succCB 
hasErrors(err);
        errCB 
&& succCB();
      } else {
        console.log("No Errors.");
        MaintenanceStore.validateApprovalReqModel.isApprove = true;
        MaintenanceStore.validateApprovalReqModel.maintenanceList = maintenanceList;
        MaintenanceStore.validateApprovalReqModel.modelNm =
          strings.global_payee;
        MaintenanceStore.validateApprovalReqModel.remarks = remarks;
        MaintenanceStore.validateApprovalReqModel.requiresApprovalFuncCd =
          CitrineFunctionCodes.RESTRICTED_PAYEE_NM_REQUIRES_APPROVAL;
        //CitrineFunctionCodes.COURIER_MAINTENANCE_REQUIRES_APPROVAL;
        MaintenanceStore.validateApprovalReqModel.userCd =
          auth.sessionUser.user.cd;

        MaintenanceStore.validateApproval(
          MaintenanceStore.validateApprovalReqModel,
          res => {
            if (res.body && res.body.error) {
              _.each(res.body.error.errors, errStr => {
                MaintenanceStore.errors.push(errStr.message);
              });
              this.setState({ clickedApprove: false });
              SettingsStore.isScreenLoading = false;
              succCB && succCB();
            } else {
              console.log("No Errors.");

              RestrictedPayeeStore.approvalConfirmProps = {
                action: strings.global_approve.toLowerCase(),
                remarks: remarks,
                dataList: maintenanceList
              };
              RestrictedPayeeStore.resetErrorList();
              if (this.state.isForView) {
                this.confirmOnClickSubmit(true, null);
              } else {
                this.redirectTo(this.state.pages.confirm);
                this.setState({
                  prevPage: this.state.pages.confirm
                });
                SettingsStore.isScreenLoading = false;
              }
              MaintenanceStore.remarks = null;
              this.setState({ clickedApprove: false });
              succCB && succCB();
            }
          }
        );
      }
    });
  };

  onClickReject = (maintenanceList, remarks, succCB) => {
    const {
      RestrictedPayeeStore,
      MaintenanceStore,
      auth,
      SettingsStore
    } = this.context.store;

    SettingsStore.isScreenLoading = true;
    MaintenanceStore.errors = [];
    this.setState({ clickedReject: true });

    MaintenanceStore.validateApprovalReqModel.isApprove = false;
    MaintenanceStore.validateApprovalReqModel.maintenanceList = maintenanceList;
    MaintenanceStore.validateApprovalReqModel.modelNm = strings.global_payee;
    MaintenanceStore.validateApprovalReqModel.remarks = remarks;
    MaintenanceStore.validateApprovalReqModel.requiresApprovalFuncCd =
      CitrineFunctionCodes.RESTRICTED_PAYEE_NM_REQUIRES_APPROVAL;
    // CitrineFunctionCodes.COURIER_MAINTENANCE_REQUIRES_APPROVAL;
    MaintenanceStore.validateApprovalReqModel.userCd = auth.sessionUser.user.cd;

    MaintenanceStore.validateApproval(
      MaintenanceStore.validateApprovalReqModel,
      res => {
        if (res.body && res.body.error) {
          _.each(res.body.error.errors, errStr => {
            MaintenanceStore.errors.push(errStr.message);
          });

          this.setState({
            showErrorModal: true,
            errorModalMsg: MaintenanceStore.errors[0],
            clickedReject: false
          });
          SettingsStore.isScreenLoading = false;
          succCB && succCB();
        } else {
          console.log("No Errors.");
          RestrictedPayeeStore.approvalConfirmProps = {
            action: strings.global_reject.toLowerCase(),
            remarks: remarks,
            dataList: maintenanceList
          };
          RestrictedPayeeStore.resetErrorList();
          if (this.state.isForView) {
            this.confirmOnClickSubmit(false, () => {
              this.setState({
                clickedReject: false
              });
            });
          } else {
            this.redirectTo(this.state.pages.confirm);
            this.setState({
              prevPage: this.state.pages.confirm,
              clickedReject: false
            });
          }
          SettingsStore.isScreenLoading = false;
          succCB && succCB();
        }
        MaintenanceStore.remarks = null;
errCB(err);
      }
    );
  };

  onSearch = multiSort => 
}

  @action
  editrestrictedPayee(restrictedPayeeReqModel, succCB, errCB) 
{
    const { RestrictedPayeeStore, MaintenanceStore, auth } = this.context.store;

    if (!multiSort) {
      multiSort = {
        page: 0,
        count: 10,
        sortList: [
          {
            direction: "desc",
            sort: "updatedDt"
          }
        ]
      };
    }

    let fields = RestrictedPayeeStore.approvalFields;
    {
      fields != undefined &&
        fields.map(
          field =>
            (MaintenanceStore.searchRequestModel[field.index] = field.value)
        );
    }

    MaintenanceStore.errors = [];

    MaintenanceStore.searchRequestModel.notCreatedBy = auth.sessionUser.user.cd;
    MaintenanceStore.searchRequestModel.filterTypeOne = {
      isCaseSensitive: false,
      isEq: true
    };
    MaintenanceStore.searchRequestModel.filterTypeTwo = {
      isCaseSensitive: false,
      isEq: false
    };
    MaintenanceStore.searchRequestModel.funcCd =
      CitrineFunctionCodes.RESTRICTED_PAYEE_NM_REQUIRES_APPROVAL;
    //CitrineFunctionCodes.COURIER_MAINTENANCE_REQUIRES_APPROVAL;

    MaintenanceStore.findBySearchModel(
      MaintenanceStore.searchRequestModel,
      multiSort,
      res 
console.log("Endpoint on restrictedPayeeStore.editrestrictedPayee");
    ClientMiddleware.put(
      ClientConfig.apiEndpoints.restrictedPayeeEdit,
      restrictedPayeeReqModel,
      succCB,
      err 
=> {
        if (res.body && !res.body.error) {
          console.log("app res: ", res);
          MaintenanceStore.responseBody = res.body;
          MaintenanceStore.approveList = res.body.content;
          let data = MaintenanceStore.approveList;
          MaintenanceStore.dataTableRef.setState({
            data: data,
            copyOfData: data,
            totalItemsCount: res.body.totalElements
          });
          MaintenanceStore.dataTableRef &&
            MaintenanceStore.dataTableRef.forceUpdate();
        } else {
          console.log("Error", res.body.error);
        }
        // 
this.setState({ hasClickedSearch: true });
hasErrors(err);
        errCB && errCB(err);
      }
    );
  };

  _createData = () => 
}

  @action
  deleteRestrictedPayee(restrictedPayee, succCB, errCB) 
{
    return [
      
console.log("Endpoint on restrictedPayee.deleterestrictedPayee");
    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeDelete,
      restrictedPayee,
      succCB,
      err => 
{
        headerTitle: strings.global_refno,
        name: "refNo",
        type: "link",
        width: 100,
        cell: props => (
                       className="linkInTable"
            onClick={() => 
this.onClickRefNo(props.data)}
          >
            {" "}
            {props.data.refNo}{" "}
          
        )
      },
      {
        headerTitle: strings.global_restrictedpayeenm,
        name: "filterOne",
        type: "text",
        width: 100
      },
      {
        headerTitle: strings.global_amount,
        name: "filterTwo",
        type: "text",
        width: 100
      },
      {
        headerTitle: strings.global_func,
        // name: "actnFuncCd",
        name: "actnFunc.description",
        type: "text",
        width: 150,
        sortBy: "actnFunc.description",
        cell: props => (
          
            {props.data.actnFunc.description}
          
        )
      },
      {
        headerTitle: strings.global_creatdby,
        name: "createdBy",
        type: "text",
        width: 150
      },
      {
        headerTitle: strings.global_createdt,
        name: "createdDt",
        type: "text",
        width: 150,
        formatter: "date"
hasErrors(err);
        errCB && errCB(err);
      }
    ];\n  };\n\n  _createDataForConfirmAck = () => {\n    return [\n      {\n        headerTitle: strings.global_refno,\n        name: "refNo",\n        type: "link",\n        width: 100,\n        cell: props => (\n           this.onClickRefNoForConfirmAck(props.data)}\n          >\n            {" "}\n            {props.data.refNo}{" "}\n          \n        )\n      },\n      {\n        headerTitle: strings.global_restrictedpayeenm,\n        name: "filterOne",\n        type: "text",\n        width: 100\n      },\n      {\n        headerTitle: strings.global_amount,\n        name: "filterTwo",\n        type: "text",\n        width: 100\n      },\n      {\n        headerTitle: strings.global_func,\n        // name: "actnFuncCd",\n        name: "actnFunc.description",\n        type: "text",\n        width: 150,\n        sortBy: "actnFunc.description",\n        cell: props => (\n          \n            {props.data.actnFunc.description}\n          \n        )\n      },\n      {\n        headerTitle: strings.global_creatdby,\n        name: "createdBy",\n        type: "text",\n        width: 150\n      },\n      {\n        headerTitle: strings.global_createdt,\n        name: "createdDt",\n        type: "text",\n        width: 120,\n        formatter: "date"\n      }\n    ];\n  };\n\n  onClickDownload = multiSort => {\n    const { MaintenanceStore, auth } = this.context.store;\n    return new Promise(resolve => {\n      MaintenanceStore.findBySearchModel(\n        MaintenanceStore.searchRequestModel,\n        multiSort,\n        res => {\n          if (res.body && !res.body.error) {\n            resolve(res.body.content);\n          }\n        }\n      );\n    });\n  };\n\n  _showMaintenanceApprovalPanel() {\n    const { RestrictedPayeeStore } = this.context.store;\n    return (\n      \n    );
  }

  _showMaintenanceApprovalConfirmPanel() @action
  deleteMultiplerestrictedPayee(
    localUserCd,
    restrictedPayeeList,
    succCB,
    errCB
  ) 
{
    const console.log(
      "Endpoint on restrictedPayeeStore.deleteMultiplerestrictedPayee"
    );
    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeDeleteMultiple,
      
MaintenanceStore, RestrictedPayeeStore } = restrictedPayeeList, localUserCd },
      succCB,
      err => {
        
this.context.store;
    let isApprove =
      RestrictedPayeeStore.approvalConfirmProps.action === "approve";
    return (
               isMultiple={true}
        isAck={false}
        isConfirm={true}
        columnHeaders={this._createDataForConfirmAck()}
        action={RestrictedPayeeStore.approvalConfirmProps.action}
        remarks={RestrictedPayeeStore.approvalConfirmProps.remarks}
        dataList={RestrictedPayeeStore.approvalConfirmProps.dataList}
        onClickBack={() => {
          MaintenanceStore.remarks = null;
          RestrictedPayeeStore.resetErrorList();
          this.confirmOnClickBack();
        }}
        onClickSubmit={() => this.confirmOnClickSubmit(isApprove, null)}
        errorFeedback={RestrictedPayeeStore.errors}
        stepWizardHeader={"Confirm Details"}
        modelName={strings.global_payee}
      />
hasErrors(err);
        errCB && errCB(err);
      }
    );
  }

  _showMaintenanceApprovalAckPanel() @action
  findBySearchModel(search, multiSort, succCB, errCB) 
{
    const console.log(
      "Endpoint on restrictedPayeeStore.restrictedPayeeFindBySearchModel"
    );
    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeFindBySearchModel,
      
MaintenanceStore, RestrictedPayeeStore } = search, multiSort },
      succCB,
      err => {
        
this.context.store;
    return (
               isMultiple={true}
        isAck={true}
        isConfirm={false}
        header={RestrictedPayeeStore.approvalAckProps.message}
        refNo={RestrictedPayeeStore.approvalAckProps.refNo}
        columnHeaders={this._createDataForConfirmAck()}
        action={RestrictedPayeeStore.approvalAckProps.action}
        remarks={RestrictedPayeeStore.approvalAckProps.remarks}
        dataList={RestrictedPayeeStore.approvalAckProps.dataList}
        hasButtons
        modelName={strings.global_payee}
        backButtonLabel={strings.formatString(
          strings.button_middle_backxtopage,
          strings.formatString(
            strings.global_approveobj,
            strings.global_restrictedpayeenms
          )
        )}
        onClickBack={() => {
          MaintenanceStore.remarks = null;
          RestrictedPayeeStore.resetApprovalFields();
          MaintenanceStore.approveList = null;
          this.redirectTo(this.state.pages.initial);
        }}
        stepWizardHeader={strings.global_acknowledgement}
      />
hasErrors(err);
        errCB && errCB(err);
      }
    );
  }

  _showViewPage(actionButtons) @action
  findBySearchModelForMaintenance(search, multiSort, succCB, errCB) 
{
    const console.log(
      "Endpoint on restrictedPayeeStore.findBySearchModelForMaintenance"
    );
    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeFindBySearchModelForMaintenance,
      
RestrictedPayeeStore, MaintenanceStore } = search, multiSort },
      succCB,
      err => {
        
this.context.store;
    let dtlStringData = RestrictedPayeeStore.viewPageMaintenanceData
      ? JSON.parse(RestrictedPayeeStore.viewPageMaintenanceData.dtlString)
      : null;
    let funcDscp =
      RestrictedPayeeStore.viewPageMaintenanceData &&
      RestrictedPayeeStore.viewPageMaintenanceData.actnFunc.description;
    return (
               errorList={RestrictedPayeeStore.errors}
        isApproveReject
        funcDscp={funcDscp}
        hasBackButton
        backButtonLabel={strings.formatString(
          strings.global_approveobj,
          strings.global_restrictedpayeenm
        )}
        store={MaintenanceStore}
        modelNm={strings.global_payee}
        viewPanel={
                       isView={true}
            data={dtlStringData ? dtlStringData : null}
          />
        }
        onClickBack={() => {
          MaintenanceStore.resetRemarks();
          MaintenanceStore.errors = [];
          RestrictedPayeeStore.resetErrorList();
          MaintenanceStore.approveList = null;
          this.setState({ isForView: false });
          this.redirectTo(this.state.pages.initial);
        }}
        onClickApprove={() => {
          this.setState({ isForView: true });
          let data = [];
          data.push(RestrictedPayeeStore.viewPageMaintenanceData);
          this.onClickApprove(data, MaintenanceStore.remarks);
          MaintenanceStore.errors = [];
        }}
        onClickReject={() => {
          this.setState({ isForView: true });
          let data = [];
          data.push(RestrictedPayeeStore.viewPageMaintenanceData);
          this.checkIfHasRemarks(data);
          MaintenanceStore.errors = [];
        }}
      />
hasErrors(err);
        errCB && errCB(err);
      }
    );
  }

  _showViewPageForConfirmAck() @action
  validateApproval(validateApprovalReqModel, succCB, errCB) 
{
    const { RestrictedPayeeStore, MaintenanceStore } = console.log("Endpoint on restrictedPayeeStore.validateApproval");
    
this.context.store;
    let dtlStringData 
errors this.showViewPageConfirmAckData();
    return (
               fullView={true}
        errorList={RestrictedPayeeStore.errors}
        // isApproveReject
        hasBackButton
        backButtonLabel={
          this.state.prevPage == this.state.pages.ack
            ? strings.global_acknowledgement
            : strings.global_confirm
        }
        store={MaintenanceStore}
        modelNm={strings.global_payee}
        viewPanel={
                       isView={true}
            data={dtlStringData ? dtlStringData : null}
          />
        }
        onClickBack={() => {
          this.state.prevPage == this.state.pages.ack
            ? this.redirectTo(this.state.pages.ack)
            : this.redirectTo(this.state.pages.confirm);
        }}
      />
[];

    ClientMiddleware.post(
      ClientConfig.apiEndpoints.validateRestrictedPayeeApproval,
      validateApprovalReqModel,
      succCB,
      errCB
    );
  }

  _showAckForSingle() @action
  approveList(reqModel, succCB, errCB) 
{
    const { MaintenanceStore, RestrictedPayeeStore } = console.log("Endpoint on restrictedPayeeStore.approveList");

    ClientMiddleware.post(
      ClientConfig.apiEndpoints.restrictedPayeeApproveList,
      reqModel,
      succCB,
      err => {
        
this.context.store;
    let data = RestrictedPayeeStore.restrictedPayeeDtlString;
    let funcDscp =
      RestrictedPayeeStore.viewPageMaintenanceData &&
      RestrictedPayeeStore.viewPageMaintenanceData.actnFunc.description;
    return (
               isAck={true}
        isConfirm={false}
        funcDscp={funcDscp}
        columnHeaders={this._createDataForConfirmAck()}
        action={RestrictedPayeeStore.approvalAckProps.action}
        remarks={RestrictedPayeeStore.approvalAckProps.remarks}
        dataList={RestrictedPayeeStore.approvalAckProps.dataList}
        hasButtons
        modelName={strings.global_payee}
        backButtonLabel={strings.formatString(
          strings.button_middle_backxtopage,
          strings.formatString(
            strings.global_approveobj,
            strings.global_restrictedpayeenm
          )
        )}
        onClickBack={() => {
          MaintenanceStore.remarks = null;
          MaintenanceStore.approveList = null;
          RestrictedPayeeStore.resetApprovalFields();
          this.redirectTo(this.state.pages.initial);
          this.setState({
            isForView: false
          });
        }}
        viewPanel={
                       header={RestrictedPayeeStore.approvalAckProps.message}
            refNo={RestrictedPayeeStore.approvalAckProps.refNo}
            isConfirm={false}
            isAck={true}
            data={data ? data : null}
            store={MaintenanceStore}
            errorFeedback={MaintenanceStore.errors}
            hideStepper={true}
          />
        }
      />
    );
  }

  showViewPageConfirmAckData() {
    const { RestrictedPayeeStore } = this.context.store;
    return RestrictedPayeeStore.viewPageMaintenanceData
      ? JSON.parse(RestrictedPayeeStore.viewPageMaintenanceData.dtlString)
      : null;
  }

  handleCancel = () => {
    this.setState({
      showErrorModal: false,
      errorModalMsg: ""
    });
  };

  handleKeyDown = e => {
    const { MaintenanceStore } = this.context.store;
    MaintenanceStore.remarks = e.target.value;
  };

  checkIfHasRemarks = data => {
    const { MaintenanceStore, SettingsStore } = this.context.store;
    if (!MaintenanceStore.remarks) {
      let errorList = [
        strings.formatString(
          strings.feedback_bad_isrequired,
          strings.global_remarks
        )
      ];
      RestrictedPayeeStore.errors = errorList;
      this.setState({
        showErrorModal: true,
        errorModalMsg: errorList[0]
      });
      SettingsStore.isScreenLoading = false;
    } else {
      this.onClickReject(data, MaintenanceStore.remarks);
    }
  };

  render() {
    const { RestrictedPayeeStore, MaintenanceStore } = this.context.store;

    const actionButtons = (
      

        
                       labelField={strings.global_remarks}
            value={MaintenanceStore.remarks}
            placeHolder={strings.global_remarks}
            onChange={this.handleKeyDown}
            maxLength="255"
          />
        

        
          
        

                   approveMessage={strings.formatString(
            strings.global_approveobj,
            strings.global_restrictedpayeenm
          )}
          rejectMessage={strings.formatString(
            strings.global_rejectobj,
            strings.global_restrictedpayeenm
          )}
          onClickApprove={() => {
            this.setState({ isForView: true });
            let data = [];
            data.push(RestrictedPayeeStore.viewPageMaintenanceData);
            this.onClickApprove(data, MaintenanceStore.remarks);
            MaintenanceStore.errors = [];
          }}
          onClickReject={() => {
            this.setState({ isForView: true });
            let data = [];
            data.push(RestrictedPayeeStore.viewPageMaintenanceData);
            this.checkIfHasRemarks(data);
            MaintenanceStore.errors = [];
          }}
        />
      

    );

    const data = [
      { key: 0, content: this._showMaintenanceApprovalPanel() },
      { key: 1, content: this._showMaintenanceApprovalConfirmPanel() },
      { key: 2, content: this._showMaintenanceApprovalAckPanel() },
      { key: 3, content: this._showViewPage(actionButtons) },
      { key: 4, content: this._showViewPageForConfirmAck() },
      { key: 5, content: this._showAckForSingle() }
    ];

    return (
      
        
                   visible={this.state.showErrorModal}
          closable={true}
          onClose={this.handleCancel}
          onCancel={this.handleCancel}
          okButtonProps={{
            style: { display: "none" }
          }}
          cancelButtonProps={{
            style: { display: "none" }
          }}
          destroyOnClose={true}
          className="errorModalFeedback"
        >
          {this.state.showErrorModal ? (
            

                               class="swal2-icon swal2-error swal2-animate-error-icon"
                style={{ display: "flex" }}
              >
                
                  
                  
                
              

              {this.state.errorModalMsg}

            

          ) : null}
        
                   data={data}
          activeKey="key"
          activeValue={RestrictedPayeeStore.selectedMenuOnApprove}
        />
      
hasErrors(err);
        errCB && errCB(err);
      }
    );
  }
}

export default ApproveRestrictedPayeeCTR;
}