Skip to content

Commit

Permalink
SBERDOMA-906 add available settlement types
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFoxPro committed Jul 30, 2021
1 parent 9b1b195 commit 2ca6cc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { PropertyPanels } from '../panels'
import Prompt from '@condo/domains/common/components/Prompt'
import { AddressMeta } from '@condo/domains/common/utils/addressApi/AddressMeta'
import { useState } from 'react'
import { validHouseTypes } from '@condo/domains/property/constants/property'
import { get } from 'lodash'
import { validHouseTypes, validSettlementTypes } from '@condo/domains/property/constants/property'

interface IOrganization {
id: string
Expand Down Expand Up @@ -109,10 +108,11 @@ const BasePropertyForm: React.FC<IPropertyFormProps> = (props) => {
<AddressSuggestionsSearchInput
onSelect={(_, option) => {
const address = JSON.parse(option.key) as AddressMeta
if (address.data.settlement_type) {
setAddressValidatorError(UnsupportedPropertyErrorMsg.replace('{propertyType}', address.data.settlement_type))
console.log(address.data)
if (!validSettlementTypes.includes(address.data.settlement_type_full)) {
setAddressValidatorError(UnsupportedPropertyErrorMsg.replace('{propertyType}', address.data.settlement_type_full))
}
else if (!validHouseTypes.includes(address.data.house_type)) {
else if (!validHouseTypes.includes(address.data.house_type_full)) {
setAddressValidatorError(AddressValidationErrorMsg)
}
else if (AddressValidationErrorMsg) setAddressValidatorError(null)
Expand Down
4 changes: 3 additions & 1 deletion apps/condo/domains/property/constants/property.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AddressMeta } from '@condo/domains/common/utils/addressApi/AddressMeta'

// "д" - "дом" or "к" - "корпус"
const validHouseTypes: AddressMeta['data']['house_type'][] = ['д', 'к', 'стр']
const validHouseTypes: AddressMeta['data']['house_type_full'][] = ['дом', 'корпус', 'строение']
const validSettlementTypes: AddressMeta['data']['settlement_type_full'][] = ['село', 'поселок городского типа']

const buildingEmptyMapJson = {
'dv': 1,
Expand Down Expand Up @@ -313,4 +314,5 @@ export {
buildingAddressMetaJson,
notValidBuildingMapJson,
validHouseTypes,
validSettlementTypes,
}

0 comments on commit 2ca6cc2

Please sign in to comment.