import { AdminUserIdentity } from "@/shared/ui/AdminUserIdentity.jsx";
import styles from "@/features/host-org/host-org.module.css";

export function HostOrgPerson({ avatar, displayUserId, fallbackId, prettyDisplayUserId, prettyId, username }) {
    return (
        <AdminUserIdentity
            avatar={avatar}
            displayUserId={displayUserId}
            name={username}
            openInAppUserDetail
            prettyDisplayUserId={prettyDisplayUserId}
            prettyId={prettyId}
            userId={fallbackId}
        />
    );
}

export function HostOrgEntity({ id, name, prefix = "" }) {
    if (!id && !name) {
        return "-";
    }
    return (
        <span className={styles.sellerText}>
            <span className={styles.sellerName}>{name || "-"}</span>
            <span className={styles.sellerMeta}>
                {prefix}
                {id || "-"}
            </span>
        </span>
    );
}

export function hostOrgRegionName(item, regionOptions = []) {
    if (item.regionName) {
        return item.regionName;
    }
    const option = regionOptions.find((region) => String(region.value) === String(item.regionId));
    return option?.name || item.regionId || "-";
}
