);
}
export default function OnboardingPage() {
const { t } = useTranslation();
useSeoMeta({
title: t('settingsUi.onboarding.seoTitle'),
description: t('settingsUi.onboarding.seoDescription'),
});
const { user } = useCurrentUser();
const { isInitialized: hasCashu, totalBalance: cashuBalance } = useCashu();
const { toast } = useToast();
const [showRelayEducation, setShowRelayEducation] = useState(false);
const [, setHasSeenRelayEducation] = useLocalStorage('seen-relay-education', false);
// Shared with BackupReminder — the single source of truth for "has the user
// saved their login/key?". The banner below stays until this is true, so
// "remind me later" can never silently become "never" for this critical step.
const [backupConfirmed] = useLocalStorage(backupConfirmedKey(user?.pubkey), false);
// "Where do you skate?" — the single most useful first step. We reuse the
// same last-location cache MapPage reads on mount, so setting it here means
// the map opens on the skater's own area instead of the whole world, and no
// permission prompt surprises them at map load. `hasHome` just hides the
// card once a location exists.
const [locating, setLocating] = useState(false);
const [hasHome, setHasHome] = useState(() => !!getLastLocation());
const handleUseMyLocation = async () => {
setLocating(true);
try {
// getCurrentPosition() also persists the fix via saveLastLocation().
await getCurrentPosition();
setHasHome(true);
toast({ title: t('settingsUi.onboarding.homeSetTitle'), description: t('settingsUi.onboarding.homeSetDesc') });
} catch {
toast({
title: t('settingsUi.onboarding.locationFailedTitle'),
description: t('settingsUi.onboarding.locationFailedDesc'),
variant: 'destructive',
});
} finally {
setLocating(false);
}
};
const handleRelayEducationComplete = () => {
setShowRelayEducation(false);
setHasSeenRelayEducation(true);
toast({
title: t('settingsUi.onboarding.niceTitle'),
description: t('settingsUi.onboarding.niceDesc'),
});
};
const copyNpub = () => {
navigator.clipboard.writeText('npub1yrnuj56rnen08zp2h9h7p74ghgjx6ma39spmpj6w9hzxywutevsst7k5cx');
toast({
title: t('common.copied'),
description: t('settingsUi.onboarding.npubCopied'),
});
};
const bugReportUrl = `/messages/npub1yrnuj56rnen08zp2h9h7p74ghgjx6ma39spmpj6w9hzxywutevsst7k5cx`;
return (
<>
{/* ── Save your login (critical) — pinned ABOVE the hero right after
signup so a new skater sees it immediately, not below the fold.
Stays until the login is actually saved (backup-confirmed). ── */}
{user && !backupConfirmed && (
{/* Primary CTA.
LoginArea (which hosts the multi-step SignupDialog) is kept mounted
even after login and merely hidden — otherwise logging in at the
first signup step would unmount the dialog and skip the profile +
recovery steps. */}