import clsx from 'clsx' import _ from 'lodash' import { User } from '../../../common/user' import { Row } from '../layout/row' import { CATEGORIES, CATEGORY_LIST } from '../../../common/categories' import { updateUser } from '../../lib/firebase/users' export function CategorySelector(props: { user: User | null | undefined className?: string }) { const { className, user } = props const followedCategories = user?.followedCategories ?? [] return (
{ if (!user?.id) return await updateUser(user.id, { followedCategories: [], }) }} /> {CATEGORY_LIST.map((cat) => ( { if (!user?.id) return await updateUser(user.id, { followedCategories: [cat], }) }} /> ))} ) } function CategoryButton(props: { category: string isFollowed: boolean toggle: () => void }) { const { toggle, category, isFollowed } = props return (
{category}
) }