Skip to content

Commit 47aa464

Browse files
committed
feat: some flow adjustments, github, ai, complete state
1 parent e9ea2a7 commit 47aa464

1 file changed

Lines changed: 76 additions & 39 deletions

File tree

packages/webapp/components/onboarding/OnboardingV2.tsx

Lines changed: 76 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { useAuthContext } from '@dailydotdev/shared/src/contexts/AuthContext';
2020
import {
2121
downloadBrowserExtension,
2222
mobileAppUrl,
23+
webappUrl,
24+
onboardingUrl,
2325
} from '@dailydotdev/shared/src/lib/constants';
2426
import { UserExperienceLevel } from '@dailydotdev/shared/src/lib/user';
2527
import { AuthTriggers } from '@dailydotdev/shared/src/lib/auth';
@@ -54,6 +56,7 @@ import usePersistentContext from '@dailydotdev/shared/src/hooks/usePersistentCon
5456
import { ActionType } from '@dailydotdev/shared/src/graphql/actions';
5557
import { redirectToApp } from '@dailydotdev/shared/src/features/onboarding/lib/utils';
5658
import { useOnboardingActions } from '@dailydotdev/shared/src/hooks/auth';
59+
import { getBetterAuthSocialUrl } from '@dailydotdev/shared/src/lib/betterAuth';
5760

5861
type RisingTag = {
5962
label: string;
@@ -325,11 +328,10 @@ export const OnboardingV2 = (): ReactElement => {
325328
]);
326329

327330
if (apiResult.status === 'fulfilled') {
328-
router.replace(
329-
{ query: { ...router.query, step: 'complete' } },
330-
undefined,
331-
{ shallow: true },
332-
);
331+
router.replace({
332+
pathname: `${webappUrl}onboarding`,
333+
query: { ...router.query, step: 'complete' },
334+
});
333335
completeAction(ActionType.CompletedOnboarding);
334336
completeAction(ActionType.EditTag);
335337
completeAction(ActionType.ContentTypes);
@@ -357,6 +359,17 @@ export const OnboardingV2 = (): ReactElement => {
357359
startImportFlow('github');
358360
}, [startImportFlow]);
359361

