Skip to content

Commit

Permalink
DOMA-1708 add missed fields to render address
Browse files Browse the repository at this point in the history
  • Loading branch information
nomerdvadcatpyat committed Nov 26, 2021
1 parent 8547c99 commit 84f318f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 5 additions & 3 deletions apps/condo/domains/common/components/Table/Renders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ const POSTFIX_PROPS: TextProps = { type: 'secondary', style: { whiteSpace: 'pre-

export const getAddressRender = (property: Property, DeletedMessage?: string, search?: FilterValue | string) => {
const isDeleted = !!get(property, 'deletedAt')
const { streetPart, regionPart, cityPart } = getAddressDetails(property)
const { streetPart, areaPart, regionPart, settlementPart, cityPart } = getAddressDetails(property)
const extraProps: Partial<TTextHighlighterProps> = isDeleted && { type: 'secondary' }
const deletedMessage = isDeleted && DeletedMessage ? `(${DeletedMessage})\n` : '\n'
const regionLine = regionPart ? `\n${regionPart}` : ''
const areaLine = areaPart ? `\n${areaPart}` : ''
const regionLine = !areaPart && regionPart ? `\n${regionPart}` : ''
const cityLine = cityPart ? `,\n${cityPart}` : ''
const postfix = regionLine + cityLine + deletedMessage
const settlementLine = settlementPart ? `,\n${settlementPart}` : ''
const postfix = regionLine + areaLine + settlementLine + cityLine + deletedMessage

return getTableCellRenderer(search, false, postfix, extraProps, POSTFIX_PROPS)(streetPart)
}
Expand Down
13 changes: 10 additions & 3 deletions apps/condo/domains/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,25 @@ export const getAddressDetails = (property: Property) => {
const houseType = get(addressMeta, 'house_type')
const houseName = get(addressMeta, 'house')

const blockType = get(addressMeta, 'block_type')
const blockName = get(addressMeta, 'block')

const regionType = get(addressMeta, 'region_type_full')
const regionName = get(addressMeta, 'region')

const cityType = get(addressMeta, 'city_type')
const cityName = get(addressMeta, 'city')

const settlement = streetName ? `${streetType}. ${streetName}` : get(addressMeta, 'settlement_with_type')
const streetPart = settlement && `${settlement}, ${houseType}. ${houseName}`
const areaPart = get(addressMeta, 'area_with_type')
const settlementPart = get(addressMeta, 'settlement_with_type')

const block = blockType ? `, ${blockType} ${blockName}` : ''
const settlement = streetName ? `${streetType}. ${streetName}` : settlementPart
const streetPart = settlement && `${settlement}, ${houseType}. ${houseName} ${block}`
const regionPart = regionName && `${regionName} ${regionType}`
const cityPart = cityName && `${cityType}. ${cityName}`

return { streetPart, regionPart, cityPart }
return { streetPart, areaPart, settlementPart, regionPart, cityPart }
}

/**
Expand Down
6 changes: 4 additions & 2 deletions apps/condo/domains/division/utils/clientSchema/Renders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ const ADDRESS_RENDER_POSTFIX_PROPS: TextProps = { type: 'secondary', style: { wh

export const getAddressRender = (property: Property, DeletedMessage?: string, search?: FilterValue | string) => {
const isDeleted = !!get(property, 'deletedAt')
const { streetPart, regionPart, cityPart } = getAddressDetails(property)
const { streetPart, regionPart, cityPart, settlementPart, areaPart } = getAddressDetails(property)
const extraProps: Partial<TTextHighlighterProps> = isDeleted && { type: 'secondary' }
const text = `${streetPart},`
const deletedMessage = isDeleted && DeletedMessage ? `(${DeletedMessage})\n` : '\n'
const region = regionPart ? regionPart : ''
const area = areaPart ? `, ${areaPart}` : ''
const city = cityPart ? `, ${cityPart}` : ''
const postfix = `${region}${city} ${deletedMessage}`
const settlement = settlementPart ? `, ${settlementPart}` : ''
const postfix = region + area + settlement + city + deletedMessage

return getTableCellRenderer(search, false, postfix, extraProps, ADDRESS_RENDER_POSTFIX_PROPS)(text)
}

0 comments on commit 84f318f

Please sign in to comment.