Skip to content

Commit b1149a8

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

1 file changed

Lines changed: 77 additions & 39 deletions

File tree

packages/webapp/components/onboarding/OnboardingV2.tsx

Lines changed: 77 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

@@ -431,6 +465,7 @@ export const OnboardingV2 = (): ReactElement => {
431465
extensionSeen,
432466
router,
433467
setSignupContext,
468+
startGithubImportFlow,
434469
]);
435470

436471
useEffect(() => {
@@ -506,14 +541,10 @@ export const OnboardingV2 = (): ReactElement => {
506541
setShowSignupChooser(true);
507542

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

519550
// Parallax scroll: shift hero layers at different speeds
@@ -1026,25 +1057,27 @@ export const OnboardingV2 = (): ReactElement => {
10261057
position={LogoPosition.Relative}
10271058
className="!left-0 !top-0 !mt-0 !translate-x-0"
10281059
/>
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>
1060+
{!isLoggedIn && (
1061+
<div className="ml-auto flex items-center gap-4">
1062+
<button
1063+
type="button"
1064+
onClick={() => {
1065+
setAuthDisplay(AuthDisplay.Default);
1066+
setShowAuthSignup(true);
1067+
}}
1068+
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"
1069+
>
1070+
Log in
1071+
</button>
1072+
<button
1073+
type="button"
1074+
onClick={() => setShowSignupChooser(true)}
1075+
className="hover:opacity-90 h-10 rounded-14 bg-white px-5 font-bold text-black transition-opacity duration-200 typo-callout"
1076+
>
1077+
Sign up
1078+
</button>
1079+
</div>
1080+
)}
10481081
</header>
10491082

10501083
{/* ── Dummy Sidebar (laptop only) ── */}
@@ -1227,7 +1260,13 @@ export const OnboardingV2 = (): ReactElement => {
12271260
<div className="onb-btn-glow pointer-events-none absolute -inset-3 rounded-20 bg-white/[0.06] blur-xl" />
12281261
<button
12291262
type="button"
1230-
onClick={startGithubImportFlow}
1263+
onClick={() => {
1264+
if (isLoggedIn) {
1265+
startGithubImportFlow();
1266+
} else {
1267+
initiateGithubAuth();
1268+
}
1269+
}}
12311270
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"
12321271
>
12331272
<svg
@@ -1538,7 +1577,7 @@ export const OnboardingV2 = (): ReactElement => {
15381577
{/* Go to feed */}
15391578
<button
15401579
type="button"
1541-
onClick={() => router.replace('/')}
1580+
onClick={() => router.replace(webappUrl)}
15421581
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"
15431582
style={{ animationDelay: '520ms' }}
15441583
>
@@ -2950,13 +2989,12 @@ export const OnboardingV2 = (): ReactElement => {
29502989
<div className="onb-btn-glow pointer-events-none absolute -inset-2 rounded-16 bg-white/[0.04] blur-lg" />
29512990
<button
29522991
type="button"
2953-
onClick={() => {
2992+
onClick={async () => {
29542993
setShowSignupChooser(false);
29552994
if (isLoggedIn) {
29562995
startGithubImportFlow();
29572996
} else {
2958-
setSignupContext('github');
2959-
openSignupAuth();
2997+
initiateGithubAuth();
29602998
}
29612999
}}
29623000
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 +4027,7 @@ export const OnboardingV2 = (): ReactElement => {
39894027
setShowSignupPrompt(false);
39904028
startGithubImportFlow();
39914029
} else {
3992-
openSignupAuth();
4030+
initiateGithubAuth();
39934031
}
39944032
}}
39954033
>

0 commit comments

Comments
 (0)