import React from 'react';
import { CompDefault, MetaProps } from '../data-channel';
import classNames from 'classnames';
import { Text, View } from '@tarojs/components';
import connect from '../connect';

export interface Props extends MetaProps {
  active: boolean;
  onChange?: Function;
}

export interface State {}

const defaultValue: CompDefault<Props, State> = {
  props: {
    active: false,
    onChange: (_value) => {},
  },
  state: {},
  meta: {
    output: { tags: ['check-tab', 'search-item'] },
    __mergeCb: (props, meta) => {
      meta.output.key = props.filterKey;
    },
  },
};

/**
 * 普通tab
 */
const TabCommon: React.FC<Props> = ({ onChange, active, meta }) => {
  return (
    <View
      className='wm-tabs-hub-item'
      // fixme 这边value为1写死了，可以考虑外部参数传入
      onClick={() => {
        onChange({ value: 1, meta: meta.output });
      }}>
      <Text className={classNames('text', active && 'active')}>销量</Text>
    </View>
  );
};

export default connect(TabCommon, defaultValue);
