From bea15d85238dcd1e87e089f7fa56c3bab219b142 Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 21 Jun 2023 11:24:41 +0800 Subject: [PATCH] fix: show address lists by type in quote draft --- .../src/pages/quote/components/ChooseAddress.tsx | 9 ++++++++- .../src/pages/quote/components/QuoteAddress.tsx | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/storefront/src/pages/quote/components/ChooseAddress.tsx b/apps/storefront/src/pages/quote/components/ChooseAddress.tsx index 7b1743e7..4152ccab 100644 --- a/apps/storefront/src/pages/quote/components/ChooseAddress.tsx +++ b/apps/storefront/src/pages/quote/components/ChooseAddress.tsx @@ -17,6 +17,7 @@ interface ChooseAddressProps { addressList: AddressItemProps[] closeModal: () => void handleChangeAddress: (address: AddressItemType) => void + type: string } interface RefProps { @@ -28,6 +29,7 @@ function ChooseAddress({ closeModal, handleChangeAddress, addressList = [], + type, }: ChooseAddressProps) { const recordList = useRef({ copyList: [], @@ -37,7 +39,12 @@ function ChooseAddress({ useEffect(() => { if (addressList.length) { - const newList = addressList.map((item: AddressItemProps) => item.node) + const allList = addressList.map((item: AddressItemProps) => item.node) + const newList = allList.filter( + (item) => + (item.isShipping === 1 && type === 'shipping') || + (item.isBilling === 1 && type === 'billing') + ) recordList.current.copyList = newList setList(newList) } diff --git a/apps/storefront/src/pages/quote/components/QuoteAddress.tsx b/apps/storefront/src/pages/quote/components/QuoteAddress.tsx index ab2ceb93..ada21e6f 100644 --- a/apps/storefront/src/pages/quote/components/QuoteAddress.tsx +++ b/apps/storefront/src/pages/quote/components/QuoteAddress.tsx @@ -218,6 +218,7 @@ function QuoteAddress( handleChangeAddress={handleChangeAddress} closeModal={handleCloseAddressChoose} addressList={addressList} + type={type} /> )