From ff134a02f901da9424f11acbbdda94aea7a6857c Mon Sep 17 00:00:00 2001 From: Tavares Hansen Date: Mon, 3 Aug 2020 19:21:09 -0700 Subject: [PATCH] [refactor][x]: move reusable ErrorMessage component to _shared --- components/{ => _shared}/Error.tsx | 0 components/_shared/Table.tsx | 3 ++- components/_shared/index.ts | 4 ++++ components/dataset/Org.tsx | 2 +- components/home/Recent.tsx | 2 +- components/resource/DataExplorer.tsx | 2 +- components/search/List.tsx | 2 +- components/search/Total.tsx | 2 +- components/static/List.tsx | 2 +- components/static/Page.tsx | 2 +- components/static/Post.tsx | 2 +- 11 files changed, 14 insertions(+), 9 deletions(-) rename components/{ => _shared}/Error.tsx (100%) create mode 100644 components/_shared/index.ts diff --git a/components/Error.tsx b/components/_shared/Error.tsx similarity index 100% rename from components/Error.tsx rename to components/_shared/Error.tsx diff --git a/components/_shared/Table.tsx b/components/_shared/Table.tsx index 0f824191..a0869498 100644 --- a/components/_shared/Table.tsx +++ b/components/_shared/Table.tsx @@ -24,7 +24,8 @@ const Table: React.FC = ({ columns, data, className }) => { {columns.map(({ key, render }) => ( {(render && typeof render === 'function' && render(item)) || - item[key]} + item[key] || + ''} ))} diff --git a/components/_shared/index.ts b/components/_shared/index.ts new file mode 100644 index 00000000..9d5cf16c --- /dev/null +++ b/components/_shared/index.ts @@ -0,0 +1,4 @@ +import Table from './Table'; +import ErrorMessage from './Error'; + +export { Table, ErrorMessage }; diff --git a/components/dataset/Org.tsx b/components/dataset/Org.tsx index 6b290574..69314426 100644 --- a/components/dataset/Org.tsx +++ b/components/dataset/Org.tsx @@ -1,6 +1,6 @@ import Link from 'next/link'; import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_ORG_QUERY } from '../../graphql/queries'; export default function Org({ variables }) { diff --git a/components/home/Recent.tsx b/components/home/Recent.tsx index 351c98b4..c67f7281 100644 --- a/components/home/Recent.tsx +++ b/components/home/Recent.tsx @@ -1,6 +1,6 @@ import Link from 'next/link'; import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { SEARCH_QUERY } from '../../graphql/queries'; function Recent() { diff --git a/components/resource/DataExplorer.tsx b/components/resource/DataExplorer.tsx index 7cba7853..7062a933 100644 --- a/components/resource/DataExplorer.tsx +++ b/components/resource/DataExplorer.tsx @@ -1,5 +1,5 @@ import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_RESOURCES_QUERY } from '../../graphql/queries'; export default function DataExplorer({ variables }) { diff --git a/components/search/List.tsx b/components/search/List.tsx index 49e291ec..b13e1f85 100644 --- a/components/search/List.tsx +++ b/components/search/List.tsx @@ -1,6 +1,6 @@ import { useQuery } from '@apollo/react-hooks'; import Item from './Item'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { SEARCH_QUERY } from '../../graphql/queries'; export default function List({ variables }) { diff --git a/components/search/Total.tsx b/components/search/Total.tsx index ecc414e0..0e688021 100644 --- a/components/search/Total.tsx +++ b/components/search/Total.tsx @@ -1,5 +1,5 @@ import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_TOTAL_COUNT_QUERY } from '../../graphql/queries'; export default function Total({ variables }) { diff --git a/components/static/List.tsx b/components/static/List.tsx index f870d61c..db73b895 100644 --- a/components/static/List.tsx +++ b/components/static/List.tsx @@ -1,6 +1,6 @@ import parse from 'html-react-parser'; import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_POSTS_QUERY } from '../../graphql/queries'; export default function List() { diff --git a/components/static/Page.tsx b/components/static/Page.tsx index c0db6749..81c4122f 100644 --- a/components/static/Page.tsx +++ b/components/static/Page.tsx @@ -1,6 +1,6 @@ import parse from 'html-react-parser'; import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_PAGE_QUERY } from '../../graphql/queries'; export default function Page({ variables }) { diff --git a/components/static/Post.tsx b/components/static/Post.tsx index c88dcc52..a698e1b1 100644 --- a/components/static/Post.tsx +++ b/components/static/Post.tsx @@ -1,6 +1,6 @@ import parse from 'html-react-parser'; import { useQuery } from '@apollo/react-hooks'; -import ErrorMessage from '../Error'; +import { ErrorMessage } from '../_shared'; import { GET_PAGE_QUERY } from '../../graphql/queries'; export default function Post({ variables }) {