1
1
import { Box } from '@mui/material' ;
2
2
import React from 'react' ;
3
3
import NeoCard from '../../card/Card' ;
4
+ import useUltraWide from '../../utils/useUltraWide' ;
4
5
5
6
export default function GroupReport ( {
6
7
groupedReports,
@@ -14,14 +15,38 @@ export default function GroupReport({
14
15
getAddCardButtonPosition,
15
16
onClonePressed,
16
17
} ) {
18
+ const isUltraWide = useUltraWide ( ) ;
17
19
return groupedReports [ groupId ] . length > 0 ? (
18
20
< Box display = 'grid' gridTemplateColumns = 'repeat(24, 1fr)' columnGap = { 1 } sx = { getBorderSpecsForGroupId ( groupId ) } >
19
21
{ groupedReports [ groupId ]
20
- . sort ( ( a : any , b : any ) => a . groupOrder - b . groupOrder )
21
- . map ( ( report : { id : any ; width : any ; height : any } ) => {
22
- const { id, width : w , height : h } = report ;
22
+ . sort ( ( a : any , b : any ) => {
23
+ const aGroupOrder = a . groupOrder ;
24
+ const bGroupOrder = b . groupOrder ;
25
+ const aUwGroupOrder = a . uwGroupOrder ?? 0 ;
26
+ const bUwGroupOrder = b . uwGroupOrder ?? 0 ;
27
+ const isUwHeightPresent = a . uwHeight && b . uwHeight ;
28
+
29
+ if ( isUltraWide && isUwHeightPresent ) {
30
+ return aUwGroupOrder - bUwGroupOrder ;
31
+ }
32
+ return aGroupOrder - bGroupOrder ;
33
+ } )
34
+ . map ( ( report : { id : any ; width : any ; height : any ; x : any ; y : any ; uwHeight : number } ) => {
35
+ const { id, width : w , height : h , uwHeight } = report ;
36
+ let modifiedWidth = w ;
37
+ let modifiedHeight = h ;
38
+ if ( isUltraWide && uwHeight ) {
39
+ modifiedWidth = w / 2 ;
40
+ modifiedHeight = uwHeight ?? 2 ;
41
+ }
42
+
23
43
return (
24
- < Box id = { id } gridColumn = { `span ${ w } ` } gridRow = { `span ${ h } ` } sx = { { height : h * 100 , paddingBottom : '15px' } } >
44
+ < Box
45
+ id = { id }
46
+ gridColumn = { `span ${ modifiedWidth } ` }
47
+ gridRow = { `span ${ modifiedHeight } ` }
48
+ sx = { { height : modifiedHeight * 100 , paddingBottom : '15px' } }
49
+ >
25
50
< NeoCard
26
51
id = { id }
27
52
key = { getReportKey ( pagenumber , id ) }
0 commit comments