/*
 * @Description:
 * @Author: jiass
 * @Date: 2022-01-25 13:29:21
 * @LastEditTime: 2022-04-08 16:17:50
 * @LastEditors: lanzhisheng
 */
import React, { FC, useState } from "react";
import { View } from "@tarojs/components";

interface propsType {
  data: [];
  onClick: any;
  defaultValue: number;
}

const TabsButton: FC<propsType> = (props) => {
  const { data, onClick, defaultValue } = props;
  const [baseBtnType, setBaseBtnType] = useState(defaultValue || 1);

  const onClickBaseType = (type) => {
    setBaseBtnType(type);
    onClick(type);
  };

  return (
    <View className="at-row childBtnBox">
      <View className="at-col btnBox">
        {data.map((item: any) => (
          <View
            className={`btn btn1 ${baseBtnType == item?.id ? "active" : ""}`}
            onClick={() => {
              onClickBaseType(item?.id);
            }}
          >
            {item?.name}
          </View>
        ))}
      </View>
    </View>
  );
};
export default TabsButton;
