feat(regions): Add support for updating countries in a region (#6432)

**What**
Add missing support for updating countries on the POST /admin/regions/:id route.
Furthermore, the PR refactors how the normalization and validation was handled in both create and update scenarios.
Finally, the PR adds a unique index on the country entity, which ensures at the DB level that we cannot have a duplicate country in the DB for a single region.
This commit is contained in:
Stevche Radevski
2024-02-20 11:46:42 +00:00
committed by GitHub
parent c319edb8e0
commit cfefd59249
10 changed files with 436 additions and 132 deletions
+3 -9
View File
@@ -7,21 +7,15 @@ export interface CreateRegionDTO {
export interface UpdateRegionDTO {
id: string
name?: string
currency_code?: string
countries?: string[]
name?: string
metadata?: Record<string, unknown>
}
export interface UpdatableRegionFields {
currency_code?: string
name?: string
currency_code?: string
countries?: string[]
metadata?: Record<string, unknown>
}
export interface AddCountryToRegionDTO {
region_id: string
country_id: string
}
export interface RemoveCountryFromRegionDTO extends AddCountryToRegionDTO {}