import { clsx } from 'clsx' import styles from './AuthorBadge.module.scss' import { Userpic } from '../Userpic' import { Author, FollowingEntity } from '../../../graphql/types.gen' import { createMemo, createSignal, Match, Show, Switch } from 'solid-js' import { useLocalize } from '../../../context/localize' import { Button } from '../../_shared/Button' import { useSession } from '../../../context/session' import { follow, unfollow } from '../../../stores/zine/common' import { CheckButton } from '../../_shared/CheckButton' type Props = { author: Author minimizeSubscribeButton?: boolean } export const AuthorBadge = (props: Props) => { const [isSubscribing, setIsSubscribing] = createSignal(false) const { session, subscriptions, actions: { loadSubscriptions, requireAuthentication } } = useSession() const { t, formatDate } = useLocalize() const subscribed = createMemo(() => subscriptions().authors.some((author) => author.slug === props.author.slug) ) const subscribe = async (really = true) => { setIsSubscribing(true) await (really ? follow({ what: FollowingEntity.Author, slug: props.author.slug }) : unfollow({ what: FollowingEntity.Author, slug: props.author.slug })) await loadSubscriptions() setIsSubscribing(false) } const handleSubscribe = (really: boolean) => { requireAuthentication(() => { subscribe(really) }, 'subscribe') } return (
} >