Skip to main content
Glama
AttachmentInput.tsx1.66 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { Button } from '@mantine/core'; import type { Attachment, Reference } from '@medplum/fhirtypes'; import type { JSX, MouseEvent } from 'react'; import { useState } from 'react'; import { AttachmentButton } from '../AttachmentButton/AttachmentButton'; import { AttachmentDisplay } from '../AttachmentDisplay/AttachmentDisplay'; import type { ComplexTypeInputProps } from '../ResourcePropertyInput/ResourcePropertyInput.utils'; import { killEvent } from '../utils/dom'; export interface AttachmentInputProps extends ComplexTypeInputProps<Attachment> { readonly arrayElement?: boolean; readonly securityContext?: Reference; readonly onChange?: (value: Attachment | undefined) => void; } export function AttachmentInput(props: AttachmentInputProps): JSX.Element { const [value, setValue] = useState(props.defaultValue); function setValueWrapper(newValue: Attachment | undefined): void { setValue(newValue); if (props.onChange) { props.onChange(newValue); } } if (value) { return ( <> <AttachmentDisplay value={value} maxWidth={200} /> <Button disabled={props.disabled} onClick={(e: MouseEvent) => { killEvent(e); setValueWrapper(undefined); }} > Remove </Button> </> ); } return ( <AttachmentButton disabled={props.disabled} securityContext={props.securityContext} onUpload={setValueWrapper}> {(props) => <Button {...props}>Upload...</Button>} </AttachmentButton> ); }

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