Skip to content

Commit

Permalink
feat: can only print own invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Mar 22, 2023
1 parent 55c09c4 commit 82203b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ export const OrderAction = (props: OrderActionProps) => {
state: {
isB2BUser,
role,
emailAddress,
},
} = useContext(GlobaledContext)

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

Expand Down Expand Up @@ -445,7 +447,7 @@ export const OrderAction = (props: OrderActionProps) => {
key: 'aboutInvoice',
name: isB2BUser ? 'viewInvoice' : 'printInvoice',
variant: 'outlined',
isCanShow: !isB2BUser || +ipStatus !== 0,
isCanShow: (!isB2BUser || +ipStatus !== 0) && (createdEmail === emailAddress),
},
],
infos: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface OrderDetailsState {
invoiceId?: number,
addressLabelPermission?: boolean,
canReturn?: boolean,
createdEmail?: string,
}
interface OrderDetailsAction {
type: string,
Expand Down Expand Up @@ -74,6 +75,7 @@ const initState = {
invoiceId: 0,
addressLabelPermission: false,
canReturn: false,
createdEmail: '',
}

export const OrderDetailsContext = createContext<OrderDetailsContextType>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ export const convertB2BOrderDetails = (data: B2BOrderData) => ({
ipStatus: +data.ipStatus || 0, // 0: no invoice, 1,2: have invoice
invoiceId: +(data.invoiceId || 0),
canReturn: data.canReturn,
createdEmail: data.createdEmail,
})
11 changes: 9 additions & 2 deletions apps/storefront/src/pages/quote/components/QuoteDetailTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ interface SearchProps {
offset?: number,
}

interface OptionProps {
optionId: number,
optionLabel: string,
optionName: string,
optionValue: string | number,
}

interface PaginationTableRefProps extends HTMLInputElement {
getList: () => void,
setList: (items?: ListItemProps[]) => void,
Expand Down Expand Up @@ -159,7 +166,7 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>
optionsValue.length > 0 && (
<Box>
{
optionsValue.map((option: any) => (option.optionLabel ? (
optionsValue.map((option: OptionProps) => (option.optionLabel && (
<Typography
sx={{
fontSize: '0.75rem',
Expand All @@ -172,7 +179,7 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>
}: ${option.optionLabel
}`}
</Typography>
) : <></>))
)))
}
</Box>
)
Expand Down

0 comments on commit 82203b9

Please sign in to comment.