Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. import { Mutation, Query } from "react-apollo";
  2. import gql from "graphql-tag";
  3. import PropTypes from "prop-types";
  4. import { withStyles } from "@material-ui/core/styles";
  5. import DialogTitle from "@material-ui/core/DialogTitle";
  6. import Dialog from "@material-ui/core/Dialog";
  7. import Avatar from "@material-ui/core/Avatar";
  8. import List from "@material-ui/core/List";
  9. import ListItem from "@material-ui/core/ListItem";
  10. import ListItemAvatar from "@material-ui/core/ListItemAvatar";
  11. import ListItemText from "@material-ui/core/ListItemText";
  12. import PersonIcon from "@material-ui/icons/Person";
  13. import AddIcon from "@material-ui/icons/Add";
  14. import blue from "@material-ui/core/colors/blue";
  15.  
  16. const emails = [
  17. // can be an object or array - see jsfiddle below
  18. { name: "ankit", id: "1e1eafa8-ea40-6f43-6541-5c7f539612f2" },
  19. { name: "rigal", id: "b62b9815-b1c7-dc4a-7539-59a68b95ddf5" }
  20. ];
  21. const styles = {
  22. avatar: {
  23. backgroundColor: blue[100],
  24. color: blue[600]
  25. }
  26. };
  27.  
  28. const REASSIGN_OPERATIONS = gql`
  29. mutation todo_operations($id: String, $contact_id_c: String) {
  30. todo_operations(id: $id, contact_id_c: $contact_id_c) {
  31. contact_id_c
  32. }
  33. }
  34. `;
  35.  
  36. class UserList extends React.Component {
  37. state = {
  38. contactid: ""
  39. };
  40.  
  41. handleClose = () => {
  42. this.props.onClose(this.props.selectedValue);
  43. };
  44.  
  45. handleListItemClick = value => {
  46. this.setState({ contactid: value });
  47. this.props.onClose(value);
  48. };
  49.  
  50. render() {
  51. const {
  52. classes,
  53. onClose,
  54. selectedValue,
  55. userTaskId,
  56. ...other
  57. } = this.props;
  58.  
  59. const changeOwnerQueryVars = {
  60. id: userTaskId,
  61. contact_id_c: selectedValue
  62. };
  63.  
  64. return (
  65. <Dialog
  66. onClose={this.handleClose}
  67. aria-labelledby="simple-dialog-title"
  68. {...other}
  69. >
  70. <DialogTitle id="simple-dialog-title">Reassign Task</DialogTitle>
  71. <div>
  72. <List>
  73. {emails.map(email => (
  74. <ListItem
  75. button
  76. onClick={() => this.handleListItemClick(email.id)}
  77. key={email.id}
  78. >
  79. <ListItemAvatar>
  80. <Avatar className={classes.avatar}>
  81. <PersonIcon />
  82. </Avatar>
  83. </ListItemAvatar>
  84. <ListItemText primary={email.name} />
  85. </ListItem>
  86. ))}
  87. </List>
  88. </div>
  89. </Dialog>
  90. );
  91. }
  92. }
  93.  
  94. UserList.propTypes = {
  95. classes: PropTypes.object.isRequired,
  96. onClose: PropTypes.func,
  97. selectedValue: PropTypes.string,
  98. userTaskId: PropTypes.string
  99. };
  100.  
  101. export default withStyles(styles)(UserList, emails);
  102.  
  103. <div className={classes.width5}>
  104. <div className={pendingStatusClass}>
  105. <AssignmentInd
  106. //onClick={this.handleClickDialogOpen}
  107. onClick={event => {
  108. this.handleClickDialogOpen(task.id);
  109. }}
  110. />
  111. <Mutation mutation={COMPLETE_TASK_OPERATIONS}>
  112. {(todo_operations, { loading, error }) => (
  113. <UserList
  114. selectedValue={this.state.selectedValue}
  115. open={this.state.openreport}
  116. onClose={this.handleDialogClose}
  117. userTaskId={this.state.userTaskId}
  118. />
  119. )}
  120. </Mutation>
  121. </div>
  122. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement