import Styles from "@/constants/Styles";
import { Dimensions, View } from "react-native";
import { BarChart } from "react-native-gifted-charts";
import Text from "../Text";

export default function ReportChartEvent({ data }: { data: { label: string; value: number; }[] }) {
   const width = Dimensions.get("window").width;
   const maxValue = Math.max(...data.map(i => i.value))
   const barData = [
      { value: 23, label: 'Akan Datang', },
      { value: 12, label: 'Selesai' },
   ];

   return (
      <View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
         <Text style={[Styles.textSubtitle, Styles.mv15]}>ACARA DIVISI</Text>
         <BarChart
            showFractionalValues={false}
            showYAxisIndices
            noOfSections={maxValue < 5 ? 2 : 4}
            maxValue={maxValue}
            frontColor="#177AD5"
            data={data}
            isAnimated
            width={width - 140}
            barWidth={width * 0.25}
            renderTooltip={(item: any, index: any) => {
               return (
                  <View
                     style={{
                        alignItems: 'center',
                        justifyContent: 'center',
                        width: width * 0.25
                     }}>
                     <Text>{item.value}</Text>
                  </View>
               );
            }}
         />
      </View>
   )
}