Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. import gql from 'graphql-tag'
  2. import { Icon, Search, Segment, Dropdown, Header } from 'semantic-ui-react/dist/commonjs'
  3.  
  4. import { graphql, compose, Query, withApollo } from 'react-apollo'
  5.  
  6. export const GET_PATIENTS_BY_USER_ID = gql`
  7. query getPatientsByUser($pagination: PatientPagination!, $filter: ListFilter) {
  8. doctorPatients(pagination: $pagination, filter:$filter) {
  9. totalCount
  10. perPage
  11. page
  12. items {
  13. patientResearches {
  14. research {
  15. id
  16. title
  17. }
  18. }
  19. updatedAt
  20. }
  21. }
  22.  
  23. userResearches {
  24. activeResearches {
  25. ...ResearchBasicInfoParts
  26. }
  27. }
  28. }
  29. ${RESEARCH_BASIC_INFO_FRAGMENT}
  30. `
  31. class PatientList extends React.Component
  32.  
  33. constructor(props) {
  34. super(props)
  35.  
  36. this.state = {
  37. value: '',
  38.  
  39. }
  40. }
  41.  
  42.  
  43.  
  44. handleSearchChange = ({value}) => {
  45. this.setState({
  46. value
  47. })
  48.  
  49. }
  50. render(){
  51.  
  52. const {value} = this.state
  53.  
  54. return (
  55. <Query query={GET_PATIENTS_BY_USER_ID}
  56. variables={{
  57. filter: {
  58. sortBy: value
  59. },
  60. pagination: {
  61. perPage: 2,
  62. page: 1
  63. }
  64. }}>
  65. {({ loading, data, refetch, error }) => {
  66. if (loading) return <LoadingView />
  67. if (error) {
  68. return <ErrorView />
  69. }
  70.  
  71.  
  72. const { doctorPatients, userResearches } = data
  73. const { items: patients, page, perPage, totalCount} = doctorPatients
  74. console.log(doctorPatients)
  75. return (
  76. {
  77. patients.map(patient => (
  78. <Table.Row
  79. onClick={this.handleClickPatient(patient.id)}
  80. style={{cursor: 'pointer'}}
  81. key={`${patient.id}`}
  82. verticalAlign='middle'
  83. >
  84. <PatientListItem
  85. {...patient}
  86. />
  87. </Table.Row>
  88. ))
  89. }
  90.  
  91. </Query>
  92. )
  93. }
  94.  
  95. }
  96.  
  97.  
  98. export default compose(
  99. withApollo,
  100. graphql(ADD_PATIENT, {
  101. name: 'addPatient'
  102. })
  103. )(withRouter(PatientList))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement