Skip to main content
Glama
EditCoverage.tsx1.83 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { Button, Modal } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; import { showNotification } from '@mantine/notifications'; import { normalizeErrorString } from '@medplum/core'; import type { Coverage, Resource } from '@medplum/fhirtypes'; import { ResourceForm, useMedplum } from '@medplum/react'; import { IconCircleCheck, IconCircleOff } from '@tabler/icons-react'; import type { JSX } from 'react'; import { cleanResource } from '../utils'; interface EditCoverageProps { readonly coverage: Coverage; readonly onChange: (updatedCoverage: Coverage) => void; } export function EditCoverage({ coverage, onChange }: EditCoverageProps): JSX.Element { const medplum = useMedplum(); const [opened, { toggle, close }] = useDisclosure(false); const handleSubmit = async (newCoverage: Resource): Promise<void> => { try { // Update the coverage with the new details. We clean the resource in order to overwrite the necessary metadata const updatedCoverage = (await medplum.updateResource(cleanResource(newCoverage))) as Coverage; showNotification({ icon: <IconCircleCheck />, title: 'Success', message: 'Coverage updated', }); toggle(); onChange(updatedCoverage); } catch (err) { showNotification({ color: 'red', icon: <IconCircleOff />, title: 'Error', message: normalizeErrorString(err), }); } }; return ( <div> <Button fullWidth onClick={toggle}> Edit Coverage </Button> <Modal opened={opened} onClose={close} size="lg"> <ResourceForm defaultValue={coverage} onSubmit={handleSubmit} /> </Modal> </div> ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/medplum/medplum'

If you have feedback or need assistance with the MCP directory API, please join our Discord server