import {HeartIcon} from '@heroicons/react/24/outline' import clsx from 'clsx' import {Profile} from 'common/profiles/profile' import {useState} from 'react' import {Button, buttonClass} from 'web/components/buttons/button' import {Col} from 'web/components/layout/col' import {Modal, MODAL_CLASS} from 'web/components/layout/modal' import {Row} from 'web/components/layout/row' import {Tooltip} from 'web/components/widgets/tooltip' import {useAPIGetter} from 'web/hooks/use-api-getter' import {useProfile} from 'web/hooks/use-profile' import {useUserById} from 'web/hooks/use-user-supabase' import {api} from 'web/lib/api' import {track} from 'web/lib/service/analytics' import {MatchAvatars} from '../matches/match-avatars' export const LikeButton = (props: { targetProfile: Profile liked: boolean refresh: () => Promise className?: string }) => { const {targetProfile, liked, refresh, className} = props const targetId = targetProfile.user_id const [isLoading, setIsLoading] = useState(false) const {data, refresh: refreshHasFreeLike} = useAPIGetter('has-free-like', {}) const hasFreeLike = data?.hasFreeLike ?? false const [showConfirmation, setShowConfirmation] = useState(false) const like = async () => { setShowConfirmation(false) setIsLoading(true) await api('like-profile', {targetUserId: targetId, remove: liked}) track('like profile', { targetId, remove: liked, }) await refresh() setIsLoading(false) await refreshHasFreeLike() } return ( ) } const LikeConfirmationDialog = (props: { targetProfile: Profile hasFreeLike: boolean open: boolean setOpen: (open: boolean) => void submit: () => void }) => { const {open, setOpen, targetProfile, hasFreeLike, submit} = props const youProfile = useProfile() const user = useUserById(targetProfile.user_id) return (
Like {user ? user.name : ''}?
They will get a notification. Unlocks messaging them.
You get one like per day
{youProfile && user && ( )} { }
) } const CancelLikeConfimationDialog = (props: { targetProfile: Profile open: boolean setOpen: (open: boolean) => void submit: () => void }) => { const {open, setOpen, targetProfile, submit} = props const user = useUserById(targetProfile.user_id) return (
Remove like of {user ? user.name : ''}
) }