@@ -29,40 +29,52 @@ const Seat = ({
29
29
const randomId = useRandomIdSeed ( ) ;
30
30
const titleId = title ? randomId ( "title" ) : "" ;
31
31
const descrId = description ? randomId ( "descr" ) : "" ;
32
- const clickable = type !== TYPES . UNAVAILABLE ;
32
+ const isAvailable = type !== TYPES . UNAVAILABLE ;
33
+ const clickable = isAvailable && onClick !== undefined ;
33
34
34
- return (
35
- < Stack inline grow = { false } spacing = "50" direction = "column" align = "center" >
36
- < button
37
- className = { cx (
38
- "orbit-seat font-base group relative" ,
39
- size === SIZE_OPTIONS . SMALL ? "w-800 h-[36px]" : "size-[46px]" ,
40
- ) }
41
- data-test = { dataTest }
42
- id = { id }
43
- disabled = { ! clickable }
44
- onClick = { clickable ? onClick : undefined }
45
- tabIndex = { clickable ? 0 : - 1 }
46
- type = "button"
35
+ const commonProps = {
36
+ className : cx (
37
+ "orbit-seat font-base group relative" ,
38
+ isAvailable && "cursor-pointer" ,
39
+ size === SIZE_OPTIONS . SMALL ? "w-800 h-[36px]" : "size-[46px]" ,
40
+ ) ,
41
+ id,
42
+ "data-test" : dataTest ,
43
+ } ;
44
+
45
+ const seatContent = (
46
+ < >
47
+ < svg
48
+ viewBox = { size === SIZE_OPTIONS . SMALL ? "0 0 32 36" : "0 0 46 46" }
49
+ aria-labelledby = { `${ [ ariaLabelledBy , titleId , descrId ] . join ( " " ) . trim ( ) } ` || undefined }
50
+ fill = "none"
51
+ role = "img"
47
52
>
48
- < svg
49
- viewBox = { size === SIZE_OPTIONS . SMALL ? "0 0 32 36" : "0 0 46 46" }
50
- aria-labelledby = { `${ [ ariaLabelledBy , titleId , descrId ] . join ( " " ) . trim ( ) } ` || undefined }
51
- fill = "none"
52
- role = "img"
53
- >
54
- { title && < title id = { titleId } > { title } </ title > }
55
- { description && < desc id = { descrId } > { description } </ desc > }
53
+ { title && < title id = { titleId } > { title } </ title > }
54
+ { description && < desc id = { descrId } > { description } </ desc > }
55
+
56
+ { size === SIZE_OPTIONS . SMALL ? (
57
+ < SeatSmall type = { type } selected = { selected } label = { label } />
58
+ ) : (
59
+ < SeatNormal type = { type } selected = { selected } label = { label } />
60
+ ) }
61
+ </ svg >
62
+ { selected && isAvailable && < SeatCircle size = { size } type = { type } /> }
63
+ </ >
64
+ ) ;
56
65
57
- { size === SIZE_OPTIONS . SMALL ? (
58
- < SeatSmall type = { type } selected = { selected } label = { label } />
59
- ) : (
60
- < SeatNormal type = { type } selected = { selected } label = { label } />
61
- ) }
62
- </ svg >
63
- { selected && clickable && < SeatCircle size = { size } type = { type } /> }
64
- </ button >
65
- { price && ! ( selected && type === TYPES . UNAVAILABLE ) && (
66
+ return (
67
+ < Stack inline grow = { false } spacing = "50" direction = "column" align = "center" >
68
+ { clickable ? (
69
+ < button { ...commonProps } onClick = { onClick } type = "button" aria-pressed = { selected } >
70
+ { seatContent }
71
+ </ button >
72
+ ) : (
73
+ < div { ...commonProps } role = "button" aria-pressed = { selected } aria-disabled = "true" >
74
+ { seatContent }
75
+ </ div >
76
+ ) }
77
+ { price && ! ( selected && ! isAvailable ) && (
66
78
< Text size = "small" type = "secondary" >
67
79
{ price }
68
80
</ Text >
0 commit comments