Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101import {View} from 'react-native'import {useLingui} from '@lingui/react/macro'import {isBefore, subYears} from 'date-fns'
import {atoms as a, useTheme} from '#/alf'import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRightIcon} from '#/components/icons/Chevron'import {Link} from '#/components/Link'import {Text} from '#/components/Typography'
export function ReportRow({ subject, action, date, dateEnd, dateLabel, to, unread,}: { subject: string action?: string date: Date dateEnd?: Date dateLabel?: string to: React.ComponentProps<typeof Link>['to'] unread?: boolean}) { const t = useTheme() const {i18n, t: l} = useLingui()
const shouldShowYear = isBefore(date, subYears(new Date(), 1))
return ( <Link label={l`View report details: ${subject}`} to={to} hoverStyle={ unread ? {backgroundColor: t.palette.primary_50} : t.atoms.bg_contrast_25 } style={[ a.flex_row, a.w_full, a.align_center, a.justify_between, a.gap_sm, a.p_lg, { backgroundColor: unread ? t.palette.primary_25 : undefined, }, ]}> <View style={[a.flex_1, a.gap_2xs, {minWidth: 0}]}> <Text emoji style={[a.text_md, unread ? a.font_semi_bold : a.font_medium]}> {subject} </Text> {action ? ( <Text style={[a.text_sm, t.atoms.text_contrast_high]}>{action}</Text> ) : undefined} <Text style={[a.text_sm, t.atoms.text_contrast_medium]}> {dateLabel ? `${dateLabel} ` : undefined} {dateEnd ? `${i18n.date(date, { month: 'short', day: 'numeric', year: shouldShowYear ? 'numeric' : undefined, })} – ${i18n.date(dateEnd, { month: 'short', day: 'numeric', year: shouldShowYear ? 'numeric' : undefined, })}` : i18n.date(date, { month: 'short', day: 'numeric', year: shouldShowYear ? 'numeric' : undefined, })} </Text> </View> <View style={[ a.flex_row, a.flex_shrink_0, a.align_center, a.justify_center, a.gap_sm, ]}> {unread ? ( <View style={[ a.rounded_full, {height: 8, width: 8, backgroundColor: t.palette.primary_500}, ]} /> ) : undefined} <ChevronRightIcon size="md" style={[t.atoms.text_contrast_medium]} /> </View> </Link> )}