Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Settings page + Onboarding

Richie McIlroy7eaaa962f78e
diff --git a/.env.example b/.env.example
index e1e37adce..964cc6946 100644
--- a/.env.example
+++ b/.env.example
@@ -25,7 +25,6 @@ NEXT_PUBLIC_URL=http://localhost:3000
NEXT_PUBLIC_LOCAL_MODE=false
# -- database ****************
-DB_MYSQL_MIGRATION_URL="mysql://root:@localhost:3306/planetscale"
DB_PLANETSCALE_HOST=localhost:3900
DB_PLANETSCALE_DATABASE=planetscale
DB_PLANETSCALE_USERNAME=root
diff --git a/apps/web/app/api/playlist/route.ts b/apps/web/app/api/playlist/route.ts
index 014e1e9ee..a1b812acf 100644
--- a/apps/web/app/api/playlist/route.ts
+++ b/apps/web/app/api/playlist/route.ts
@@ -86,7 +86,7 @@ export async function GET(request: NextRequest) {
if (video.public === false) {
const user = await getCurrentUser();
- if (!user || user.userId !== video.ownerId) {
+ if (!user || user.id !== video.ownerId) {
return new Response(
JSON.stringify({ error: true, message: "Video is not public" }),
{
diff --git a/apps/web/app/api/settings/user/name/route.ts b/apps/web/app/api/settings/user/name/route.ts
new file mode 100644
index 000000000..1c4daf5d3
--- /dev/null
+++ b/apps/web/app/api/settings/user/name/route.ts
@@ -0,0 +1,38 @@
+import { type NextRequest } from "next/server";
+import { getCurrentUser } from "@cap/database/auth/session";
+import { users } from "@cap/database/schema";
+import { db } from "@cap/database";
+import { eq } from "drizzle-orm";
+
+export async function POST(request: NextRequest) {
+ const user = await getCurrentUser();
+ const { firstName, lastName } = await request.json();
+
+ if (!user) {
+ console.error("User not found");
+
+ return new Response(JSON.stringify({ error: true }), {
+ status: 401,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+ }
+
+ await db
+ .update(users)
+ .set({
+ name: firstName,
+ lastName: lastName,
+ })
+ .where(eq(users.id, user.id));
+
+ return new Response(
+ JSON.stringify({
+ status: 200,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ })
+ );
+}
diff --git a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
index d11a50be7..166aa10cd 100644
--- a/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
+++ b/apps/web/app/dashboard/_components/AdminNavbar/AdminNavItems.tsx
@@ -115,7 +115,7 @@ export const AdminNavItems = () => {
key={item.name}
href={item.href}
className={classNames(
- pathname == item.href
+ pathname.includes(item.href)
? "bg-gray-200"
: "opacity-75 hover:opacity-100",
navItemClass
diff --git a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
index 1128589ab..e1725e75d 100644
--- a/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
+++ b/apps/web/app/dashboard/_components/DynamicSharedLayout.tsx
@@ -2,11 +2,11 @@
import { createContext, useContext } from "react";
import AdminDesktopNav from "@/app/dashboard/_components/AdminNavbar/AdminDesktopNav";
import AdminMobileNav from "@/app/dashboard/_components/AdminNavbar/AdminMobileNav";
-import type { Database } from "@cap/utils";
type SharedContext = {
- spaceData: Database["public"]["Tables"]["spaces"]["Row"][] | null;
- activeSpace: Database["public"]["Tables"]["spaces"]["Row"] | null;
+ spaceData: null;
+ activeSpace: null;
+ user: typeof users.$inferSelect | null;
};
const Context = createContext<SharedContext>({} as SharedContext);
@@ -15,13 +15,15 @@ export default function DynamicSharedLayout({
children,
spaceData,
activeSpace,
+ user,
}: {
children: React.ReactNode;
spaceData: SharedContext["spaceData"];
activeSpace: SharedContext["activeSpace"];
+ user: SharedContext["user"];
}) {
return (
- <Context.Provider value={{ spaceData, activeSpace }}>
+ <Context.Provider value={{ spaceData, activeSpace, user }}>
<div className="dashboard-layout h-screen min-h-full flex">
<AdminDesktopNav />
<div className="flex-1 overflow-auto focus:outline-none">
diff --git a/apps/web/app/dashboard/caps/Caps.tsx b/apps/web/app/dashboard/caps/Caps.tsx
index 6436262db..1eadaaabd 100644
--- a/apps/web/app/dashboard/caps/Caps.tsx
+++ b/apps/web/app/dashboard/caps/Caps.tsx
@@ -55,7 +55,8 @@ export const Caps = ({ data }: { data: videoData }) => {
</div>
<div className="text-center">
<h1 className="text-2xl font-semibold mb-3">
- Record your first Cap.
+ <span className="block">Hey, </span>
+ <span className="block">Record your first Cap.</span>
</h1>
<p className="text-xl max-w-md">
Craft your narrative with a Cap—get projects done quicker.
diff --git a/apps/web/app/dashboard/caps/page.tsx b/apps/web/app/dashboard/caps/page.tsx
index 3a59265ed..e559d3c36 100644
--- a/apps/web/app/dashboard/caps/page.tsx
+++ b/apps/web/app/dashboard/caps/page.tsx
@@ -3,12 +3,17 @@ import { db } from "@cap/database";
import { comments, videos } from "@cap/database/schema";
import { desc, eq, sql } from "drizzle-orm";
import { getCurrentUser } from "@cap/database/auth/session";
+import { redirect } from "next/navigation";
export const revalidate = 0;
export default async function CapsPage() {
const user = await getCurrentUser();
- const userId = user?.userId as string;
+ const userId = user?.id as string;
+
+ if (user !== null && (user.name === null || user.name.length === 0)) {
+ return redirect("/onboarding");
+ }
const videoData = await db
.select({
diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx
index 26e4e278e..c88a29e21 100644
--- a/apps/web/app/dashboard/layout.tsx
+++ b/apps/web/app/dashboard/layout.tsx
@@ -1,18 +1,9 @@
"use server";
import DynamicSharedLayout from "@/app/dashboard/_components/DynamicSharedLayout";
-// import {
-// createSupabaseServerClient,
-// getSession,
-// getActiveSpace,
-// } from "@/utils/database/supabase/server";
-// import SupabaseProvider from "@/utils/database/supabase/provider";
-// import SupabaseListener from "@/utils/database/supabase/listener";
import { getCurrentUser } from "@cap/database/auth/session";
import { redirect } from "next/navigation";
import { DashboardTemplate } from "@/components/templates/DashboardTemplate";
-//TODO: Auth
-
export default async function DashboardLayout({
children,
}: {
@@ -23,23 +14,8 @@ export default async function DashboardLayout({
if (!user) {
redirect("/login");
}
-
- // if (!user.name) {
- // redirect("/onboarding");
- // }
-
- // const supabase = await createSupabaseServerClient();
- // const spaceData = await supabase
- // .from("spaces")
- // .select("*")
- // .order("created_at", { ascending: true });
- // const activeSpace = await getActiveSpace();
- // const session = await getSession();
-
- // console.log("session", session);
-
return (
- <DynamicSharedLayout spaceData={null} activeSpace={null}>
+ <DynamicSharedLayout spaceData={null} activeSpace={null} user={user}>
<div className="full-layout">
<DashboardTemplate>{children}</DashboardTemplate>
</div>
diff --git a/apps/web/app/dashboard/settings/Caps.tsx b/apps/web/app/dashboard/settings/Caps.tsx
deleted file mode 100644
index 6436262db..000000000
--- a/apps/web/app/dashboard/settings/Caps.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-"use client";
-import { Button } from "@cap/ui";
-import moment from "moment";
-import { VideoThumbnail } from "@/components/VideoThumbnail";
-import { useRouter } from "next/navigation";
-import toast from "react-hot-toast";
-import { EyeIcon, LinkIcon, MessageSquareIcon, SmileIcon } from "lucide-react";
-import { useEffect, useState } from "react";
-
-type videoData = {
- id: string;
- ownerId: string;
- name: string;
- createdAt: Date;
- totalComments: number;
- totalReactions: number;
-}[];
-
-export const Caps = ({ data }: { data: videoData }) => {
- const { push } = useRouter();
- const [analytics, setAnalytics] = useState<Record<string, number>>({});
-
- useEffect(() => {
- const fetchAnalytics = async () => {
- const analyticsData: Record<string, number> = {};
-
- for (const video of data) {
- const response = await fetch(
- `/api/video/analytics?videoId=${video.id}`
- );
- const data = await response.json();
-
- if (!data.count) {
- analyticsData[video.id] = 0;
- } else {
- analyticsData[video.id] = data.count;
- }
- }
- setAnalytics(analyticsData);
- };
-
- fetchAnalytics();
- }, [data]);
-
- return (
- <div className="py-12">
- {data.length === 0 ? (
- <div className="min-h-full h-full flex flex-col items-center justify-center">
- <div className="w-full max-w-md mx-auto">
- <img
- className="w-full h-auto"
- src="/illustrations/person-microphone.svg"
- alt="Person using microphone"
- />
- </div>
- <div className="text-center">
- <h1 className="text-2xl font-semibold mb-3">
- Record your first Cap.
- </h1>
- <p className="text-xl max-w-md">
- Craft your narrative with a Cap—get projects done quicker.
- </p>
- <Button
- onClick={() => {
- push("/download");
- }}
- size="default"
- className="mt-8 relative"
- variant="default"
- >
- Download Cap
- </Button>
- </div>
- </div>
- ) : (
- <>
- <div className="mb-8">
- <h1 className="text-3xl font-semibold mb-1">My Caps</h1>
- </div>
- <div className="grid grid-cols-2 md:grid-cols-4 gap-6">
- {data.map((cap, index) => {
- const videoAnalytics = analytics[cap.id];
-
- return (
- <div
- key={index}
- className="rounded-xl border border-filler overflow-hidden relative"
- >
- <button
- type="button"
- className="cursor-pointer border border-gray-300 absolute top-2 right-2 z-20 bg-white hover:bg-gray-300 w-6 h-6 m-0 p-0 rounded-full flex items-center justify-center transition-all"
- onClick={() => {
- if (
- process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NEXT_ENV === "production"
- ) {
- navigator.clipboard.writeText(
- `https://cap.link/${cap.id}`
- );
- } else {
- navigator.clipboard.writeText(
- `${process.env.NEXT_PUBLIC_URL}/s/${cap.id}`
- );
- }
- toast.success("Link copied to clipboard!");
- }}
- >
- <LinkIcon className="w-3 h-3" />
- </button>
- <a
- className="group block"
- href={
- process.env.NEXT_PUBLIC_IS_CAP &&
- process.env.NEXT_ENV === "production"
- ? `https://cap.link/${cap.id}`
- : `${process.env.NEXT_PUBLIC_URL}/s/${cap.id}`
- }
- >
- <VideoThumbnail
- userId={cap.ownerId}
- videoId={cap.id}
- alt={`${cap.name} Thumbnail`}
- />
- </a>
- <div className="p-4">
- <p className="font-medium">{cap.name}</p>
- <p className="text-sm text-gray-400">
- {moment(cap.createdAt).fromNow()}
- </p>
- <div className="flex items-center space-x-3 mt-2 text-sm text-gray-600">
- <div className="flex items-center">
- <EyeIcon className="w-4 h-4 mr-1" />
- <span className="text-gray-600">
- {videoAnalytics ?? "-"}
- </span>
- </div>
- <div className="flex items-center">
- <MessageSquareIcon className="w-4 h-4 mr-1" />
- <span className="text-gray-600">
- {cap.totalComments}
- </span>
- </div>
- <div className="flex items-center">
- <SmileIcon className="w-4 h-4 mr-1" />
- <span className="text-gray-600">
- {cap.totalReactions}
- </span>
- </div>
- </div>
- </div>
- </div>
- );
- })}
- </div>
- </>
- )}
- </div>
- );
-};
diff --git a/apps/web/app/dashboard/settings/Settings.tsx b/apps/web/app/dashboard/settings/Settings.tsx
new file mode 100644
index 000000000..0299ba491
--- /dev/null
+++ b/apps/web/app/dashboard/settings/Settings.tsx
@@ -0,0 +1,95 @@
+"use client";
+
+import { users } from "@cap/database/schema";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+ Button,
+ Input,
+ Label,
+} from "@cap/ui";
+import { useRouter } from "next/navigation";
+import toast from "react-hot-toast";
+
+export const Settings = ({
+ user,
+}: {
+ user: typeof users.$inferSelect | null;
+}) => {
+ const firstName = user ? user?.name : "";
+ const lastName = user ? user?.lastName : "";
+ const router = useRouter();
+
+ const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
+ e.preventDefault();
+
+ const formData = new FormData(e.currentTarget);
+ const firstName = formData.get("firstName") as string;
+ const lastName = formData.get("lastName") as string;
+
+ try {
+ const response = await fetch("/api/settings/user/name", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ firstName, lastName }),
+ });
+
+ if (response.ok) {
+ toast.success("Name updated successfully");
+ router.refresh();
+ } else {
+ toast.error("Failed to update name");
+ }
+ } catch (error) {
+ console.error("Error updating name:", error);
+ toast.error("An error occurred while updating name");
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit}>
+ <Card>
+ <CardHeader>
+ <CardTitle>Your name</CardTitle>
+ <CardDescription>
+ Changing your name below will update how your name appears when
+ sharing a Cap, and in your profile.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-3">
+ <div>
+ <Label htmlFor="firstName">First name</Label>
+ <Input
+ type="text"
+ defaultValue={firstName as string}
+ id="firstName"
+ name="firstName"
+ />
+ </div>
+ <div>
+ <Label htmlFor="lastName">Last name</Label>
+ <Input
+ type="text"
+ defaultValue={lastName as string}
+ id="lastName"
+ name="lastName"
+ />
+ </div>
+ </div>
+ </CardContent>
+ <CardFooter className="border-t px-6 py-4">
+ <Button type="submit" size="default">
+ Save
+ </Button>
+ </CardFooter>
+ </Card>
+ </form>
+ );
+};
diff --git a/apps/web/app/dashboard/settings/billing/Billing.tsx b/apps/web/app/dashboard/settings/billing/Billing.tsx
new file mode 100644
index 000000000..a21856705
--- /dev/null
+++ b/apps/web/app/dashboard/settings/billing/Billing.tsx
@@ -0,0 +1,45 @@
+"use client";
+
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+ Button,
+ Input,
+ Label,
+} from "@cap/ui";
+import { users } from "@cap/database/schema";
+import { useRouter } from "next/navigation";
+import toast from "react-hot-toast";
+
+export const Billing = ({
+ user,
+}: {
+ user: typeof users.$inferSelect | null;
+}) => {
+ const router = useRouter();
+
+ return (
+ <form>
+ <Card>
+ <CardHeader>
+ <CardTitle>Billing</CardTitle>
+ <CardDescription>Manage all things billing.</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <CardTitle>View and manage your billing details</CardTitle>
+ <CardDescription>
+ View and edit your billing details, as well as cancel your
+ subscription.
+ </CardDescription>
+ <CardDescription className="mt-3">
+ <Button size="sm">Manage billing</Button>
+ </CardDescription>
+ </CardContent>
+ </Card>
+ </form>
+ );
+};
diff --git a/apps/web/app/dashboard/settings/billing/page.tsx b/apps/web/app/dashboard/settings/billing/page.tsx
new file mode 100644
index 000000000..29d458e80
--- /dev/null
+++ b/apps/web/app/dashboard/settings/billing/page.tsx
@@ -0,0 +1,10 @@
+import { Billing } from "./Billing";
+import { getCurrentUser } from "@cap/database/auth/session";
+
+export const revalidate = 0;
+
+export default async function BillingPage() {
+ const user = await getCurrentUser();
+
+ return <Billing user={user} />;
+}
diff --git a/apps/web/app/dashboard/settings/layout.tsx b/apps/web/app/dashboard/settings/layout.tsx
new file mode 100644
index 000000000..b98289140
--- /dev/null
+++ b/apps/web/app/dashboard/settings/layout.tsx
@@ -0,0 +1,51 @@
+"use client";
+
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+
+export default async function DashboardLayout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ const pathname = usePathname();
+
+ const secondaryNavigation = [
+ { name: "My account", title: "Settings", href: "/dashboard/settings" },
+ { name: "Billing", title: "Billing", href: "/dashboard/settings/billing" },
+ ];
+
+ const currentPage = secondaryNavigation.find(
+ (item) => item.href === pathname
+ );
+
+ return (
+ <div className="py-12">
+ <header className="border-b border-white/5">
+ <h1 className="text-3xl">{currentPage?.title ?? "Settings"}</h1>
+ <nav className="mb-4 flex overflow-x-auto py-4">
+ <ul
+ role="list"
+ className="flex min-w-full flex-none gap-x-6 text-sm leading-6 text-gray-400 p-0"
+ >
+ {secondaryNavigation.map((item, index) => (
+ <li key={index}>
+ <Link
+ href={item.href}
+ className={`${
+ item.href === pathname
+ ? "text-black border-black primary"
+ : "text-gray-900 opacity-50 hover:opacity-100 border-transparent"
+ } pb-2 border-b-2`}
+ >
+ {item.name}
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </nav>
+ </header>
+ {children}
+ </div>
+ );
+}
diff --git a/apps/web/app/dashboard/settings/page.tsx b/apps/web/app/dashboard/settings/page.tsx
index 3a59265ed..e9cf8d5de 100644
--- a/apps/web/app/dashboard/settings/page.tsx
+++ b/apps/web/app/dashboard/settings/page.tsx
@@ -1,29 +1,10 @@
-import { Caps } from "./Caps";
-import { db } from "@cap/database";
-import { comments, videos } from "@cap/database/schema";
-import { desc, eq, sql } from "drizzle-orm";
+import { Settings } from "./Settings";
import { getCurrentUser } from "@cap/database/auth/session";
export const revalidate = 0;
-export default async function CapsPage() {
+export default async function SettingsPage() {
const user = await getCurrentUser();
- const userId = user?.userId as string;
- const videoData = await db
- .select({
- id: videos.id,
- ownerId: videos.ownerId,
- name: videos.name,
- createdAt: videos.createdAt,
- totalComments: sql<number>`COUNT(CASE WHEN ${comments.type} = 'text' THEN 1 END)`,
- totalReactions: sql<number>`COUNT(CASE WHEN ${comments.type} = 'emoji' THEN 1 END)`,
- })
- .from(videos)
- .leftJoin(comments, eq(videos.id, comments.videoId))
- .where(eq(videos.ownerId, userId))
- .groupBy(videos.id, videos.ownerId, videos.name, videos.createdAt)
- .orderBy(desc(videos.createdAt));
-
- return <Caps data={videoData} />;
+ return <Settings user={user} />;
}
diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index f746aefb8..31697978d 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -151,7 +151,8 @@ h5 {
a,
p,
span,
-input {
+input,
+label {
@apply tracking-tight text-black;
}
@@ -184,8 +185,8 @@ label {
.custom-bg {
background: radial-gradient(
50.01% 50.01% at 53.53% 49.99%,
- var(--tertiary-2) 4.65%,
- var(--tertiary) 68.48%,
+ var(--tertiary-3) 5.65%,
+ var(--tertiary) 78.48%,
#ffffff 100%
);
}
@@ -199,6 +200,15 @@ label {
);
}
+.muted-custom-bg-2 {
+ background: radial-gradient(
+ 50.01% 50.01% at 53.53% 49.99%,
+ var(--tertiary) 4.65%,
+ var(--tertiary) 68.48%,
+ #ffffff 100%
+ );
+}
+
.styled-links a {
@apply font-semibold underline;
}
diff --git a/apps/web/app/login/form.tsx b/apps/web/app/login/form.tsx
index a2e255341..90e8c8b74 100644
--- a/apps/web/app/login/form.tsx
+++ b/apps/web/app/login/form.tsx
@@ -50,7 +50,7 @@ export function LoginForm() {
toast.error("Error sending email - try again?");
});
}}
- className="flex flex-col space-y-3"
+ className="flex flex-col space-y-3 fade-in-down animate-delay-2"
>
<div>
<input
diff --git a/apps/web/app/login/page.tsx b/apps/web/app/login/page.tsx
index f37a00c79..e511481be 100644
--- a/apps/web/app/login/page.tsx
+++ b/apps/web/app/login/page.tsx
@@ -15,11 +15,13 @@ export default async function LoginPage() {
<div className="muted-custom-bg wrapper w-full h-screen flex items-center justify-center">
<div className="w-full max-w-lg relative overflow-hidden sm:rounded-2xl p-4 space-y-4">
<a href="/">
- <LogoBadge className="h-12 w-auto" />
+ <LogoBadge className="h-12 w-auto fade-in-down" />
</a>
<div className="text-left flex flex-col items-start justify-center space-y-3">
- <h1 className="text-3xl font-semibold">Sign in to Cap.</h1>
- <p className="text-2xl text-gray-500">
+ <h1 className="text-3xl font-semibold fade-in-down animate-delay-1">
+ Sign in to Cap.
+ </h1>
+ <p className="text-2xl text-gray-500 fade-in-down animate-delay-1">
Effortless, instant screen sharing. Open source and cross-platform.
</p>
</div>
diff --git a/apps/web/app/onboarding/Onboarding.tsx b/apps/web/app/onboarding/Onboarding.tsx
new file mode 100644
index 000000000..76615e28b
--- /dev/null
+++ b/apps/web/app/onboarding/Onboarding.tsx
@@ -0,0 +1,76 @@
+"use client";
+
+import { users } from "@cap/database/schema";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+ Button,
+ Input,
+ Label,
+} from "@cap/ui";
+import { useRouter } from "next/navigation";
+import toast from "react-hot-toast";
+
+export const Onboarding = ({
+ user,
+}: {
+ user: typeof users.$inferSelect | null;
+}) => {
+ const router = useRouter();
+
+ const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
+ e.preventDefault();
+
+ const formData = new FormData(e.currentTarget);
+ const firstName = formData.get("firstName") as string;
+ const lastName = formData.get("lastName") as string;
+
+ try {
+ const response = await fetch("/api/settings/user/name", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ firstName, lastName }),
+ });
+
+ if (response.ok) {
+ toast.success("Name updated successfully");
+ router.refresh();
+ } else {
+ toast.error("Failed to update name");
+ }
+ } catch (error) {
+ console.error("Error updating name:", error);
+ toast.error("An error occurred while updating name");
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit}>
+ <Card noStyle>
+ <CardContent>
+ <div className="space-y-3">
+ <div>
+ <Label htmlFor="firstName">First name *</Label>
+ <Input type="text" id="firstName" name="firstName" required />
+ </div>
+ <div>
+ <Label htmlFor="lastName">Last name</Label>
+ <Input type="text" id="lastName" name="lastName" />
+ </div>
+ </div>
+ </CardContent>
+ <CardFooter className="border-t px-6 py-4">
+ <Button className="mx-auto" type="submit" size="lg">
+ Complete
+ </Button>
+ </CardFooter>
+ </Card>
+ </form>
+ );
+};
diff --git a/apps/web/app/onboarding/page.tsx b/apps/web/app/onboarding/page.tsx
index 019a807f8..5ac2464b5 100644
--- a/apps/web/app/onboarding/page.tsx
+++ b/apps/web/app/onboarding/page.tsx
@@ -1,7 +1,34 @@
+import { Button, LogoBadge } from "@cap/ui";
+import { Suspense } from "react";
+import { getCurrentUser } from "@cap/database/auth/session";
+import { redirect } from "next/navigation";
+import { Onboarding } from "./Onboarding";
+
export default async function OnboardingPage() {
+ const user = await getCurrentUser();
+
+ if (user !== null && user.name !== null && user.name.length > 1) {
+ redirect("/dashboard");
+ }
+
return (
- <div>
- <h1>Onboarding Page</h1>
+ <div className="muted-custom-bg-2 wrapper w-full h-screen flex items-center justify-center">
+ <div className="w-full max-w-lg relative overflow-hidden sm:rounded-2xl p-4 space-y-4">
+ <a href="/">
+ <LogoBadge className="h-14 mx-auto w-auto fade-in-down" />
+ </a>
+ <div className="text-center flex flex-col items-center justify-center space-y-3">
+ <h1 className="text-3xl font-semibold fade-in-down animate-delay-1">
+ Let's get you started.
+ </h1>
+ <p className="text-2xl text-gray-500 fade-in-down animate-delay-1">
+ What's your name?
+ </p>
+ </div>
+ <div className="fade-in-down animate-delay-2 flex flex-col space-y-3">
+ <Onboarding user={user} />
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/web/components/Footer.tsx b/apps/web/components/Footer.tsx
index d41375e91..cb17ecc06 100644
--- a/apps/web/components/Footer.tsx
+++ b/apps/web/components/Footer.tsx
@@ -9,6 +9,7 @@ export const Footer = () => {
pathname === "/login" ||
pathname.includes("/dashboard") ||
pathname.includes("/s/") ||
+ pathname.includes("/onboarding") ||
(typeof window !== "undefined" && window.location.href.includes("cap.link"))
)
return null;
diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsx
index d856b1122..5c22b8125 100644
--- a/apps/web/components/Navbar.tsx
+++ b/apps/web/components/Navbar.tsx
@@ -26,6 +26,7 @@ export const Navbar = ({ auth }: { auth: boolean }) => {
pathname === "/login" ||
pathname.includes("/dashboard") ||
pathname.includes("/s/") ||
+ pathname.includes("/onboarding") ||
(typeof window !== "undefined" && window.location.href.includes("cap.link"))
)
return null;
diff --git a/packages/database/auth/auth-options.ts b/packages/database/auth/auth-options.ts
index 6d4f8b48d..0de9a1956 100644
--- a/packages/database/auth/auth-options.ts
+++ b/packages/database/auth/auth-options.ts
@@ -39,7 +39,7 @@ export const authOptions: NextAuthOptions = {
httpOnly: true,
sameSite: "none",
path: "/",
- secure: process.env.NODE_ENV === "development" ? false : true,
+ secure: true,
},
},
},
@@ -71,6 +71,7 @@ export const authOptions: NextAuthOptions = {
return {
id: dbUser.id,
name: dbUser.name,
+ lastName: dbUser.lastName,
email: dbUser.email,
picture: dbUser.image,
};
diff --git a/packages/database/auth/session.ts b/packages/database/auth/session.ts
index 3ba6e6e35..1ebebd17e 100644
--- a/packages/database/auth/session.ts
+++ b/packages/database/auth/session.ts
@@ -10,14 +10,6 @@ export const getSession = async () => {
return session;
};
-export const userSelectProps = {
- userId: users.id,
- email: users.email,
- name: users.name,
- image: users.image,
- createdAt: users.created_at,
-};
-
export const getCurrentUser = async () => {
const session = await getServerSession(authOptions);
@@ -26,7 +18,7 @@ export const getCurrentUser = async () => {
}
const [currentUser] = await db
- .select(userSelectProps)
+ .select()
.from(users)
.where(eq(users.id, session?.user.id));
diff --git a/packages/database/schema.ts b/packages/database/schema.ts
index e90ff227a..9308a7930 100644
--- a/packages/database/schema.ts
+++ b/packages/database/schema.ts
@@ -26,6 +26,7 @@ export const users = mysqlTable(
{
id: nanoId("id").notNull().primaryKey().unique(),
name: varchar("name", { length: 255 }),
+ lastName: varchar("lastName", { length: 255 }),
email: varchar("email", { length: 255 }).unique().notNull(),
emailVerified: timestamp("emailVerified"),
image: varchar("image", { length: 255 }),
@@ -42,6 +43,7 @@ export const users = mysqlTable(
activeSpaceId: nanoId("activeSpaceId"),
created_at: timestamp("created_at").notNull().defaultNow(),
updated_at: timestamp("updated_at").notNull().defaultNow().onUpdateNow(),
+ onboarding_completed_at: timestamp("onboarding_completed_at"),
},
(table) => ({
emailIndex: uniqueIndex("email_idx").on(table.email),
diff --git a/packages/ui/src/components/Card.tsx b/packages/ui/src/components/Card.tsx
index f07bfb687..9397a7fe8 100644
--- a/packages/ui/src/components/Card.tsx
+++ b/packages/ui/src/components/Card.tsx
@@ -1,20 +1,20 @@
-import { forwardRef } from 'react';
-import { classNames } from '@cap/utils';
+import { forwardRef } from "react";
+import { classNames } from "@cap/utils";
const Card = forwardRef<
HTMLDivElement,
- React.HTMLAttributes<HTMLDivElement>
->(({ className, ...props }, ref) => (
+ React.HTMLAttributes<HTMLDivElement> & { noStyle?: boolean }
+>(({ className, noStyle, ...props }, ref) => (
<div
ref={ref}
className={classNames(
- 'rounded-lg border bg-card text-card-foreground shadow-sm',
+ !noStyle && "rounded-lg border bg-card text-card-foreground shadow-sm",
className
)}
{...props}
/>
));
-Card.displayName = 'Card';
+Card.displayName = "Card";
const CardHeader = forwardRef<
HTMLDivElement,
@@ -22,11 +22,11 @@ const CardHeader = forwardRef<
>(({ className, ...props }, ref) => (
<div
ref={ref}
- className={classNames('flex flex-col space-y-1.5 p-6', className)}
+ className={classNames("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
));
-CardHeader.displayName = 'CardHeader';
+CardHeader.displayName = "CardHeader";
const CardTitle = forwardRef<
HTMLParagraphElement,
@@ -35,13 +35,13 @@ const CardTitle = forwardRef<
<h3
ref={ref}
className={classNames(
- 'text-lg font-semibold leading-none tracking-tight',
+ "text-lg font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
));
-CardTitle.displayName = 'CardTitle';
+CardTitle.displayName = "CardTitle";
const CardDescription = forwardRef<
HTMLParagraphElement,
@@ -49,19 +49,19 @@ const CardDescription = forwardRef<
>(({ className, ...props }, ref) => (
<p
ref={ref}
- className={classNames('text-sm text-muted-foreground', className)}
+ className={classNames("text-sm text-gray-500 ", className)}
{...props}
/>
));
-CardDescription.displayName = 'CardDescription';
+CardDescription.displayName = "CardDescription";
const CardContent = forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
- <div ref={ref} className={classNames('p-6 pt-0', className)} {...props} />
+ <div ref={ref} className={classNames("p-6 pt-0", className)} {...props} />
));
-CardContent.displayName = 'CardContent';
+CardContent.displayName = "CardContent";
const CardFooter = forwardRef<
HTMLDivElement,
@@ -69,11 +69,11 @@ const CardFooter = forwardRef<
>(({ className, ...props }, ref) => (
<div
ref={ref}
- className={classNames(' flex items-center p-6 pt-0', className)}
+ className={classNames(" flex items-center p-6 pt-0", className)}
{...props}
/>
));
-CardFooter.displayName = 'CardFooter';
+CardFooter.displayName = "CardFooter";
export {
Card,
@@ -82,4 +82,4 @@ export {
CardTitle,
CardDescription,
CardContent,
-};
\ No newline at end of file
+};
diff --git a/packages/ui/src/components/input/Input.tsx b/packages/ui/src/components/input/Input.tsx
index d2fa32dc5..db3f2d90f 100644
--- a/packages/ui/src/components/input/Input.tsx
+++ b/packages/ui/src/components/input/Input.tsx
@@ -11,7 +11,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={classNames(
- "flex h-11 w-full rounded-lg border border-input px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+ "flex h-11 w-full rounded-full border border-gray-400 focus:border-black px-3 h-10 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
diff --git a/packages/ui/src/components/input/Label.tsx b/packages/ui/src/components/input/Label.tsx
index a554e6787..cc6e26f1f 100644
--- a/packages/ui/src/components/input/Label.tsx
+++ b/packages/ui/src/components/input/Label.tsx
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import { classNames } from "@cap/utils";
const labelVariants = cva(
- "text-base font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+ "text-sm font-normal text-gray-500 leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 mb-1.5"
);
const Label = React.forwardRef<