import React, { useCallback } from "react";
import { Avatar } from "antd";
import { image, locales } from "@pisell/utils";
import classnames from 'classnames';
import User01 from "@pisell/icon/es/User01";
import { isWalkIn as getIsWalkIn } from "../../utils";
import "./index.less";
var ClientItem = function ClientItem(props) {
  var data = props.data,
    _props$coverSize = props.coverSize,
    coverSize = _props$coverSize === void 0 ? 48 : _props$coverSize,
    style = props.style,
    className = props.className,
    walkInName = props.walkInName;
  var getNickname = useCallback(function (item) {
    if (getIsWalkIn(item === null || item === void 0 ? void 0 : item.id)) {
      return walkInName || locales.getText("pisell2.text.select-a-customer");
    }
    return item.name || (item.display_name || "").trim() || (item.nickname || "").trim() || "";
  }, [locales.localeMap]);
  return /*#__PURE__*/React.createElement("div", {
    style: style,
    className: classnames("pisell-lowcode__client-item", className)
  }, /*#__PURE__*/React.createElement(Avatar, {
    className: "pisell-lowcode__client-item-avatar",
    src: image.ali(data === null || data === void 0 ? void 0 : data.cover, 100) || undefined,
    size: coverSize,
    icon: /*#__PURE__*/React.createElement(User01, {
      className: "pisell-lowcode__client-item-avatar-icon"
    })
  }), /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode__client-item-info"
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode__client-item-info-name"
  }, getNickname(data)), /*#__PURE__*/React.createElement("div", {
    className: "pisell-lowcode__client-item-info-desc"
  }, data !== null && data !== void 0 && data.email ? /*#__PURE__*/React.createElement("div", {
    className: ""
  }, data === null || data === void 0 ? void 0 : data.email) : null, data !== null && data !== void 0 && data.phone ? /*#__PURE__*/React.createElement("div", {
    className: ""
  }, data === null || data === void 0 ? void 0 : data.phone) : null)));
};
export default ClientItem;