Skip to content

Commit

Permalink
Add prototype of reports for uber components
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscoder committed Dec 19, 2024
1 parent 9a4b669 commit e7191d4
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/uberComponents/ResourceListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import { plural, Trans } from '@lingui/macro';
import { Empty, Row, Col, Button } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import { Bundle, ParametersParameter, Resource } from 'fhir/r4b';
import { useMemo } from 'react';

import { formatError, SearchParams } from '@beda.software/fhir-react';
import { isFailure, isLoading, isSuccess } from '@beda.software/remote-data';

import { BasePageContent, BasePageHeader } from 'src/components/BaseLayout';
import { SearchBar } from 'src/components/SearchBar';
import { useSearchBar } from 'src/components/SearchBar/hooks';
import { isTableFilter } from 'src/components/SearchBar/utils';
import { SpinIndicator } from 'src/components/Spinner';
import { Table } from 'src/components/Table';
import { populateTableColumnsWithFiltersAndSorts } from 'src/components/Table/utils';
import { Title, Text } from 'src/components/Typography';

import {
Expand All @@ -28,16 +31,18 @@ import {
export { navigationAction, customAction, questionnaireAction } from './actions';
import { useResourceListPage } from './hooks';
import { SearchBarColumn } from '../../components/SearchBar/types';
import { populateTableColumnsWithFiltersAndSorts } from 'src/components/Table/utils';
import { isTableFilter } from 'src/components/SearchBar/utils';
import { useMemo } from 'react';

type RecordType<R extends Resource> = { resource: R; bundle: Bundle };

interface TableManager {
reload: () => void;
}

interface ReportColumn {
title: React.ReactNode;
value: React.ReactNode;
}

interface ResourceListPageProps<R extends Resource> {
/* Page header title (for example, Organizations) */
headerTitle: string;
Expand Down Expand Up @@ -90,6 +95,18 @@ interface ResourceListPageProps<R extends Resource> {
* Default launch context that will be added to all questionnaires
*/
defaultLaunchContext?: ParametersParameter[];

/**
* EXPERIMENTAL FEATURE. The interface might be changed
* TODO: https://github.com/beda-software/fhir-emr/issues/414
*/
// loadReportBundle?: (searchParams: SearchParams) => Promise<RemoteDataResult<Bundle>>

/**
* EXPERIMENTAL FEATURE. The interface might be changed
* TODO: https://github.com/beda-software/fhir-emr/issues/414
*/
getReportColumns?: (bundle: Bundle, reportBundle?: Bundle) => Array<ReportColumn>;
}

export function ResourceListPage<R extends Resource>({
Expand All @@ -106,10 +123,9 @@ export function ResourceListPage<R extends Resource>({
}: ResourceListPageProps<R>) {
const allFilters = getFilters?.() ?? [];

const { columnsFilterValues, onChangeColumnFilter, onResetFilters } =
useSearchBar({
columns: allFilters ?? [],
});
const { columnsFilterValues, onChangeColumnFilter, onResetFilters } = useSearchBar({
columns: allFilters ?? [],
});
const tableFilterValues = useMemo(
() => columnsFilterValues.filter((filter) => isTableFilter(filter)),
[JSON.stringify(columnsFilterValues)],
Expand Down

0 comments on commit e7191d4

Please sign in to comment.