Skip to content

Commit

Permalink
fix: update order company name
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Dec 5, 2022
1 parent d0e2333 commit 255f9c4
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion apps/storefront/src/pages/orderDetail/components/OrderAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {

import {
OrderDetailsState,
OrderDetailsContext,
} from '../context/OrderDetailsContext'

const OrderActionContainer = styled('div')(() => ({}))
Expand Down Expand Up @@ -300,6 +301,12 @@ export const OrderAction = (props: OrderActionProps) => {
},
} = useContext(GlobaledContext)

const {
state: {
addressLabelPermission,
},
} = useContext(OrderDetailsContext)

const {
money,
orderSummary: {
Expand All @@ -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 {}
Expand All @@ -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}`,
}
Expand Down

0 comments on commit 255f9c4

Please sign in to comment.