first commit

This commit is contained in:
lendry
2026-06-24 14:37:15 +03:00
commit 995adeedd4
188 changed files with 28810 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
export type AddressLabel = 'HOME' | 'WORK' | 'OTHER';
export const ADDRESS_LABELS: Record<AddressLabel, { title: string; shortTitle: string }> = {
HOME: { title: 'Дом', shortTitle: 'Дом' },
WORK: { title: 'Работа', shortTitle: 'Работа' },
OTHER: { title: 'Другой адрес', shortTitle: 'Другие' }
};
export function formatAddressLine(address: {
fullAddress?: string | null;
city?: string;
street?: string;
house?: string;
apartment?: string | null;
}) {
if (address.fullAddress?.trim()) return address.fullAddress.trim();
const parts = [`г. ${address.city}`, `${address.street}, ${address.house}`];
if (address.apartment?.trim()) parts.push(`кв. ${address.apartment.trim()}`);
return parts.filter(Boolean).join(', ');
}
export function getPrimaryAddress(addresses: { label: string }[], label: AddressLabel) {
return addresses.find((item) => item.label === label) ?? null;
}
export function getOtherAddresses<T extends { label: string }>(addresses: T[]) {
return addresses.filter((item) => item.label === 'OTHER');
}