From 003bff7cbc1bd9a30aaa126a11e3ebe18ef018dc Mon Sep 17 00:00:00 2001 From: "Brian.Jiang2021" Date: Fri, 2 Dec 2022 10:01:59 +0800 Subject: [PATCH] fix: bc address issues --- .../storefront/src/pages/address/components/AddressForm.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/storefront/src/pages/address/components/AddressForm.tsx b/apps/storefront/src/pages/address/components/AddressForm.tsx index 6772c68c..1d6ea10f 100644 --- a/apps/storefront/src/pages/address/components/AddressForm.tsx +++ b/apps/storefront/src/pages/address/components/AddressForm.tsx @@ -207,7 +207,7 @@ const AddressForm = ({ currentCountryName = countryName if (states.length > 0) { - const state = states.filter((item: StateProps) => item.stateCode === currentStateCode)[0] + const state = states.filter((item: StateProps) => item.stateCode === currentStateCode || item.stateName === currentStateCode)[0] currentStateName = state.stateName || currentStateCode currentStateCode = state.stateCode || currentStateCode @@ -268,6 +268,7 @@ const AddressForm = ({ const handleSaveBcAddress = (event: BaseSyntheticEvent | undefined) => { handleSubmit(async (data) => { setAddUpdateLoading(true) + try { const extraFields = addressExtraFields.map((field: CustomFieldItems) => ({ name: field.bcLabel, @@ -293,7 +294,8 @@ const AddressForm = ({ currentCountryName = countryName if (states.length > 0) { - const state = states.filter((item: StateProps) => item.stateCode === currentStateCode)[0] + const state = states.filter((item: StateProps) => item.stateCode === currentStateCode || item.stateName === currentStateCode)[0] + currentStateName = state.stateName || currentStateCode currentStateCode = state.stateCode || currentStateCode } else {