fix: muralpay iso mismatch (#4871)

* fix: deduplicate and use full code

* fix: subdivisions match muralpay
This commit is contained in:
Calum H.
2025-12-18 02:08:47 +00:00
committed by GitHub
parent 609e3896eb
commit 514c6f6e34
3 changed files with 28 additions and 7 deletions

View File

@@ -17,6 +17,7 @@
"@formatjs/cli": "^6.2.12",
"@nuxt/devtools": "^1.3.3",
"@types/dompurify": "^3.0.5",
"@types/iso-3166-2": "^1.0.4",
"@types/node": "^20.1.0",
"@vintl/compact-number": "^2.0.5",
"@vintl/how-ago": "^3.0.1",
@@ -58,6 +59,7 @@
"floating-vue": "^5.2.2",
"fuse.js": "^6.6.2",
"highlight.js": "^11.7.0",
"iso-3166-2": "1.0.0",
"js-yaml": "^4.1.0",
"jszip": "^3.10.1",
"markdown-it": "14.1.0",

View File

@@ -220,14 +220,14 @@
<script setup lang="ts">
import { Chips, Combobox, formFieldLabels, formFieldPlaceholders } from '@modrinth/ui'
import { useVIntl } from '@vintl/vintl'
// TODO: Switch to using Muralpay's improved endpoint when it's available.
import iso3166 from 'iso-3166-2'
import { useFormattedCountries } from '@/composables/country.ts'
import { useGeneratedState } from '@/composables/generated.ts'
import { useWithdrawContext } from '@/providers/creator-withdraw.ts'
const { withdrawData } = useWithdrawContext()
const { formatMessage } = useVIntl()
const generatedState = useGeneratedState()
const providerData = withdrawData.value.providerData
const existingKycData = providerData.type === 'muralpay' ? providerData.kycData : null
@@ -283,12 +283,15 @@ const subdivisionOptions = computed(() => {
const selectedCountry = formData.value.physicalAddress.country
if (!selectedCountry) return []
const subdivisions = generatedState.value.subdivisions?.[selectedCountry] ?? []
const country = iso3166.country(selectedCountry)
if (!country) return []
return subdivisions.map((sub) => ({
value: sub.code.includes('-') ? sub.code.split('-')[1] : sub.code,
label: sub.localVariant || sub.name,
}))
return Object.entries(country.sub)
.map(([code, sub]) => ({
value: code.split('-').slice(1).join('-'),
label: sub.name,
}))
.sort((a, b) => a.label.localeCompare(b.label))
})
watch(

16
pnpm-lock.yaml generated
View File

@@ -287,6 +287,9 @@ importers:
highlight.js:
specifier: ^11.7.0
version: 11.9.0
iso-3166-2:
specifier: 1.0.0
version: 1.0.0
js-yaml:
specifier: ^4.1.0
version: 4.1.0
@@ -345,6 +348,9 @@ importers:
'@types/dompurify':
specifier: ^3.0.5
version: 3.0.5
'@types/iso-3166-2':
specifier: ^1.0.4
version: 1.0.4
'@types/node':
specifier: ^20.1.0
version: 20.14.11
@@ -2795,6 +2801,9 @@ packages:
'@types/http-proxy@1.17.15':
resolution: {integrity: sha512-25g5atgiVNTIv0LBDTg1H74Hvayx0ajtJPLLcYE3whFv75J0pWNtOBzaXJQgDTmrX1bx5U9YC2w/n65BN1HwRQ==}
'@types/iso-3166-2@1.0.4':
resolution: {integrity: sha512-tXaeT4FDobC8rAy6LoFvbGA4vhOQQNIdSRC5DAoYfT3D9ohnKHkDFxHzSln6WqTKVeKLrnMiMQubM8m3fqNp/w==}
'@types/js-yaml@4.0.9':
resolution: {integrity: sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==}
@@ -5360,6 +5369,9 @@ packages:
isexe@2.0.0:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
iso-3166-2@1.0.0:
resolution: {integrity: sha512-xLAazfKZzwlsg/Zz/GQGQk3jJez5/2ORrjD3TjSuqz/arMht/xTK49c0GOE3afO/gEd9tHtBVVlfBla01unUng==}
jackspeak@3.4.0:
resolution: {integrity: sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==}
engines: {node: '>=14'}
@@ -10772,6 +10784,8 @@ snapshots:
dependencies:
'@types/node': 20.14.11
'@types/iso-3166-2@1.0.4': {}
'@types/js-yaml@4.0.9': {}
'@types/json-schema@7.0.15': {}
@@ -14060,6 +14074,8 @@ snapshots:
isexe@2.0.0: {}
iso-3166-2@1.0.0: {}
jackspeak@3.4.0:
dependencies:
'@isaacs/cliui': 8.0.2