import clsx from 'clsx' import { getSocialEntries, getSocialUrl, PLATFORM_LABELS, Site, SITE_ORDER, Socials, } from 'common/socials' import {sortBy} from 'lodash' import {Row} from '../layout/row' import {SocialIcon} from './social' const LABELS_TO_RENDER = [ 'okcupid', 'calendly', 'datingdoc', 'friendshipdoc', 'connectiondoc', 'workdoc', ] export function UserHandles(props: {links: Socials; className?: string}) { const {links, className} = props const display = sortBy( getSocialEntries(links), ({platform}) => -[...SITE_ORDER].reverse().indexOf(platform as Site), ) .filter(({platform, value}) => !!value && !!platform) .map(({platform, value, index}) => { let renderedLabel: string = LABELS_TO_RENDER.includes(platform) ? PLATFORM_LABELS[platform as Site] : value renderedLabel = renderedLabel?.replace(/\/+$/, '') // remove trailing slashes renderedLabel = renderedLabel?.replace(/^(https?:\/\/)?(www\.)?/, '') // remove protocol and www return { platform, label: renderedLabel, url: getSocialUrl(platform as any, value), key: `${platform}-${index}`, } }) if (display.length === 0) { return null } return ( {display.map(({platform, label, url, key}) => ( {label} ))} ) }