diff --git a/components/dataset/Org.tsx b/components/dataset/Org.tsx
index 0971532c..b8751dde 100644
--- a/components/dataset/Org.tsx
+++ b/components/dataset/Org.tsx
@@ -1,20 +1,53 @@
import Link from 'next/link';
+import ErrorMessage from '../Error';
+import { NetworkStatus } from 'apollo-client';
+import { useQuery } from '@apollo/react-hooks';
+import gql from 'graphql-tag';
-export default function Org({ org }) {
+export const GET_ORG_QUERY = gql`
+ query dataset($id: String!) {
+ dataset(id: $id) {
+ result {
+ organization {
+ name
+ title
+ image_url
+ }
+ }
+ }
+ }
+`;
+
+export default function Org({ variables }) {
+ const { loading, error, data, fetchMore, networkStatus } = useQuery(
+ GET_ORG_QUERY,
+ {
+ variables,
+ // Setting this value to true will make the component rerender when
+ // the "networkStatus" changes, so we are able to know if it is fetching
+ // more data
+ notifyOnNetworkStatusChange: true,
+ }
+ );
+
+ if (error) return ;
+ if (loading) return
Loading
;
+
+ const { organization } = data.dataset.result;
return (
<>
- {org ? (
+ {organization ? (
<>
-
+
- {org.title || org.name}
+ {organization.title || organization.name}
>
diff --git a/components/dataset/Resources.tsx b/components/dataset/Resources.tsx
index e4753de1..93a01e17 100644
--- a/components/dataset/Resources.tsx
+++ b/components/dataset/Resources.tsx
@@ -1,6 +1,43 @@
import Link from 'next/link';
+import ErrorMessage from '../Error';
+import { NetworkStatus } from 'apollo-client';
+import { useQuery } from '@apollo/react-hooks';
+import gql from 'graphql-tag';
+
+export const DEFAULT_DATASET_QUERY = gql`
+ query dataset($id: String!) {
+ dataset(id: $id) {
+ result {
+ name
+ resources {
+ name
+ title
+ format
+ created
+ last_modified
+ }
+ }
+ }
+ }
+`;
+
+export default function Resources({ variables }) {
+ const { loading, error, data, fetchMore, networkStatus } = useQuery(
+ DEFAULT_DATASET_QUERY,
+ {
+ variables,
+ // Setting this value to true will make the component rerender when
+ // the "networkStatus" changes, so we are able to know if it is fetching
+ // more data
+ notifyOnNetworkStatusChange: true,
+ }
+ );
+
+ if (error) return ;
+ if (loading) return
Loading
;
+
+ const { result } = data.dataset;
-export default function Resources({ datapackage }) {
return (
<>