@@ -2,7 +2,7 @@ import { forwardRef, useEffect, useMemo } from "react";
22import { twMerge } from "tailwind-merge" ;
33import { dataAttributes , seatStatusColors } from "@/constants" ;
44import { ISTKProps } from "@/types" ;
5- import { ISeat , ISeatCategory , SeatStatus } from "@/types/elements" ;
5+ import { ISeat , ISeatCategory , ISection , SeatStatus } from "@/types/elements" ;
66import { d3Extended } from "@/utils" ;
77
88export const seatSize = 28 ;
@@ -14,12 +14,17 @@ export interface ISeatProps extends ISeat {
1414 consumer : ISTKProps ;
1515 element : ISeat ;
1616 categories : ISeatCategory [ ] ;
17+ sections : ISection [ ] ;
1718 onClick : ( e : any ) => void ;
1819}
1920
2021const Seat : React . FC < ISeatProps > = forwardRef (
21- ( { x, y, id, label, categories, category, status, onClick, consumer, element, ...props } , ref : any ) => {
22+ ( { x, y, id, label, categories, category, sections , status, onClick, consumer, element, ...props } , ref : any ) => {
2223 const categoryObject = useMemo ( ( ) => categories ?. find ?.( ( c ) => c . id === category ) , [ categories , category ] ) ;
24+ const sectionObject = useMemo (
25+ ( ) => sections ?. find ?.( ( s ) => s . id === categoryObject ?. section ) ,
26+ [ sections , categoryObject ]
27+ ) ;
2328
2429 const showLabel = consumer . options ?. showSeatLabels ?? true ;
2530
@@ -55,7 +60,7 @@ const Seat: React.FC<ISeatProps> = forwardRef(
5560 onClick ( e ) ;
5661 consumer . events ?. onSeatClick ?.( {
5762 ...element ,
58- category : categoryObject
63+ category : categoryObject ? { ... categoryObject , section : sectionObject } : null
5964 } ) ;
6065 } ;
6166
@@ -69,6 +74,7 @@ const Seat: React.FC<ISeatProps> = forwardRef(
6974 r = { seatSize / 2 }
7075 onClick = { localOnClick }
7176 { ...{ [ dataAttributes . category ] : category } }
77+ { ...{ [ dataAttributes . section ] : categoryObject ?. section } }
7278 { ...{ [ dataAttributes . status ] : status ?? SeatStatus . Available } }
7379 { ...props }
7480 className = { twMerge ( props . className , "filter hover:brightness-[1.05]" ) }
0 commit comments