Skip to content

Commit

Permalink
feat: user profile dropdown & settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aamirazad committed Jun 18, 2024
1 parent 2549175 commit 26b325a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
19 changes: 13 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
images: {
remotePatterns: [
{
hostname: "img.clerk.com",
},
],
},
};

export default config;
12 changes: 8 additions & 4 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { db } from "@/server/db";
import { users } from "@/server/db/schema";
import { currentUser } from "@clerk/nextjs/server";

export async function setFullUserName(name: string, userId: string) {
try {
Expand All @@ -22,16 +23,19 @@ export async function setPaperlessURL(url: string, userId: string) {
.onConflictDoUpdate({ target: users.userId, set: { paperlessURL: url } });
} catch {
throw new Error("Database error");
}
}
}

export async function setPaperlessToken(token: string, userId: string) {
try {
await db
.insert(users)
.values({ paperlessToken: token, userId: userId })
.onConflictDoUpdate({ target: users.userId, set: { paperlessToken: token } });
.onConflictDoUpdate({
target: users.userId,
set: { paperlessToken: token },
});
} catch {
throw new Error("Database error");
}
}
}
}
1 change: 0 additions & 1 deletion src/app/setup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
} from "../actions";
import { Toaster } from "@/components/ui/sonner";
import { toast } from "sonner";
import { Check } from "lucide-react";

function FullName({
setActiveTab,
Expand Down
45 changes: 44 additions & 1 deletion src/components/topnav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,49 @@ import { Button, buttonVariants } from "@/components/ui/button";
import Tooltip from "@/components/tooltip";
import { ModeToggle } from "@/components/mode-toggle";
import { Separator } from "@/components/ui/separator";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import Image from "next/image";
import { useUser } from "@clerk/nextjs";

function UserProfile() {

const { user } = useUser();

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="icon"
className="size-8 overflow-hidden rounded-full"
>
<Image
src={user?.imageUrl}
width={32}
height={32}
alt="Avatar"
className="overflow-hidden rounded-full"
/>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>Support</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}

export function TopNav() {
return (
Expand Down Expand Up @@ -46,7 +89,7 @@ export function TopNav() {
<SignInButton />
</SignedOut>
<SignedIn>
<UserButton />
<UserProfile />
</SignedIn>
</div>
</div>
Expand Down

0 comments on commit 26b325a

Please sign in to comment.