Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 31x 2x | // The current tenancy's lease on the Tenancy page (openspec: documents,
// "The lease on the tenancy page"): the leases naming it, each opening its
// details page, or a note that the signed lease can be kept with the flat's
// documents. Owners get the add action from the route.
import Box from '@mui/material/Box'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import type { ReactNode } from 'react'
import type { DocumentRow } from '#/features/documents/document.repository.server'
import { formatDate } from '#/lib/format'
import { m } from '#/paraglide/messages.js'
import { colors, radii } from '#/theme/tokens'
interface Props {
leases: readonly DocumentRow[]
/** Wraps a lease's row in a link to its details page. */
link: (lease: DocumentRow, row: ReactNode) => ReactNode
/** Owners only: the link that adds a lease. */
add?: ReactNode
}
export function LeaseCard(props: Props) {
return (
<Stack
component="section"
aria-labelledby="lease-title"
sx={{
bgcolor: 'background.paper',
border: `1px solid ${colors.cardBorder}`,
borderRadius: `${String(radii.card)}px`,
gap: 0.75,
px: 2,
py: 1.75,
}}
>
<Typography
id="lease-title"
component="h2"
sx={{ fontSize: 15, fontWeight: 900 }}
>
{m.lease_card_title()}
</Typography>
{props.leases.length === 0 ? (
<Typography variant="body2" color="text.secondary">
{m.lease_card_none()}
</Typography>
) : (
<Box component="ul" sx={{ m: 0, p: 0, listStyle: 'none' }}>
{props.leases.map((lease, i) => (
<Box
key={lease.id}
component="li"
sx={{
borderTop: i === 0 ? 'none' : `1px solid ${colors.divider}`,
}}
>
{props.link(
lease,
<Stack sx={{ minHeight: 56, justifyContent: 'center' }}>
<Typography sx={{ fontSize: 14, fontWeight: 900 }}>
{lease.name}
</Typography>
<Typography variant="body2" color="text.secondary">
{m.lease_card_line({
date: formatDate(lease.date),
type:
lease.contentType === 'application/pdf'
? m.documents_type_pdf()
: m.documents_type_image(),
})}
</Typography>
</Stack>,
)}
</Box>
))}
</Box>
)}
{props.add}
</Stack>
)
}
|