Skip to content

Commit

Permalink
fix(client): show errors in UI on TagPage
Browse files Browse the repository at this point in the history
  • Loading branch information
neopostmodern committed Aug 7, 2022
1 parent 43c882e commit a846b33
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions client/src/renderer/containers/TagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMutation, useQuery } from '@apollo/client';
import gql from 'graphql-tag';
import React, { useCallback } from 'react';
import { useParams } from 'react-router';
import FatalApolloError from '../components/FatalApolloError';
import NetworkOperationsIndicator from '../components/NetworkOperationsIndicator';
import NotesList from '../components/NotesList';
import TagForm from '../components/TagForm';
Expand Down Expand Up @@ -102,19 +103,26 @@ const TagPage: React.FC<{}> = () => {
[updateTag]
);

if (tagQuery.state === DataState.LOADING) {
return <ComplexLayout loading />;
}
if (tagQuery.state === DataState.ERROR) {
return (
<ComplexLayout>
<FatalApolloError query={tagQuery} />
</ComplexLayout>
);
}

return (
<ComplexLayout loading={tagQuery.state === DataState.LOADING}>
<ComplexLayout>
<NetworkOperationsIndicator
query={tagQuery}
mutation={updateTagMutation}
/>
{tagQuery.state === DataState.DATA && (
<>
<TagForm tag={tagQuery.data.tag} onSubmit={handleSubmit} />
<TagForm tag={tagQuery.data.tag} onSubmit={handleSubmit} />

<NotesList notes={tagQuery.data.tag.notes} />
</>
)}
<NotesList notes={tagQuery.data.tag.notes} />
</ComplexLayout>
);
};
Expand Down

0 comments on commit a846b33

Please sign in to comment.