import styled from '@emotion/styled'; import Duration from 'sentry/components/duration'; import {PanelBody, PanelItem} from 'sentry/components/panels'; import TimeSince from 'sentry/components/timeSince'; import {Tooltip} from 'sentry/components/tooltip'; import {tct} from 'sentry/locale'; import space from 'sentry/styles/space'; import {defined} from 'sentry/utils'; import useApiRequests from 'sentry/utils/useApiRequests'; import {CheckInStatus, Monitor} from 'sentry/views/monitors/types'; import CheckInIcon from './checkInIcon'; type CheckIn = { dateCreated: string; duration: number; id: string; status: CheckInStatus; }; type Props = { monitor: Monitor; orgId: string; }; type State = { checkInList: CheckIn[]; }; const MonitorCheckIns = ({monitor, orgId}: Props) => { const {data, hasError, renderComponent} = useApiRequests({ endpoints: [ [ 'checkInList', `/organizations/${orgId}/monitors/${monitor.id}/checkins/`, {query: {per_page: '10'}}, ], ], }); const renderedComponent = renderComponent( {data.checkInList?.map(checkIn => ( {defined(checkIn.duration) && } ))} ); return hasError ? {renderedComponent} : renderedComponent; }; export default MonitorCheckIns; const DivMargin = styled('div')` margin-right: ${space(2)}; `; const CheckInIconWrapper = styled(DivMargin)` display: flex; align-items: center; `; const TimeSinceWrapper = styled(DivMargin)` font-variant-numeric: tabular-nums; `; const DurationWrapper = styled('div')` font-variant-numeric: tabular-nums; `; const ErrorWrapper = styled('div')` margin: ${space(3)} ${space(3)} 0; `;