-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch and display keys in a namespace
- Loading branch information
Showing
2 changed files
with
67 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useDataQuery } from '@dhis2/app-runtime' | ||
import React from 'react' | ||
import { useParams } from 'react-router-dom' | ||
import classes from '../../App.module.css' | ||
import i18n from '../../locales' | ||
import ErrorNotice from '../error/ErrorNotice' | ||
import CenteredLoader from '../loader/Loader' | ||
import ItemsTable from '../table/ItemsTable' | ||
import SearchField from './SearchField' | ||
|
||
interface QueryResults { | ||
results: [] | ||
} | ||
|
||
const KeysDataSection = ({ query }) => { | ||
const { namespace: currentNamespace } = useParams() | ||
|
||
const { error, loading, data } = useDataQuery<QueryResults>(query, { | ||
variables: { | ||
id: currentNamespace, | ||
}, | ||
}) | ||
|
||
if (error) { | ||
return <ErrorNotice /> | ||
} | ||
|
||
if (loading) { | ||
return <CenteredLoader /> | ||
} | ||
|
||
return ( | ||
<> | ||
<div className={classes.keysPanelMidSection}> | ||
<SearchField placeholder={i18n.t('Search keys')} /> | ||
</div> | ||
<div> | ||
{data && <ItemsTable data={data} label={i18n.t('Key')} />} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default KeysDataSection |