Skip to content

Commit

Permalink
Replace List with Bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscoder committed Nov 26, 2024
1 parent 01e26b6 commit 2ab082b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/uberComponents/ResourceListPage/actions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { t, Trans } from '@lingui/macro';
import { Button, notification } from 'antd';
import { List, Resource } from 'fhir/r4b';
import { Bundle, Resource } from 'fhir/r4b';
import { useNavigate } from 'react-router-dom';

import { ModalTrigger } from 'src/components/ModalTrigger';
Expand Down Expand Up @@ -105,12 +105,12 @@ export function HeaderQuestionnaireAction({ action, reload }: { action: Question

export function BatchQuestionnaireAction<R extends Resource>({
action,
list,
bundle,
reload,
disabled,
}: {
action: QuestionnaireActionType;
list: List;
bundle: Bundle<R>;
reload: () => void;
disabled?: boolean;
}) {
Expand All @@ -128,8 +128,8 @@ export function BatchQuestionnaireAction<R extends Resource>({
questionnaireLoader={questionnaireIdLoader(action.questionnaireId)}
launchContextParameters={[
{
name: 'List',
resource: list,
name: 'Bundle',
resource: bundle as Bundle,
},
]}
onSuccess={() => {
Expand Down
15 changes: 8 additions & 7 deletions src/uberComponents/ResourceListPage/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bundle, List, Resource } from 'fhir/r4b';
import { Bundle, Resource } from 'fhir/r4b';
import { useMemo, useState } from 'react';

import { SearchParams } from '@beda.software/fhir-react';
Expand Down Expand Up @@ -44,11 +44,12 @@ export function useResourceListPage<R extends Resource>(
bundle: bundle as Bundle,
})),
);
const selectedResourcesList: List = {
resourceType: 'List',
status: 'current',
mode: 'working',
entry: isSuccess(recordResponse) ? recordResponse.data.map(({ resource }) => ({ item: resource })) : [],
const selectedResourcesBundle: Bundle<R> = {
resourceType: 'Bundle',
type: 'collection',
entry: isSuccess(recordResponse)
? recordResponse.data.map(({ resource }) => ({ resource: resource as R }))
: [],
};

return {
Expand All @@ -58,7 +59,7 @@ export function useResourceListPage<R extends Resource>(
handleTableChange,
selectedRowKeys,
setSelectedRowKeys,
selectedResourcesList,
selectedResourcesBundle,
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/uberComponents/ResourceListPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ interface ResourceListPageProps<R extends Resource> {
* Batch actions that are available when rows are selected
* (for example, delete multiple organizations)
*
* NOTE: Theoretically getHeaderActions can accept selected resources List
* NOTE: Theoretically getHeaderActions can accept selected resources Bundle
*/
getBatchActions?: () => Array<QuestionnaireActionType>;
}
Expand All @@ -100,7 +100,7 @@ export function ResourceListPage<R extends Resource>({
handleTableChange,
selectedRowKeys,
setSelectedRowKeys,
selectedResourcesList,
selectedResourcesBundle,
} = useResourceListPage(resourceType, extractPrimaryResources, columnsFilterValues, searchParams ?? {});

const headerActions = getHeaderActions?.() ?? [];
Expand Down Expand Up @@ -131,10 +131,10 @@ export function ResourceListPage<R extends Resource>({
<Row justify="start" align="middle" gutter={[8, 16]}>
{batchActions.map((action, index) => (
<Col key={index}>
<BatchQuestionnaireAction
<BatchQuestionnaireAction<R>
action={action}
reload={pagerManager.reload}
list={selectedResourcesList}
bundle={selectedResourcesBundle}
disabled={!selectedRowKeys.length}
/>
</Col>
Expand Down

0 comments on commit 2ab082b

Please sign in to comment.