2025-03-29 11:39:46 +03:00
|
|
|
import { Dictionary } from '@freearhey/core'
|
|
|
|
|
import { Country } from '.'
|
|
|
|
|
|
|
|
|
|
type SubdivisionData = {
|
2023-09-15 18:40:35 +03:00
|
|
|
code: string
|
|
|
|
|
name: string
|
|
|
|
|
country: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class Subdivision {
|
|
|
|
|
code: string
|
|
|
|
|
name: string
|
2025-03-29 11:39:46 +03:00
|
|
|
countryCode: string
|
|
|
|
|
country?: Country
|
|
|
|
|
|
|
|
|
|
constructor(data: SubdivisionData) {
|
|
|
|
|
this.code = data.code
|
|
|
|
|
this.name = data.name
|
|
|
|
|
this.countryCode = data.country
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
withCountry(countriesGroupedByCode: Dictionary): this {
|
|
|
|
|
this.country = countriesGroupedByCode.get(this.countryCode)
|
2023-09-15 18:40:35 +03:00
|
|
|
|
2025-03-29 11:39:46 +03:00
|
|
|
return this
|
2023-09-15 18:40:35 +03:00
|
|
|
}
|
|
|
|
|
}
|