Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. TicketDetail where I call the api
  2.  
  3. import React from 'react'
  4. import DateDisplay from '../usercontainers/DateDisplay'
  5. import AssignTicket from '../ticketcomponents/AssignTicket'
  6. import CommentList from '../ticketcomponents/CommentList'
  7. import CreateComment from '../ticketcomponents/CreateComment'
  8. export const TicketDetailView = (props) => {
  9. console.log('tdv')
  10. return (
  11. <div>
  12. <p>Subject: {props.ticket.title}</p>
  13. <p>Description: {props.ticket.body}</p>
  14. <p>Submitted By: {props.ticket.created_by}</p>
  15. <p>Date Created: <DateDisplay date={props.ticket.date} /></p>
  16.  
  17. <AssignTicket ticket={props.ticket} user={props.user}>
  18. </AssignTicket>
  19. <CommentList ticket={props.ticket} user={props.user}
  20. commentCreated={props.commentCreated} />
  21. <CreateComment ticket={props.ticket} user={props.user}/>
  22. </div>
  23. )
  24. }
  25. export default TicketDetailView
  26.  
  27. import React from 'react'
  28. import DateDisplay from '../usercontainers/DateDisplay'
  29. import AssignTicket from '../ticketcomponents/AssignTicket'
  30. import CommentList from '../ticketcomponents/CommentList'
  31. import CreateComment from '../ticketcomponents/CreateComment'
  32. export const TicketDetailView = (props) => {
  33. console.log('tdv')
  34. return (
  35. <div>
  36.  
  37.  
  38. <p>Subject: {props.ticket.title}</p>
  39. <p>Description: {props.ticket.body}</p>
  40. <p>Submitted By: {props.ticket.created_by}</p>
  41. <p>Date Created: <DateDisplay date={props.ticket.date} /></p>
  42.  
  43. <AssignTicket ticket={props.ticket} user={props.user}>
  44. </AssignTicket>
  45. <CommentList ticket={props.ticket} user={props.user}
  46. commentCreated={props.commentCreated} />
  47. <CreateComment ticket={props.ticket} user={props.user}/>
  48. </div>
  49. )
  50. }
  51. export default TicketDetailView
  52.  
  53. import React from 'react'
  54. import * as actions from '../store/actions/ticketaction'
  55. import { withRouter } from 'react-router-dom'
  56. import { connect } from 'react-redux';
  57. import { withStyles } from '@material-ui/core/styles';
  58. import compose from 'recompose/compose';
  59. import TicketListView from '../ticketcontainers/TicketListView'
  60. const styles = theme => ({})
  61.  
  62.  
  63.  
  64. class CreateComment extends React.Component {
  65. handleSubmit = (e) => {
  66. // e.preventDefault();
  67. const date = Date.now()
  68. const user = this.props.user.username
  69. const ticket = this.props.ticket.id
  70. this.props.postComment(e.target.comment.value, date, user, ticket)
  71. };
  72.  
  73. render(){
  74. console.log(this.props)
  75. let commentStatus = null
  76. if(this.props.commentCreated){
  77. commentStatus = (
  78. <p>Your comment added</p>
  79. )
  80. }
  81. return(
  82. <form onSubmit={this.handleSubmit}>
  83. {commentStatus}
  84. <textarea
  85. name='comment'></textarea>
  86. <button
  87. type='submit'>Submit
  88. </button>
  89. </form>
  90.  
  91. )
  92. }
  93.  
  94. }
  95.  
  96. const mapStateToDispatch = (dispatch) => ({
  97. postComment: (comment, date, user, ticket) =>
  98. dispatch(actions.postComment(comment, date, user, ticket)),
  99. })
  100.  
  101. export default withRouter(connect(null, mapStateToDispatch)(CreateComment))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement