|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { Link } from '@/navigation'; |
| 4 | +import { ContentCopyOutlined } from '@mui/icons-material'; |
| 5 | +import { Button, Stack, Typography } from '@mui/material'; |
| 6 | +import { useTranslations } from 'next-intl'; |
| 7 | +import { FC } from 'react'; |
| 8 | +import toast from 'react-hot-toast'; |
| 9 | +import CheckedAnimation from './CheckedAnimation'; |
| 10 | + |
| 11 | +export interface OrderDetailsProps { |
| 12 | + orderId: number | string; |
| 13 | + transactionId: number | string; |
| 14 | +} |
| 15 | + |
| 16 | +const OrderDetails: FC<OrderDetailsProps> = ({ orderId, transactionId }) => { |
| 17 | + const t = useTranslations(); |
| 18 | + |
| 19 | + const handleClickOnCopy = () => { |
| 20 | + navigator.clipboard |
| 21 | + .writeText(transactionId.toString()) |
| 22 | + .then(() => { |
| 23 | + toast.success(t('messages.copied')); |
| 24 | + }) |
| 25 | + .catch((err) => {}); |
| 26 | + }; |
| 27 | + |
| 28 | + return ( |
| 29 | + <Stack |
| 30 | + spacing={3} |
| 31 | + alignItems="center" |
| 32 | + justifyContent="center" |
| 33 | + sx={{ |
| 34 | + textAlign: 'center', |
| 35 | + }} |
| 36 | + > |
| 37 | + <CheckedAnimation /> |
| 38 | + <Typography variant="h5" gutterBottom> |
| 39 | + {t('order.payment.successful.title')} |
| 40 | + </Typography> |
| 41 | + <Typography variant="body1" color="textSecondary"> |
| 42 | + {t('order.payment.successful.description')} |
| 43 | + </Typography> |
| 44 | + |
| 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> |
| 57 | + <Button |
| 58 | + sx={{ |
| 59 | + width: 'fit-content', |
| 60 | + }} |
| 61 | + LinkComponent={Link} |
| 62 | + href={`/profile/orders/${orderId}`} |
| 63 | + variant="contained" |
| 64 | + color="primary" |
| 65 | + size="large" |
| 66 | + > |
| 67 | + {t('order.view')} |
| 68 | + </Button> |
| 69 | + </Stack> |
| 70 | + ); |
| 71 | +}; |
| 72 | + |
| 73 | +export default OrderDetails; |
0 commit comments