Skip to main content
Glama
PeriodInput.tsx1.71 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { Group } from '@mantine/core'; import type { Period } from '@medplum/fhirtypes'; import type { JSX } from 'react'; import { useContext, useMemo, useState } from 'react'; import { DateTimeInput } from '../DateTimeInput/DateTimeInput'; import { ElementsContext } from '../ElementsInput/ElementsInput.utils'; import type { ComplexTypeInputProps } from '../ResourcePropertyInput/ResourcePropertyInput.utils'; export interface PeriodInputProps extends ComplexTypeInputProps<Period> {} export function PeriodInput(props: PeriodInputProps): JSX.Element { const [value, setValue] = useState(props.defaultValue); const { getExtendedProps } = useContext(ElementsContext); const [startProps, endProps] = useMemo( () => ['start', 'end'].map((field) => getExtendedProps(props.path + '.' + field)), [getExtendedProps, props.path] ); function setValueWrapper(newValue: Period): void { setValue(newValue); if (props.onChange) { props.onChange(newValue); } } return ( <Group gap="xs" grow wrap="nowrap"> <DateTimeInput disabled={props.disabled || startProps?.readonly} name={props.name + '.start'} placeholder="Start" defaultValue={value?.start} onChange={(newValue) => setValueWrapper({ ...value, start: newValue })} /> <DateTimeInput disabled={props.disabled || endProps?.readonly} name={props.name + '.end'} placeholder="End" defaultValue={value?.end} onChange={(newValue) => setValueWrapper({ ...value, end: newValue })} /> </Group> ); }

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