import _identity from 'lodash/identity' import React, { ReactElement } from 'react' import { isValidNumber } from '../../utils/isValidNumber' import config from './config' import { IShareButton } from './index' const SocialComponent = ({ mainLabel, subLabel, platform, shareData, points, onAfterShare, alreadyApplied, oneTimeAction, btnClassName = '', }: IShareButton) => { const Component = config(platform)?.component const Icon = config(platform)?.icon const isActionDisabled = alreadyApplied && oneTimeAction return ( <> {Component && (
{mainLabel} {subLabel} {isValidNumber(points) && (
{points} Points
)}
)} ) } interface SocialButtonsTypes { shareLink: string; name: string; appId: string; showDefaultShareButtons: boolean; shareButtons: IShareButton[]; titleText?: string; footerText?: string | ReactElement; clientLabel?: string; showReferralsInfoText?: boolean; onAfterShare?: (eventActionId: string | undefined) => void; } const SocialButtons = ({ showDefaultShareButtons, shareLink, name, appId, shareButtons, titleText = 'or use one of these convenient buttons:', footerText = (

We never post on Facebook without your permission!

) as ReactElement, clientLabel, onAfterShare = _identity, showReferralsInfoText = false, }: SocialButtonsTypes) => ( <> {titleText &&
{titleText}
}
{showDefaultShareButtons && ( <> )} {shareButtons.map((shareButton: IShareButton, index: number) => ( onAfterShare(shareButton.eventActionId)} key={index} {...shareButton} /> ))}
{showDefaultShareButtons || shareButtons.length ? footerText : null} {(showReferralsInfoText || Boolean(clientLabel)) && (

*Please note, only purchases made from a different{' '} {clientLabel || 'Ticket Fairy'} account can count towards your referrals {' '} so please make sure you ask your friends to buy their own tickets using their own {clientLabel || 'Ticket Fairy'} account!

)} ) export default SocialButtons