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 | 298x 66x 58x 58x 58x 58x 235x 55x 68x 10x 65x | // How ownership reads in the UI: reasons, splits ("Sinä 50 % · Jussi 50 %")
// and dates. Shared by the ownership components.
import { formatShare } from '#/lib/format'
import { m } from '#/paraglide/messages.js'
import type { OwnershipReason } from '#/server/db/schema'
import type { Share } from './periods'
export function reasonLabel(reason: OwnershipReason): string {
switch (reason) {
case 'sale':
return m.ownership_reason_sale()
case 'gift':
return m.ownership_reason_gift()
case 'inheritance':
return m.ownership_reason_inheritance()
case 'division':
return m.ownership_reason_division()
case 'other':
return m.ownership_reason_other()
}
}
/** The name to show: "Sinä" for the user, else the name. */
export function displayName(
userId: string,
names: Readonly<Record<string, string>>,
you: string,
): string {
return userId === you ? m.sharing_you() : (names[userId] ?? '')
}
/** A split as one line, larger shares first: "Sinä 50 % · Jussi 50 %". */
export function splitText(
shares: readonly Share[],
names: Readonly<Record<string, string>>,
you: string,
): string {
return [...shares]
.filter((s) => s.share > 0)
.sort((a, b) => b.share - a.share)
.map((s) =>
m.property_card_owner({
name: displayName(s.userId, names, you),
share: formatShare(s.share),
}),
)
.join(' · ')
}
|