import { useNavigate } from 'react-router-dom'; import { Item, ItemGroup } from "../../../../components/ui/item-group"; import { useAuthServiceContext } from '../../../../services'; import { useState } from 'react'; import { BodyStructure } from 'fhir/r4'; import { useFhirBodyStructures } from '../../../../hooks/useFhirBodyStructures.tsx'; import { AppSpinner, ScrollableTab } from '../../../../components'; import { ResourceListStatus } from '../../../../components/ui/resource-list-status'; import { Flex, FlexItem, FlexBlock } from '../../../../components/ui/flex'; import { Text } from '../../../../components/ui/text'; import { Spacer } from '../../../../components/ui/spacer'; // `Icon` and `warning` were BOTH already dead at HEAD (no ` { const navigate = useNavigate(); const { userRole, USER_ROLES } = useAuthServiceContext(); const { loading, error, clearError, bodyStructuresList, attempted } = useFhirBodyStructures(); const [selectedbodyStructure, setSelectedbodyStructure] = useState(); const [showDisplayModal, setShowDisplayModal] = useState(false); // The record's practice context: its own body structures under a named practice; the empty state speaks for the whole record. const practiceView = useRecordPracticeView(bodyStructuresList, recordPracticeId); useRetireOnPracticeChange(() => { setShowDisplayModal(false); setSelectedbodyStructure(undefined); }); const spacerMargin = '24px'; const viewBodyStructure = (bodyStructure: BodyStructure) => { setSelectedbodyStructure(bodyStructure); setShowDisplayModal(true); }; const editBodyStructure = (event: React.MouseEvent, bodyStructure: BodyStructure) => { event.stopPropagation(); navigate(bodyStructure.id as string, { relative: 'route' }); }; const addBodyStructure = () => { navigate('new', { relative: 'route' }); }; const isAuthorizedToEdit = () => { return userRole && [USER_ROLES.PRACTITIONER].includes(userRole as string); }; const renderContent = () => { return ( <> {loading ? ( ) : ( {practiceView.shown.length !== 0 && ( {practiceView.shown.map((bodyStructure: BodyStructure) => { return ( viewBodyStructure(bodyStructure)}> {bodyStructure.description} {isAuthorizedToEdit() && ( )} ); })} )} )} {/*{selectedbodyStructure && (*/} {/* {*/} {/* setShowDisplayModal(false);*/} {/* setSelectedbodyStructure(undefined);*/} {/* }}/>*/} {/*)}*/} ); }; const renderHeader = () => { return ( {isAuthorizedToEdit() && ( )} ); }; return (
{renderHeader()} {renderContent()}
); } export default BodyStructures;