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 | 9x 105x 105x 42x | // A flat as the rest of the app sees it (openspec: properties).
import type { IsoDate } from '#/lib/dates'
/** 1, 2, 3 or 4, where 4 means four rooms or more. */
export type RoomCount = 1 | 2 | 3 | 4
export const ROOM_COUNTS: readonly RoomCount[] = [1, 2, 3, 4]
export interface PropertyDetails {
streetAddress: string
/** Five digits. */
postcode: string
city: string
roomCount: RoomCount
/** In tenths of m²: 485 = 48,5 m². */
floorArea: number
/** Housing company details for form 7H; all optional (openspec: properties). */
housingCompanyName?: string
/** Business ID (Y-tunnus), "2345678-0". */
businessId?: string
/** E.g. "B 12". */
apartmentNumber?: string
}
export interface Property extends PropertyDetails {
id: string
}
/** A flat the user has archived, with the day (in Finland) they did. */
export interface ArchivedProperty extends Property {
archivedOn: IsoDate
}
/** A flat as one user sees it: when they archived it, if they did. */
export interface UserProperty extends Property {
archivedAt: Date | null
}
/**
* Sorts by street address in the language's alphabetical order, numbers by
* value: "Kuusikuja 3" before "Kuusikuja 12", and in Finnish and Swedish
* Å, Ä and Ö after Z.
*/
export function sortByStreetAddress<T extends Pick<Property, 'streetAddress'>>(
items: readonly T[],
locale: string,
): T[] {
const collator = new Intl.Collator(locale, { numeric: true })
return [...items].sort((a, b) =>
collator.compare(a.streetAddress, b.streetAddress),
)
}
|