import clsx from 'clsx' import { useState } from 'react' import { SearchIcon } from '@heroicons/react/outline' import { User } from '../../../common/user' import { followFoldFromSlug, unfollowFoldFromSlug, } from '../../lib/firebase/folds' import { Row } from '../layout/row' import { Spacer } from '../layout/spacer' function FollowFoldButton(props: { fold: { slug: string; name: string } user: User | null | undefined isFollowed?: boolean }) { const { fold, user, isFollowed } = props const { slug, name } = fold const [followed, setFollowed] = useState(isFollowed) const onClick = async () => { if (followed) { if (user) await unfollowFoldFromSlug(slug, user.id) setFollowed(false) } else { if (user) await followFoldFromSlug(slug, user.id) setFollowed(true) } } return (
{name}
) } function FollowFolds(props: { folds: { slug: string; name: string }[] followedFoldSlugs: string[] noLabel?: boolean className?: string user: User | null | undefined }) { const { folds, noLabel, className, user, followedFoldSlugs } = props return ( {folds.length > 0 && ( <> {!noLabel &&
Communities
} {folds.map((fold) => ( ))} )}
) } export const FastFoldFollowing = (props: { followedFoldSlugs: string[] user: User | null | undefined }) => { const { followedFoldSlugs, user } = props return ( <> ) }