Skip to content

Commit 0954b54

Browse files
committed
chore: hide transaction when is not exist
1 parent d9d21d3 commit 0954b54

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/app/[locale]/(main)/(container)/profile/orders/[id]/payment/successful/components/OrderDetails.tsx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ import CheckedAnimation from './CheckedAnimation';
1010

1111
export interface OrderDetailsProps {
1212
orderId: number | string;
13-
transactionId: number | string;
13+
transactionId?: number | string | null;
1414
}
1515

1616
const OrderDetails: FC<OrderDetailsProps> = ({ orderId, transactionId }) => {
1717
const t = useTranslations();
1818

1919
const handleClickOnCopy = () => {
20-
navigator.clipboard
21-
.writeText(transactionId.toString())
22-
.then(() => {
23-
toast.success(t('messages.copied'));
24-
})
25-
.catch((err) => {});
20+
if (transactionId) {
21+
navigator.clipboard
22+
.writeText(transactionId.toString())
23+
.then(() => {
24+
toast.success(t('messages.copied'));
25+
})
26+
.catch((err) => {});
27+
}
2628
};
2729

2830
return (
@@ -42,18 +44,22 @@ const OrderDetails: FC<OrderDetailsProps> = ({ orderId, transactionId }) => {
4244
{t('order.payment.successful.description')}
4345
</Typography>
4446

45-
<Stack direction="row" alignItems="center" spacing={1}>
46-
<Typography variant="body2" color="textSecondary" gutterBottom>
47-
{t('order.payment.successful.transactionId')}{' '}
48-
</Typography>
49-
<Button
50-
onClick={handleClickOnCopy}
51-
variant="outlined"
52-
endIcon={<ContentCopyOutlined fontSize="small" />}
53-
>
54-
<Typography variant="h6">{transactionId}</Typography>
55-
</Button>
56-
</Stack>
47+
{!!transactionId && (
48+
<Stack direction="row" alignItems="center" spacing={1}>
49+
<Typography variant="body2" color="textSecondary" gutterBottom>
50+
{t('order.payment.successful.transactionId')}{' '}
51+
</Typography>
52+
53+
<Button
54+
onClick={handleClickOnCopy}
55+
variant="outlined"
56+
endIcon={<ContentCopyOutlined fontSize="small" />}
57+
>
58+
<Typography variant="h6">{transactionId}</Typography>
59+
</Button>
60+
</Stack>
61+
)}
62+
5763
<Button
5864
sx={{
5965
width: 'fit-content',

src/app/[locale]/(main)/(container)/profile/orders/[id]/payment/successful/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Page: FC<PageProps> = async (props) => {
2929
<Card variant="outlined" sx={{ width: '100%' }}>
3030
<CardContent>
3131
<OrderDetails
32-
transactionId={data.order.transactionId!}
32+
transactionId={data.order.transactionId}
3333
orderId={orderId}
3434
/>
3535
</CardContent>

0 commit comments

Comments
 (0)