3165e42119
* add trigger for updated user * Add referral bonuses and notifications for them * Cleanup * Add share group button, cleanup * Cleanup * Add referrals list to user profile * Remove unused * Referral bonus => constant * Refactor * Add referral txn to helper fn * Move reads into firebase transaction * Use effects to write referral info * Flex-wrap profile objects * Small ui changes * Restrict referral user to one update * Remove rogue semicolon * Note about group referral query details * Track referrals, add them to settings list
13 lines
373 B
TypeScript
13 lines
373 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { listenForReferrals } from 'web/lib/firebase/users'
|
|
|
|
export const useReferrals = (userId: string | null | undefined) => {
|
|
const [referralIds, setReferralIds] = useState<string[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (userId) return listenForReferrals(userId, setReferralIds)
|
|
}, [userId])
|
|
|
|
return referralIds
|
|
}
|