Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { View } from 'native-base';
- import {withApollo } from 'react-apollo';
- import gql from 'graphql-tag';
- import _ from 'lodash';
- import OverlaySpinner from '../ui/overlaySpinner';
- import AddNoteSection from '../../components/tabs/requestTab/AddNoteSection';
- import { handleErrors } from '../../services';
- class AddNoteSectionContainer extends Component {
- constructor(props) {
- super(props);
- this.state = {
- categoryList: [],
- isOpenClose: false,
- notes: "",
- notesResponse:[]
- };
- }
- addNoteChange = (event) => {
- this.setState({
- notes: event
- }, () => {
- });
- };
- statusTextModification = (currentstatus) => {
- var status ="";
- if (currentstatus === "Pending"){
- status = "P"
- }else if(currentstatus === "Close"){
- status = "C"
- }else{
- status = "A"
- }
- return status;
- }
- OnButtonClick = async (data) => {
- var status = "";
- const{navigation}=this.props;
- const{workFlowDetails,troubleTicketDetails} =
- navigation.state.params.ticketDetailsInfo;
- const workAgent_ID = workFlowDetails.currentNextActivity;
- const currentStepPosition = workAgent_ID.filter((item) => {
- return item._activityStatus === "I"
- });
- const workAgentID = currentStepPosition.map(currentStepPosition => {
- return currentStepPosition._workAgent;
- });
- let workAgent_id=workAgentID[0];
- console.log("Props for note notes",workAgent_id);
- if (navigation.state.params.currentStatus === "Pending"){
- status = "P"
- }else if(navigation.state.params.currentStatus === "Close"){
- status = "C"
- }else{
- status = "A"
- }
- const mutationObj = `
- mutation createIncidentNote{
- createIncidentNote(
- input:{
- status: "${status}",
- incidentInitiator: "${data}",
- notes: "${this.state.notes}",
- userId: "${troubleTicketDetails.LoggedBy}",
- workAgentID: "${workAgent_id}",
- referenceNumber: "${navigation.state.params.referenceNumber}",
- }){
- REQUEST_STATUS
- ABILLITY_REF_NUM
- SUCCESS_MESG_LANG_1
- SUCCESS_MESG_LANG_2
- }
- }
- `;
- try {
- const { data } = await this.props.client.mutate({
- mutation: gql(mutationObj)
- });
- // Here below is the code I am using .
- this.props.navigation.goBack()
- } catch (e) {
- handleErrors(e, this.props.navigation);
- console.log('Error in Adding note', e);
- }
- };
- render(){
- return(
- <View>
- <AddNoteSection
- {...this.props}
- addNoteChange={(text) => this.addNoteChange(text)}
- OnButtonClick={(data) => this.OnButtonClick(data)}
- />
- {/* {<OverlaySpinner color="#00678F" />} */}
- </View>
- )
- }
- }
- export default withApollo(AddNoteSectionContainer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement