import clsx from 'clsx' import { useState } from 'react' import { SearchIcon } from '@heroicons/react/outline' import { User } from 'common/user' import { followFoldFromSlug, unfollowFoldFromSlug, } from 'web/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 (