Skip to content

Commit 754db92

Browse files
committed
feat: make onboarding project step skippable
1 parent efcd3e3 commit 754db92

1 file changed

Lines changed: 37 additions & 7 deletions

File tree

‎apps/web-dashboard/src/pages/Onboarding.jsx‎

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,36 @@ export default function Onboarding() {
357357
}
358358
};
359359

360-
const handleFinishOnboarding = async () => {
360+
const handleCompleteStep3 = async () => {
361+
try {
362+
await api.patch('/api/user/onboarding', {
363+
steps: { firstApiCall: true },
364+
completed: true
365+
});
366+
const updatedUser = { ...user };
367+
updatedUser.onboarding.steps.firstApiCall = true;
368+
updatedUser.onboarding.completed = true;
369+
login(updatedUser);
370+
navigate('/dashboard');
371+
} catch (err) {
372+
console.error(err);
373+
toast.error("Failed to finish onboarding. Moving to dashboard anyway.");
374+
navigate('/dashboard');
375+
}
376+
};
377+
378+
const handleSkipOnboarding = async () => {
361379
try {
362380
await api.patch('/api/user/onboarding', { completed: true });
363-
} catch (e) {
364-
console.error("Failed to mark onboarding as completed", e);
381+
const updatedUser = { ...user };
382+
if (!updatedUser.onboarding) updatedUser.onboarding = { steps: {} };
383+
updatedUser.onboarding.completed = true;
384+
login(updatedUser);
385+
navigate('/dashboard');
386+
} catch (err) {
387+
console.error(err);
388+
toast.error('Failed to skip onboarding');
365389
}
366-
await refreshUser();
367-
navigate('/dashboard');
368390
};
369391

370392
const copyToClipboard = (text) => {
@@ -591,6 +613,14 @@ export default function Onboarding() {
591613
>
592614
{projectLoading ? <RefreshCw className="animate-spin" size={16} /> : 'Create & Continue'}
593615
</button>
616+
617+
<button
618+
type="button"
619+
onClick={handleSkipOnboarding}
620+
style={{ marginTop: '0.5rem', background: 'transparent', color: 'var(--color-text-muted)', border: 'none', cursor: 'pointer', fontSize: '0.85rem' }}
621+
>
622+
Skip onboarding and go to dashboard
623+
</button>
594624
</form>
595625
)}
596626
</div>
@@ -835,15 +865,15 @@ export default function Onboarding() {
835865
{!testSuccess ? (
836866
<button
837867
type="button"
838-
onClick={handleFinishOnboarding}
868+
onClick={handleCompleteStep3}
839869
style={{ background: 'transparent', color: 'var(--color-text-muted)', border: 'none', cursor: 'pointer', fontSize: '0.9rem', textDecoration: 'underline' }}
840870
>
841871
Skip & Launch Dashboard
842872
</button>
843873
) : <div />}
844874
<button
845875
type="button"
846-
onClick={handleFinishOnboarding}
876+
onClick={handleCompleteStep3}
847877
className="btn-primary"
848878
>
849879
Launch Dashboard <Rocket size={18} />

0 commit comments

Comments
 (0)