diff --git a/web/pages/referrals.tsx b/web/pages/referrals.tsx index 23f65eb6..798a28e8 100644 --- a/web/pages/referrals.tsx +++ b/web/pages/referrals.tsx @@ -1,9 +1,11 @@ import {ENV_CONFIG} from 'common/envs/constants' -import {CopyLinkRow} from 'web/components/buttons/copy-link-button' +import {useEffect, useState} from 'react' import {Col} from 'web/components/layout/col' import {PageBase} from 'web/components/page-base' import {SEO} from 'web/components/SEO' +import {Input} from 'web/components/widgets/input' import {QRCode} from 'web/components/widgets/qr-code' +import {ShareCTAButton} from 'web/components/widgets/share-cta-button' import {Title} from 'web/components/widgets/title' import {useUser} from 'web/hooks/use-user' import {useT} from 'web/lib/locale' @@ -12,10 +14,17 @@ export default function ReferralsPage() { const user = useUser() const t = useT() - const url = user + const defaultUrl = user ? `https://${ENV_CONFIG.domain}/?referrer=${user.username}` : `https://${ENV_CONFIG.domain}/` + // Editable: the share sheet and the QR code follow whatever is in the field, so a user can tweak the + // link (a different landing path, an extra param) and still share exactly what they see. + const [url, setUrl] = useState(defaultUrl) + + // `user` arrives after first paint, so the field starts on the logged-out URL and has to catch up. + useEffect(() => setUrl(defaultUrl), [defaultUrl]) + const title = t('referrals.title', `Invite someone to join Compass!`) return ( @@ -25,7 +34,26 @@ export default function ReferralsPage() {