export default {
  props: {
    disabled: Boolean,
    keys: { type: Array, default: () => [] },
    data: { type: Array, default: () => [] },
    type: { type: String, default: () => "copy" },
    text: { type: String, default: () => "COPY" },
  },
  methods: {
    renderText() {
      return [<a-icon type={this.type} />, this.$t(this.text)];
    },
    handleClick() {
      const row = this.keys.length
        ? this.data.find((list) => list.id === this.keys[0])
        : {};
      this.$emit("copy", row);
    },
  },
  render() {
    const defaultText = this.$scopedSlots.default
      ? this.$scopedSlots.default()
      : this.renderText();
    const props = {
      props: {
        ...this.$props,
      },
      on: {
        click: this.handleClick,
      },
    };
    return (
      <a-button {...props} class={[!this.disabled ? "btn__blue-3" : ""]}>
        {defaultText}
      </a-button>
    );
  },
};
