import React from "react" import * as antd from "antd" import classnames from "classnames" import { Icons, createIconRender } from "components/Icons" import { Image, UserBadges, FollowButton } from "components" import linksDecorators from "schemas/userLinksDecorators" import "./index.less" function processValue(value, decorator) { if (decorator.hrefResolve) { if (!String(value).includes(decorator.hrefResolve)) { return `${decorator.hrefResolve}${value}` } } return value } const UserLinkViewer = (props) => { const { link, decorator } = props return
{ createIconRender(decorator.icon ?? "MdLink") }

{ link.value }

} const UserLink = (props) => { let { index, link } = props link.key = link.key.toLowerCase() const decorator = linksDecorators[link.key] ?? {} link.value = processValue(link.value, decorator) const hasHref = String(link.value).includes("://") const handleOnClick = () => { if (!hasHref) { if (app.isMobile) { app.DrawerController.open("link_viewer", UserLinkViewer, { componentProps: { link: link, decorator: decorator } }) } return false } window.open(link.value, "_blank") } const renderName = () => { if (decorator.hrefResolve) { return decorator.label ?? link.value } return link.value } return } export const UserCard = React.forwardRef((props, ref) => { const [user, setUser] = React.useState(props.user) // TODO: Support API user data fetching return

{user.fullName || user.username} {user.verified && }

@{user.username}
{ user.badges?.length > 0 && }

{user.description}

{ user.links && Array.isArray(user.links) && user.links.length > 0 &&
{ user.links.map((link, index) => { return }) }
}
}) export const MobileUserCard = React.forwardRef((props, ref) => { return
{ props.user.cover &&
} { !props.user.cover &&
}

{ props.user.fullName ?? `@${props.user.username}` } { props.user.verified && }

{ props.user.fullName && @{props.user.username} }
{ props.user.badges?.length > 0 && }

{ props.user.description }

{ props.user.links && Array.isArray(props.user.links) && props.user.links.length > 0 &&
{ props.user.links.map((link, index) => { return }) }
}
{ props.followers && } } disabled /> } />
}) export default UserCard