Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Onboarding Flow #90

Merged
merged 25 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c0772ec
feat: add onboarding dialog skeleton
RishikeshNK Oct 26, 2024
7f2d845
feat: add basic onboarding flow
RishikeshNK Oct 27, 2024
1d04b46
feat: change onboarding flow order sequence
RishikeshNK Oct 27, 2024
2afc5e0
chore: format
RishikeshNK Oct 27, 2024
55a5f36
chore: add isloading to return null branch
RishikeshNK Oct 27, 2024
2472634
feat: order by created at prayge
RishikeshNK Nov 21, 2024
816626e
feat: add a reusuable onboarding wrapper
RishikeshNK Nov 27, 2024
2058f44
chore: merge main
RishikeshNK Nov 27, 2024
201a217
feat: add cooped field
RishikeshNK Nov 28, 2024
af07501
feat: add post onboarding dialogs
RishikeshNK Nov 28, 2024
29d07c5
feat: add jank af (pls destroy this code when reviewing) post onboard…
RishikeshNK Nov 28, 2024
7eb746f
chore: remove unused logo
RishikeshNK Nov 28, 2024
5504fe1
docs: add basic jsdocs
RishikeshNK Nov 28, 2024
24ee712
refactor: rename variables and add dialog title
RishikeshNK Nov 28, 2024
420487e
chore: also do onboarding flow on the homepage
RishikeshNK Nov 29, 2024
fdfb27b
chore: remove that last change don't need it cause it stacks?
RishikeshNK Nov 29, 2024
2a163dd
feat: graduation year is current + 6
RishikeshNK Nov 30, 2024
f07e247
feat: switch out png for svg
RishikeshNK Nov 30, 2024
c7074dc
Reworking Onboarding
banushi-a Feb 1, 2025
02855bb
Change 'Cooped' Radio Buttons
banushi-a Feb 1, 2025
edba674
I still got it
banushi-a Feb 1, 2025
85769b5
Don't need user router anymore (wasn't working anyways)
banushi-a Feb 1, 2025
e8414fa
Lint + Types
banushi-a Feb 1, 2025
b4e5eed
fix: prevent rerender by disabling refetching
RishikeshNK Feb 2, 2025
81f71fd
Fix Styles + Change Border Radius to lg to match new designs
banushi-a Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/web/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions apps/web/src/app/(pages)/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Toaster } from "@cooper/ui/toaster";

import HeaderLayout from "~/app/_components/header-layout";
import OnboardingWrapper from "~/app/_components/onboarding/onboarding-wrapper";

export default function RootLayout({
children,
Expand All @@ -9,8 +10,10 @@ export default function RootLayout({
}) {
return (
<HeaderLayout>
{children}
<Toaster />
<OnboardingWrapper>
{children}
<Toaster />
</OnboardingWrapper>
</HeaderLayout>
);
}
21 changes: 21 additions & 0 deletions apps/web/src/app/_components/onboarding/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const monthOptions = [
{ value: "1", label: "January" },
{ value: "2", label: "February" },
{ value: "3", label: "March" },
{ value: "4", label: "April" },
{ value: "5", label: "May" },
{ value: "6", label: "June" },
{ value: "7", label: "July" },
{ value: "8", label: "August" },
{ value: "9", label: "September" },
{ value: "10", label: "October" },
{ value: "11", label: "November" },
{ value: "12", label: "December" },
];

export const majors = [
"Computer Science",
"Computer Science + Math",
"Computer Science + Business",
"Computer Science + Design",
];
57 changes: 57 additions & 0 deletions apps/web/src/app/_components/onboarding/dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"use client";

import { useState } from "react";

import type { Session } from "@cooper/auth";
import { Dialog, DialogContent } from "@cooper/ui/dialog";

import { OnboardingForm } from "~/app/_components/onboarding/onboarding-form";
import { api } from "~/trpc/react";

interface OnboardingDialogProps {
isOpen?: boolean;
session: Session | null;
}

/**
* OnboardingDialog component that handles user onboarding.
* Implementation note: Use OnboardingWrapper to wrap the component and initiate the dialog.
* @param isOpen - Whether the dialog is open
* @param session - The current user session
* @returns The OnboardingDialog component or null
*/
export function OnboardingDialog({
isOpen = true,
session,
}: OnboardingDialogProps) {
const [open, setOpen] = useState<boolean>(isOpen);

const profile = api.profile.getCurrentUser.useQuery(undefined, {
refetchOnWindowFocus: false,
});

const shouldShowOnboarding = session && !profile.data;

const closeDialog = () => {
setOpen(false);
};

if (profile.isPending || !shouldShowOnboarding) {
return null;
}

return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent
className="max-h-[90dvh] max-w-[85dvw] overflow-y-scroll rounded-lg p-8 md:max-w-[70dvw] lg:max-w-[46rem] lg:p-12"
aria-describedby="The form to create a Cooper profile once you have logged in with a husky google account."
>
<OnboardingForm
userId={session.user.id}
closeDialog={closeDialog}
session={session}
/>
</DialogContent>
</Dialog>
);
}
Loading