362+
const initiateGithubAuth = useCallback(async () => {
363+
setSignupContext('github');
364+
const url = await getBetterAuthSocialUrl(
365+
'github',
366+
`${onboardingUrl}?flow=github`,
367+
);
368+
if (url) {
369+
window.location.href = url;
370+
}
371+
}, [setSignupContext]);
372+
360373
const closeGithubImportFlow = useCallback(() => {
361374
clearGithubImportTimer();
362375
clearGithubResumeTimeout();
@@ -398,18 +411,39 @@ export const OnboardingV2 = (): ReactElement => {
398411
}, [applyThemeMode]);
399412

400413
useEffect(() => {
401-
if (!isAuthReady || !isOnboardingActionsReady) {
414+
if (!isAuthReady) {
402415
return;
403416
}
404417

405418
const step = router.query.step as string | undefined;
406419

407420
if (step === 'complete') {
421+
if (!isLoggedIn) {
422+
router.replace(`${webappUrl}onboarding`);
423+
return;
424+
}
425+
408426
if (extensionSeen) {
409427
setFeedReadyState(true);
410428
} else {
411429
setShowExtensionPromo(true);
412430
}
431+
432+
return;
433+
}
434+
435+
const flow = router.query.flow as string | undefined;
436+
437+
if (flow === 'github') {
438+
if (!isLoggedIn) {
439+
router.replace(`${webappUrl}onboarding`);
440+
return;
441+
}
442+
startGithubImportFlow();
443+
return;
444+
}
445+
446+
if (!isOnboardingActionsReady) {
413447
return;
414448
}
415449

@@ -506,14 +540,10 @@ export const OnboardingV2 = (): ReactElement => {
506540
setShowSignupChooser(true);
507541

508542
const { onbSignup, ...restQuery } = router.query;
509-
router.replace(
510-
{
511-
pathname: router.pathname,
512-
query: restQuery,
513-
},
514-
undefined,
515-
{ shallow: true },
516-
);
543+
router.replace({
544+
pathname: router.pathname,
545+
query: restQuery,
546+
});
517547
}, [router]);
518548

519549
// Parallax scroll: shift hero layers at different speeds
@@ -1026,25 +1056,27 @@ export const OnboardingV2 = (): ReactElement => {
10261056
position={LogoPosition.Relative}
10271057
className="!left-0 !top-0 !mt-0 !translate-x-0"
10281058
/>
1029-
<div className="ml-auto flex items-center gap-4">
1030-
<button
1031-
type="button"
1032-
onClick={() => {
1033-
setAuthDisplay(AuthDisplay.Default);
1034-
setShowAuthSignup(true);
1035-
}}
1036-
className="h-10 rounded-14 border border-border-subtlest-tertiary px-5 font-bold text-text-primary transition-colors duration-200 typo-callout hover:bg-surface-hover"
1037-
>
1038-
Log in
1039-
</button>
1040-
<button
1041-
type="button"
1042-
onClick={() => setShowSignupChooser(true)}
1043-
className="hover:opacity-90 h-10 rounded-14 bg-white px-5 font-bold text-black transition-opacity duration-200 typo-callout"
1044-
>
1045-
Sign up
1046-
</button>
1047-
</div>
1059+
{!isLoggedIn && (
1060+
<div className="ml-auto flex items-center gap-4">
1061+
<button
1062+
type="button"
1063+
onClick={() => {
1064+
setAuthDisplay(AuthDisplay.Default);
1065+
setShowAuthSignup(true);
1066+
}}
1067+
className="h-10 rounded-14 border border-border-subtlest-tertiary px-5 font-bold text-text-primary transition-colors duration-200 typo-callout hover:bg-surface-hover"
1068+
>
1069+
Log in
1070+
</button>
1071+
<button
1072+
type="button"
1073+
onClick={() => setShowSignupChooser(true)}
1074+
className="hover:opacity-90 h-10 rounded-14 bg-white px-5 font-bold text-black transition-opacity duration-200 typo-callout"
1075+
>
1076+
Sign up
1077+
</button>
1078+
</div>
1079+
)}
10481080
</header>
10491081

10501082
{/* ── Dummy Sidebar (laptop only) ── */}
@@ -1227,7 +1259,13 @@ export const OnboardingV2 = (): ReactElement => {
12271259
<div className="onb-btn-glow pointer-events-none absolute -inset-3 rounded-20 bg-white/[0.06] blur-xl" />
12281260
<button
12291261
type="button"
1230-
onClick={startGithubImportFlow}
1262+
onClick={() => {
1263+
if (isLoggedIn) {
1264+
startGithubImportFlow();
1265+
} else {
1266+
initiateGithubAuth();
1267+
}
1268+
}}
12311269
className="onb-btn-shine focus-visible:ring-white/20 group relative flex w-full items-center justify-center gap-2.5 overflow-hidden rounded-14 bg-white px-7 py-3.5 font-bold text-black transition-all duration-300 typo-callout hover:-translate-y-1 hover:shadow-[0_8px_30px_rgba(255,255,255,0.12)] focus-visible:outline-none focus-visible:ring-2 tablet:w-auto"
12321270
>
12331271
<svg
@@ -1538,7 +1576,7 @@ export const OnboardingV2 = (): ReactElement => {
15381576
{/* Go to feed */}
15391577
<button
15401578
type="button"
1541-
onClick={() => router.replace('/')}
1579+
onClick={() => router.replace(webappUrl)}
15421580
className="onb-ready-reveal mt-6 flex items-center gap-2 rounded-12 bg-white/[0.08] px-5 py-2.5 text-text-secondary transition-all duration-200 typo-callout hover:bg-white/[0.14] hover:text-text-primary"
15431581
style={{ animationDelay: '520ms' }}
15441582
>
@@ -2950,13 +2988,12 @@ export const OnboardingV2 = (): ReactElement => {
29502988
<div className="onb-btn-glow pointer-events-none absolute -inset-2 rounded-16 bg-white/[0.04] blur-lg" />
29512989
<button
29522990
type="button"
2953-
onClick={() => {
2991+
onClick={async () => {
29542992
setShowSignupChooser(false);
29552993
if (isLoggedIn) {
29562994
startGithubImportFlow();
29572995
} else {
2958-
setSignupContext('github');
2959-
openSignupAuth();
2996+
initiateGithubAuth();
29602997
}
29612998
}}
29622999
className="onb-btn-shine focus-visible:ring-white/20 group relative flex w-full items-center justify-center gap-2.5 overflow-hidden rounded-14 bg-white px-5 py-3.5 font-bold text-black transition-all duration-300 typo-callout hover:-translate-y-1 hover:shadow-[0_8px_30px_rgba(255,255,255,0.12)] focus-visible:outline-none focus-visible:ring-2"
@@ -3989,7 +4026,7 @@ export const OnboardingV2 = (): ReactElement => {
39894026
setShowSignupPrompt(false);
39904027
startGithubImportFlow();
39914028
} else {
3992-
openSignupAuth();
4029+
initiateGithubAuth();
39934030
}
39944031
}}
39954032
>

0 commit comments

Comments
 (0)