From 255f9c42c50c9d9ccf5233fc3bf2a3bcf47f4866 Mon Sep 17 00:00:00 2001 From: "aton.xia" Date: Mon, 5 Dec 2022 08:58:04 +0800 Subject: [PATCH] fix: update order company name --- .../orderDetail/components/OrderAction.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/storefront/src/pages/orderDetail/components/OrderAction.tsx b/apps/storefront/src/pages/orderDetail/components/OrderAction.tsx index afd7c207..640964bf 100644 --- a/apps/storefront/src/pages/orderDetail/components/OrderAction.tsx +++ b/apps/storefront/src/pages/orderDetail/components/OrderAction.tsx @@ -35,6 +35,7 @@ import { import { OrderDetailsState, + OrderDetailsContext, } from '../context/OrderDetailsContext' const OrderActionContainer = styled('div')(() => ({})) @@ -300,6 +301,12 @@ export const OrderAction = (props: OrderActionProps) => { }, } = useContext(GlobaledContext) + const { + state: { + addressLabelPermission, + }, + } = useContext(OrderDetailsContext) + const { money, orderSummary: { @@ -322,6 +329,16 @@ export const OrderAction = (props: OrderActionProps) => { return <> } + const getCompanyName = (company: string) => { + if (addressLabelPermission) { + return company + } + + const index = company.indexOf('/') + + return company.substring(index + 1, company.length) + } + const getFullPaymentAddress = (billingAddress?: Address) => { if (!billingAddress) { return {} @@ -339,7 +356,7 @@ export const OrderAction = (props: OrderActionProps) => { const paymentAddress = { paymentMethod: `Payment by ${paymentMethod}`, name: `${firstName} ${lastName}`, - company, + company: getCompanyName(company), street: street1, address: `${city}, ${state} ${zip}, ${country}`, }