Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { View } from 'native-base';
  3. import {withApollo } from 'react-apollo';
  4. import gql from 'graphql-tag';
  5. import _ from 'lodash';
  6. import OverlaySpinner from '../ui/overlaySpinner';
  7. import AddNoteSection from '../../components/tabs/requestTab/AddNoteSection';
  8. import { handleErrors } from '../../services';
  9.  
  10.  
  11. class AddNoteSectionContainer extends Component {
  12. constructor(props) {
  13. super(props);
  14. this.state = {
  15. categoryList: [],
  16. isOpenClose: false,
  17. notes: "",
  18. notesResponse:[]
  19. };
  20. }
  21.  
  22. addNoteChange = (event) => {
  23. this.setState({
  24. notes: event
  25. }, () => {
  26. });
  27. };
  28.  
  29. statusTextModification = (currentstatus) => {
  30. var status ="";
  31. if (currentstatus === "Pending"){
  32. status = "P"
  33. }else if(currentstatus === "Close"){
  34. status = "C"
  35. }else{
  36. status = "A"
  37. }
  38. return status;
  39. }
  40.  
  41. OnButtonClick = async (data) => {
  42. var status = "";
  43. const{navigation}=this.props;
  44. const{workFlowDetails,troubleTicketDetails} =
  45. navigation.state.params.ticketDetailsInfo;
  46. const workAgent_ID = workFlowDetails.currentNextActivity;
  47.  
  48. const currentStepPosition = workAgent_ID.filter((item) => {
  49. return item._activityStatus === "I"
  50. });
  51. const workAgentID = currentStepPosition.map(currentStepPosition => {
  52. return currentStepPosition._workAgent;
  53. });
  54. let workAgent_id=workAgentID[0];
  55. console.log("Props for note notes",workAgent_id);
  56.  
  57. if (navigation.state.params.currentStatus === "Pending"){
  58. status = "P"
  59. }else if(navigation.state.params.currentStatus === "Close"){
  60. status = "C"
  61. }else{
  62. status = "A"
  63. }
  64.  
  65. const mutationObj = `
  66. mutation createIncidentNote{
  67. createIncidentNote(
  68. input:{
  69. status: "${status}",
  70. incidentInitiator: "${data}",
  71. notes: "${this.state.notes}",
  72. userId: "${troubleTicketDetails.LoggedBy}",
  73. workAgentID: "${workAgent_id}",
  74. referenceNumber: "${navigation.state.params.referenceNumber}",
  75.  
  76. }){
  77. REQUEST_STATUS
  78. ABILLITY_REF_NUM
  79. SUCCESS_MESG_LANG_1
  80. SUCCESS_MESG_LANG_2
  81. }
  82. }
  83. `;
  84. try {
  85. const { data } = await this.props.client.mutate({
  86. mutation: gql(mutationObj)
  87. });
  88. // Here below is the code I am using .
  89. this.props.navigation.goBack()
  90.  
  91. } catch (e) {
  92. handleErrors(e, this.props.navigation);
  93. console.log('Error in Adding note', e);
  94. }
  95. };
  96.  
  97. render(){
  98. return(
  99. <View>
  100. <AddNoteSection
  101. {...this.props}
  102. addNoteChange={(text) => this.addNoteChange(text)}
  103. OnButtonClick={(data) => this.OnButtonClick(data)}
  104. />
  105. {/* {<OverlaySpinner color="#00678F" />} */}
  106. </View>
  107. )
  108. }
  109. }
  110. export default withApollo(AddNoteSectionContainer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement