-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
948 additions
and
1,562 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
104 changes: 52 additions & 52 deletions
104
src/modules/Main/components/MainArea/components/DataArea/DataArea.tsx
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 |
---|---|---|
@@ -1,57 +1,57 @@ | ||
import { FullPageLoader } from '../../../../../../shared/components/Loaders' | ||
import { colors, Pagination } from '@dhis2/ui' | ||
import i18n from '@dhis2/d2-i18n' | ||
import { AddButton } from '../AddButton' | ||
import React from 'react' | ||
import { useCategoryContext } from '../DataProvider' | ||
import { isEmpty } from 'lodash' | ||
import { DataCard } from './components/DataCard' | ||
import { ViewModalProvider } from '../../../../../../shared/components/ViewModal' | ||
import { FullPageLoader } from "../../../../../../shared/components/Loaders"; | ||
import { colors, Pagination } from "@dhis2/ui"; | ||
import i18n from "@dhis2/d2-i18n"; | ||
import { AddButton } from "../AddButton"; | ||
import React from "react"; | ||
import { useCategoryContext } from "../DataProvider"; | ||
import { isEmpty } from "lodash"; | ||
import { DataCard } from "./components/DataCard"; | ||
import { ViewModalProvider } from "../../../../../../shared/components/ViewModal"; | ||
|
||
export function DataArea () { | ||
const { | ||
loading, | ||
category, | ||
categoryData, | ||
refetch, | ||
error, | ||
...pagination | ||
} = useCategoryContext() | ||
export function DataArea() { | ||
const { loading, category, categoryData, refetch, error, ...pagination } = | ||
useCategoryContext(); | ||
|
||
if (loading) { | ||
return ( | ||
<FullPageLoader/> | ||
) | ||
} | ||
if (loading) { | ||
return <FullPageLoader />; | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div className="column w-100 h-100 align-center center gap-16"> | ||
<h1 style={{ color: colors.grey800 }}>{i18n.t('There was an error loading the data.')}</h1> | ||
</div> | ||
) | ||
} | ||
if (isEmpty(categoryData)) { | ||
return ( | ||
<div className="column w-100 h-100 align-center center gap-16"> | ||
<h1 style={{ color: colors.grey800 }}>{i18n.t('There is no data for the the selected dimensions.')}</h1> | ||
<AddButton primary/> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<div className="column gap-32"> | ||
<ViewModalProvider> | ||
{ | ||
categoryData?.map((data, index) => ( | ||
<DataCard index={index} refetch={refetch} instanceConfig={category} | ||
key={`${data.trackedEntity}-card`} | ||
data={data}/>)) | ||
} | ||
</ViewModalProvider> | ||
<Pagination {...pagination} /> | ||
</div> | ||
) | ||
if (error) { | ||
return ( | ||
<div className="column w-100 h-100 align-center center gap-16"> | ||
<h1 style={{ color: colors.grey800 }}> | ||
{i18n.t("There was an error loading the data.")} | ||
</h1> | ||
</div> | ||
); | ||
} | ||
if (isEmpty(categoryData)) { | ||
return ( | ||
<div className="column w-100 h-100 align-center center gap-16"> | ||
<h1 style={{ color: colors.grey800 }}> | ||
{i18n.t( | ||
"There is no data for the the selected dimensions.", | ||
)} | ||
</h1> | ||
<AddButton primary /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="column gap-32"> | ||
<ViewModalProvider> | ||
{categoryData?.map((data, index) => ( | ||
<DataCard | ||
index={index} | ||
refetch={refetch} | ||
instanceConfig={category} | ||
key={`${data.trackedEntity}-card`} | ||
data={data} | ||
/> | ||
))} | ||
</ViewModalProvider> | ||
<Pagination {...pagination} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.