import { capitalize, plural } from '../../utils' import { Show } from 'solid-js/web' import './Card.scss' import { createMemo } from 'solid-js' import type { Topic } from '../../graphql/types.gen' import { FollowingEntity } from '../../graphql/types.gen' import { t } from '../../utils/intl' import { locale as locstore } from '../../stores/ui' import { useStore } from '@nanostores/solid' import { session } from '../../stores/auth' import { follow, unfollow } from '../../stores/zine/common' interface TopicProps { topic: Topic compact?: boolean subscribed?: boolean shortDescription?: boolean subscribeButtonBottom?: boolean } export const TopicCard = (props: TopicProps) => { const locale = useStore(locstore) const auth = useStore(session) const topic = createMemo(() => props.topic) const subscribed = createMemo(() => { return Boolean(auth()?.user?.slug) && topic().slug ? topic().slug in auth().info.topics : false }) // FIXME use store actions const subscribe = async (really = true) => { if (really) { follow({ what: FollowingEntity.Topic, slug: topic().slug }) } else { unfollow({ what: FollowingEntity.Topic, slug: topic().slug }) } } return (