fix: country selection (#10670)

This commit is contained in:
David Kubeš
2025-01-22 17:00:51 +01:00
committed by GitHub
parent 38e46bbb6c
commit 52362ec1ea

View File

@@ -35,7 +35,7 @@ const FORM_CONFIG = {
EMAIL_ADDRESS: { field: 'email' }, EMAIL_ADDRESS: { field: 'email' },
PHONE_NUMBER: { field: 'phoneNumber' }, PHONE_NUMBER: { field: 'phoneNumber' },
CITY: { field: 'additionalAttributes.city' }, CITY: { field: 'additionalAttributes.city' },
COUNTRY: { field: 'additionalAttributes.country' }, COUNTRY: { field: 'additionalAttributes.countryCode' },
BIO: { field: 'additionalAttributes.description' }, BIO: { field: 'additionalAttributes.description' },
COMPANY_NAME: { field: 'additionalAttributes.companyName' }, COMPANY_NAME: { field: 'additionalAttributes.companyName' },
}; };
@@ -123,7 +123,7 @@ const prepareStateBasedOnProps = () => {
}; };
const countryOptions = computed(() => const countryOptions = computed(() =>
countries.map(({ name }) => ({ label: name, value: name })) countries.map(({ name, id }) => ({ label: name, value: id }))
); );
const editDetailsForm = computed(() => const editDetailsForm = computed(() =>
@@ -205,8 +205,8 @@ const getMessageType = key => {
}; };
const handleCountrySelection = value => { const handleCountrySelection = value => {
const selectedCountry = countries.find(option => option.name === value); const selectedCountry = countries.find(option => option.id === value);
state.additionalAttributes.countryCode = selectedCountry?.id || ''; state.additionalAttributes.country = selectedCountry?.name || '';
emit('update', state); emit('update', state);
}; };
@@ -242,7 +242,7 @@ defineExpose({
<template v-for="item in editDetailsForm" :key="item.key"> <template v-for="item in editDetailsForm" :key="item.key">
<ComboBox <ComboBox
v-if="item.key === 'COUNTRY'" v-if="item.key === 'COUNTRY'"
v-model="state.additionalAttributes.country" v-model="state.additionalAttributes.countryCode"
:options="countryOptions" :options="countryOptions"
:placeholder="item.placeholder" :placeholder="item.placeholder"
class="[&>div>button]:h-8" class="[&>div>button]:h-8"