Skip to content

Commit

Permalink
fix: user addresses - reset region if changing country (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethidden authored and Frodigo committed Jul 4, 2022
1 parent 71cb0b3 commit f765cde
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,21 @@ export default defineComponent({
setup(props, { emit }) {
const { load: loadCountries, search: searchCountry } = useCountrySearch();
const form = ref<TransformedCustomerAddress | null>(null);
const countries = ref<Countries[]>([]);
const countriesList = computed(() => addressGetter.countriesList(countries.value));
const country = ref<Country | null>(null);
const regionInformation = computed(() => addressGetter.regionList(country.value));
const updateCountry = async (params: UseCountrySearchParams) => {
country.value = await searchCountry(params);
form.value.region = {
// let region SfSelect know it should display initial state
...(regionInformation.value.length > 0 ? { region_id: null } : {}),
};
};
const regionInformation = computed(() => addressGetter.regionList(country.value));
const form = ref<TransformedCustomerAddress | null>(null);
watch(() => props.address, () => {
form.value = {
apartment: props.address.apartment,
Expand Down Expand Up @@ -329,7 +332,7 @@ export default defineComponent({
onBeforeMount(async () => {
countries.value = await loadCountries();
if (props.address.country_code) {
await updateCountry({ id: props.address.country_code });
country.value = await searchCountry({ id: props.address.country_code });
}
});
Expand Down

0 comments on commit f765cde

Please sign in to comment.