Skip to content

Commit cb952fc

Browse files
Merge pull request #166 from 0101oak/oak/fix-order-print-layout
print layout fixed
2 parents b6107df + 3a30438 commit cb952fc

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

src/components/managers/orders/orderDetails.tsx

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import EditIcon from '@mui/icons-material/Edit';
22
import { Button, Grid, TextField, Typography } from '@mui/material';
33
import CircularProgress from '@mui/material/CircularProgress';
44
import IconButton from '@mui/material/IconButton';
5-
import { DataGrid, GridPaginationModel } from '@mui/x-data-grid';
5+
import { DataGrid, GridColDef, GridPaginationModel } from '@mui/x-data-grid';
66
import { MakeGenerics, useMatch } from '@tanstack/react-location';
77
import { getDictionary } from 'api/admin';
88
import {
@@ -12,10 +12,11 @@ import {
1212
setTrackingNumberUpdate,
1313
} from 'api/orders';
1414
import { common_Dictionary } from 'api/proto-http/admin';
15-
import { common_OrderFull } from 'api/proto-http/frontend';
15+
import { common_OrderFull, common_OrderItem } from 'api/proto-http/frontend';
1616
import { CopyToClipboard } from 'components/common/copyToClipboard';
1717
import { Layout } from 'components/login/layout';
1818
import { ROUTES } from 'constants/routes';
19+
import logo from 'img/tex-text.png';
1920
import { useEffect, useState } from 'react';
2021
import styles from 'styles/order.scss';
2122
import { formatDateTime, getOrderStatusName, getStatusColor } from './utility';
@@ -44,7 +45,6 @@ export const OrderDetails = () => {
4445
const [isPrinting, setIsPrinting] = useState(false);
4546
const [columnVisibility, setColumnVisibility] = useState({
4647
thumbnail: true,
47-
productLink: true,
4848
size: true,
4949
});
5050
const [isEdit, setIsEdit] = useState(false);
@@ -59,7 +59,7 @@ export const OrderDetails = () => {
5959
};
6060

6161
useEffect(() => {
62-
setColumnVisibility({ thumbnail: !isPrinting, productLink: !isPrinting, size: !isPrinting });
62+
setColumnVisibility({ thumbnail: !isPrinting, size: !isPrinting });
6363
}, [isPrinting]);
6464

6565
useEffect(() => {
@@ -99,10 +99,11 @@ export const OrderDetails = () => {
9999
setOrderStatus(getOrderStatusName(dictionary, orderDetails?.order?.orderStatusId));
100100
}, [orderDetails, dictionary]);
101101

102-
const orderItemsColumns = [
102+
const orderItemsColumns: GridColDef<common_OrderItem>[] = [
103103
{
104104
field: 'thumbnail',
105105
headerName: '',
106+
align: 'center',
106107
width: 200,
107108
renderCell: (params: any) => (
108109
<a
@@ -119,6 +120,7 @@ export const OrderDetails = () => {
119120
{
120121
field: 'sku',
121122
headerName: 'SKU',
123+
align: 'center',
122124
width: isPrinting ? 150 : 300,
123125
renderCell: (params: any) => (
124126
<div
@@ -140,12 +142,16 @@ export const OrderDetails = () => {
140142
},
141143
{
142144
field: 'productName',
143-
headerName: isPrinting ? 'NAME' : 'PRODUCT NAME',
144-
width: isPrinting ? 100 : 200,
145+
align: 'center',
146+
headerAlign: 'center',
147+
headerName: 'PRODUCT NAME',
148+
width: 150,
145149
},
146150
{
147151
field: 'quantity',
148152
headerName: 'QUANTITY',
153+
headerAlign: 'center',
154+
align: 'center',
149155
width: isPrinting ? 100 : 200,
150156
valueGetter: (_params: any, row: any) => {
151157
return row.orderItem.quantity;
@@ -154,6 +160,8 @@ export const OrderDetails = () => {
154160
{
155161
field: 'size',
156162
headerName: 'SIZE',
163+
align: 'center',
164+
headerAlign: 'center',
157165
width: 200,
158166
cellClassName: styles.hide_cell,
159167
valueGetter: (_params: any, row: any) => {
@@ -165,17 +173,23 @@ export const OrderDetails = () => {
165173
{
166174
field: 'productPrice',
167175
headerName: 'PRICE',
168-
width: isPrinting ? 100 : 200,
176+
align: 'center',
177+
headerAlign: 'center',
178+
width: isPrinting ? 90 : 200,
169179
valueGetter: (params: any, row: any) =>
170180
`${params * row.orderItem.quantity} ${dictionary?.baseCurrency}`,
171181
},
172182
{
173183
field: 'productSalePercentage',
174184
headerName: 'SALE',
175-
width: isPrinting ? 100 : 200,
185+
align: 'center',
186+
headerAlign: 'center',
187+
width: isPrinting ? 90 : 200,
176188
},
177189
{
178190
field: 'productPriceWithSale',
191+
align: 'center',
192+
headerAlign: 'center',
179193
headerName: isPrinting ? 'PWS' : 'PRICE WITH SALE',
180194
width: isPrinting ? 100 : 200,
181195
},
@@ -498,17 +512,23 @@ export const OrderDetails = () => {
498512
return (
499513
<Layout>
500514
<Grid container spacing={2} justifyContent='center' alignItems='center'>
515+
{isPrinting && (
516+
<Grid item xs={12}>
517+
<img src={logo} alt='logo' style={{ width: '30px', height: 'auto' }} />
518+
</Grid>
519+
)}
520+
501521
<Grid item xs={12}>
502-
<Grid container justifyContent='flex-start'>
503-
<Grid item xs={12} sm={2} className={styles.hide_cell}>
522+
<Grid container justifyContent='flex-start' alignItems='center'>
523+
<Grid item xs={12} md={2} className={styles.hide_cell}>
504524
<Typography fontWeight='bold' textTransform='uppercase'>
505525
order id: {orderDetails?.order?.id}
506526
</Typography>
507527
</Grid>
508528
<Grid
509529
item
510530
xs={12}
511-
sm={2}
531+
md={2}
512532
className={isPrinting ? styles.hide_cell : styles.non_print_state}
513533
>
514534
<Typography fontWeight='bold' textTransform='uppercase'>
@@ -526,21 +546,18 @@ export const OrderDetails = () => {
526546
<Grid
527547
item
528548
xs={12}
529-
sm={2}
549+
md={2}
530550
className={isPrinting ? styles.hide_cell : styles.non_print_state}
531551
>
532552
STATUS:&nbsp;{orderStatusColored}
533553
</Grid>
534-
<Grid item xs={12} sm={5} className={styles.support}>
554+
<Grid item xs={12} className={styles.support}>
535555
COMPANY ADRESS: ADRESS ADRESS ADRESS
536556
</Grid>
537-
<Grid item xs={12} sm={3} className={styles.support}>
538-
COMPANY VAT ID: ID
539-
</Grid>
540-
<Grid item xs={12} sm={isPrinting ? 4 : 3}>
557+
<Grid item xs={12} md={3}>
541558
PLACED: {formatDateTime(orderDetails?.order?.placed)}
542559
</Grid>
543-
<Grid item className={styles.hide_cell} xs={12} sm={3}>
560+
<Grid item className={styles.hide_cell} xs={12} md={3}>
544561
MODIFIED: {formatDateTime(orderDetails?.order?.modified)}
545562
</Grid>
546563
</Grid>

0 commit comments

Comments
 (0)