-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialog.tsx
More file actions
57 lines (47 loc) · 1.56 KB
/
dialog.tsx
File metadata and controls
57 lines (47 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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-auto rounded-lg p-6 md:max-w-[70dvw] lg:max-w-[46rem] lg:p-8"
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>
);
}