Feature: Add an onboarding page and redirect users to that page if the user is not logged in. Have 3 sample latest question an... - #73
Open
lazydev-issue-resolver[bot] wants to merge 1 commit into
Conversation
Generated autonomously by LazyDev.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #72
Generated autonomously by LazyDev.
Implementation Plan
Core Technical Requirements
/onboardingroute with:Metadatatitle of"Onboarding"/onboardinginstead of/loginor being allowed into protected routes./onboardingpublic; authenticated users who visit it should be redirected to the home page (or dashboard).Step-by-Step Implementation Plan
1. Locate the current auth guard and redirect logic
First, inspect the existing authentication flow. Likely files:
components/auth-provider.tsxapp/login/page.tsxmiddleware.tsat project rootapp/layout.tsxDetermine exactly how protected routes are currently handled:
AuthProvider) that wraps pages and checksusePathname()+useRouter(), note its public route allowlist and current login redirect.middleware.ts, note the matcher and redirect target.Action: Modify that logic so the public routes list includes
/onboarding, and the unauthenticated redirect target becomes/onboarding.2. Create the onboarding page
Create
app/onboarding/page.tsx(orapp/(public)/onboarding/page.tsxif route groups are used).Add:
Include:
"Welcome to [App Name]!""Latest questions"/loginand/(only if meaningful for public users)useEffectredirect for authenticated users:Or, if using a server-side session/cookie, perform the redirect server-side.
3. Add a data-fetching method for the latest 3 Q&As
You likely already have a database layer in
lib/mongodb.tsand type definitions inlib/types.ts.Create/reuse a function such as:
If the app normally talks to the backend through API routes instead of direct DB calls, do one of the following:
app/api/questions/latest/route.tswith aGEThandler that returns the latest 3.?limit=3&sort=latest.Then the onboarding page can fetch from that endpoint.
4. Build the sample Q&A UI
Create a dedicated component, e.g.:
// components/onboarding/latest-questions.tsxIt should:
Skeletonloading state while fetchingUse existing shadcn/ui components like
Card,Badge, andButtonto keep styling consistent with the rest of the app.5. Integrate into the onboarding page
Import
LatestQuestionsintoapp/onboarding/page.tsx.Place it after the greeting copy so the layout is:
6. Update the auth guard to redirect unauthenticated users to
/onboardingExample if the guard is in
components/auth-provider.tsx:'onboarding'to the public paths array if not already allowed./loginto/onboarding.Example if using
middleware.ts:Ensure
/onboardingitself is never blocked by the guard.7. Redirect authenticated users away from
/onboardingIn
app/onboarding/page.tsx, check auth state:useAuth()anduseEffectto redirect to/.This prevents logged-in users from seeing the onboarding screen.
8. Add styling and responsive layout
Use Tailwind classes in the page/component:
max-w-3xl mx-autofor the containerNo global CSS changes should be needed if Tailwind is already configured.
9. Manual verification checklist
/→ redirected to/onboarding/onboarding/onboarding→ sees page with greeting and 3 latest Q&As"Onboarding"/onboarding→ redirected to/Affected Files Summary
app/onboarding/page.tsxcomponents/onboarding/latest-questions.tsxlib/questions.ts(or similar)getLatestQuestions(limit)app/api/questions/latest/route.tscomponents/auth-provider.tsx/middleware.ts/onboardingapp/login/page.tsx(if applicable)lib/types.ts(if needed)This plan keeps the change minimal, follows the existing Next.js App Router structure, and directly resolves the missing onboarding screen, auth redirect, and sample content requirements.