ComplexData-MILA / HTUI

Apache License 2.0
0 stars 0 forks source link

Resolve multi-hook issue #1

Closed jacobdanovitch closed 3 years ago

jacobdanovitch commented 3 years ago

Re: Graph.js#L65:89

-  const defaultFirstName = 'Amanda'
-  const defaultLastName = 'Alexander'
+ let name = 'Amanda', surname =  'Alexander'

  const {
    loading: loadingPerson,
    data: dataPerson,
    error: errorPerson,
  } = useQuery(GET_PERSON, { variables: { filter: getFilter() } })

+  if (!loadingPerson){
+    { name, surName } = {...dataPerson.people[0]}
+  }

  const { loading, data, error } = useQuery(GET_FILE, {
    variables: {
-      nameInput: dataPerson
-        ? dataPerson.people[0]
-          ? dataPerson.people[0].name
-          : defaultFirstName
-        : defaultFirstName,
-      surnameInput: dataPerson
-        ? dataPerson.people[0]
-          ? dataPerson.people[0].surname
-          : defaultLastName
-        : defaultLastName,
+      nameInput: name
+      surnameInput: surName
    },
  })
-  if (error || errorPerson) return <p>Error</p>
-  if (loading || loadingPerson) return <p>Loading</p>
+  if (error) return <p>Error</p>
+  if (loading) return <p>Loading</p>
  let graphData = JSON.parse(data.response)

Also maybe rename GET_FILE to GET_GRAPH.