Skip to content

Commit 02e533e

Browse files
committed
Huge Ui overhaul
1 parent d08f48b commit 02e533e

14 files changed

Lines changed: 746 additions & 344 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"@radix-ui/react-popover": "^1.0.7",
3333
"@radix-ui/react-progress": "^1.0.3",
3434
"@radix-ui/react-radio-group": "^1.1.3",
35-
"@radix-ui/react-scroll-area": "^1.0.5",
36-
"@radix-ui/react-select": "^2.0.0",
35+
"@radix-ui/react-scroll-area": "^1.2.0",
36+
"@radix-ui/react-select": "^2.1.2",
3737
"@radix-ui/react-separator": "^1.1.0",
3838
"@radix-ui/react-slider": "^1.1.2",
3939
"@radix-ui/react-slot": "^1.1.0",

src/app/(main)/layout.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ export default function RootLayout({
2424
<ToastProvider />
2525
<ModalProvider />
2626
<AppSidebar />
27-
<main>
28-
<SidebarTrigger />
29-
{children}
30-
</main>
27+
<main>{children}</main>
3128
</SidebarProvider>
3229
);
3330
}

src/app/api/passwords/[passwordId]/route.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NextResponse } from "next/server";
44

55
export async function DELETE(
66
req: Request,
7-
{ params }: { params: { passwordId: string } }
7+
{ params }: { params: { passwordId: Promise<string> } }
88
) {
99
try {
1010
const { userId } = await auth();
@@ -13,7 +13,8 @@ export async function DELETE(
1313
return new NextResponse("Unauthenticated", { status: 401 });
1414
}
1515

16-
if (!params.passwordId) {
16+
const passwordId = await params.passwordId; // Await the params
17+
if (!passwordId) {
1718
return new NextResponse("Password ID is required", { status: 400 });
1819
}
1920

@@ -29,7 +30,7 @@ export async function DELETE(
2930

3031
const passwordItem = await prismadb.passwordItem.delete({
3132
where: {
32-
id: params.passwordId,
33+
id: passwordId,
3334
userId: userId,
3435
},
3536
});
@@ -40,3 +41,46 @@ export async function DELETE(
4041
return new NextResponse("Internal Error", { status: 500 });
4142
}
4243
}
44+
45+
export async function PATCH(
46+
req: Request,
47+
{ params }: { params: { passwordId: Promise<string> } }
48+
) {
49+
try {
50+
const { userId } = await auth();
51+
52+
if (!userId) {
53+
return new NextResponse("Unauthenticated", { status: 401 });
54+
}
55+
56+
const passwordId = await params.passwordId;
57+
if (!passwordId) {
58+
return new NextResponse("Password ID is required", { status: 400 });
59+
}
60+
61+
const existingUser = await prismadb.user.findUnique({
62+
where: {
63+
id: userId,
64+
},
65+
});
66+
67+
if (!existingUser) {
68+
return new NextResponse("User does not have a vault.", { status: 400 });
69+
}
70+
71+
const passwordData = await req.json();
72+
73+
const updatedPasswordItem = await prismadb.passwordItem.update({
74+
where: {
75+
id: passwordId,
76+
userId: userId,
77+
},
78+
data: passwordData,
79+
});
80+
81+
return NextResponse.json(updatedPasswordItem);
82+
} catch (error) {
83+
console.log("[PASSWORD_UPDATE]", error);
84+
return new NextResponse("Internal Error", { status: 500 });
85+
}
86+
}

src/components/ui/app-sidebar.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22

33
import {
44
Asterisk,
5-
Calendar,
65
CreditCard,
7-
Home,
8-
Inbox,
9-
Key,
106
KeySquare,
117
Notebook,
12-
Search,
138
Settings,
149
} from "lucide-react";
1510

@@ -24,9 +19,9 @@ import {
2419
SidebarMenuItem,
2520
} from "@/components/ui/sidebar";
2621
import { useSidebar } from "@/hooks/use-sidebar-tab";
27-
import { UserButton } from "@clerk/nextjs";
22+
import { UserButton, useUser } from "@clerk/nextjs";
2823
import { Icons } from "./icons";
29-
import {Separator} from "./separator";
24+
import { Separator } from "./separator";
3025

3126
const items = [
3227
{
@@ -53,32 +48,34 @@ const items = [
5348

5449
export function AppSidebar() {
5550
const sidebar = useSidebar();
51+
const { user } = useUser();
5652

5753
return (
58-
<Sidebar>
54+
<Sidebar className="flex flex-col justify-between min-h-screen bg-gray-800 text-white">
5955
<SidebarContent>
6056
<SidebarGroup>
61-
<SidebarGroupLabel className="mb-10">
57+
<SidebarGroupLabel className="mb-10 flex items-center justify-between p-4">
6258
<UserButton />
63-
<Separator orientation="vertical" className="ml-3 bg-primary/10" />
64-
<div className="flex justify-end ml-3 items-center">
65-
<span className="font-bold text-lg text-gray-900 mr-2">LockScript Vault</span>
66-
67-
<Icons.logo className="h-5 w-5" />
59+
<span>{user?.username}</span>
60+
<div className="flex items-center space-x-3">
61+
<Separator orientation="vertical" className="bg-gray-600 h-8" />
62+
<Icons.logo className="h-6 w-6 text-primary" />
6863
</div>
6964
</SidebarGroupLabel>
7065
<SidebarGroupContent>
71-
<SidebarMenu>
66+
<SidebarMenu className="space-y-2">
7267
{items.map((item) => (
7368
<SidebarMenuItem key={item.title}>
7469
<SidebarMenuButton
7570
onClick={() => sidebar.setTab(item.title)}
7671
className={`${
77-
sidebar.tab === item.title ? "bg-primary/10" : ""
78-
} hover:bg-primary/10`}
72+
sidebar.tab === item.title
73+
? "bg-primary/20 text-primary"
74+
: "text-gray-400"
75+
} hover:bg-primary/10 rounded-lg p-2 flex items-center space-x-3`}
7976
>
80-
<item.icon />
81-
<span>{item.title}</span>
77+
<item.icon className="h-5 w-5" />
78+
<span className="font-medium">{item.title}</span>
8279
</SidebarMenuButton>
8380
</SidebarMenuItem>
8481
))}

src/components/ui/card.tsx

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as React from "react"
2+
3+
import { cn } from "@/lib/utils"
4+
5+
const Card = React.forwardRef<
6+
HTMLDivElement,
7+
React.HTMLAttributes<HTMLDivElement>
8+
>(({ className, ...props }, ref) => (
9+
<div
10+
ref={ref}
11+
className={cn(
12+
"rounded-lg border bg-card text-card-foreground shadow-sm",
13+
className
14+
)}
15+
{...props}
16+
/>
17+
))
18+
Card.displayName = "Card"
19+
20+
const CardHeader = React.forwardRef<
21+
HTMLDivElement,
22+
React.HTMLAttributes<HTMLDivElement>
23+
>(({ className, ...props }, ref) => (
24+
<div
25+
ref={ref}
26+
className={cn("flex flex-col space-y-1.5 p-6", className)}
27+
{...props}
28+
/>
29+
))
30+
CardHeader.displayName = "CardHeader"
31+
32+
const CardTitle = React.forwardRef<
33+
HTMLDivElement,
34+
React.HTMLAttributes<HTMLDivElement>
35+
>(({ className, ...props }, ref) => (
36+
<div
37+
ref={ref}
38+
className={cn(
39+
"text-2xl font-semibold leading-none tracking-tight",
40+
className
41+
)}
42+
{...props}
43+
/>
44+
))
45+
CardTitle.displayName = "CardTitle"
46+
47+
const CardDescription = React.forwardRef<
48+
HTMLDivElement,
49+
React.HTMLAttributes<HTMLDivElement>
50+
>(({ className, ...props }, ref) => (
51+
<div
52+
ref={ref}
53+
className={cn("text-sm text-muted-foreground", className)}
54+
{...props}
55+
/>
56+
))
57+
CardDescription.displayName = "CardDescription"
58+
59+
const CardContent = React.forwardRef<
60+
HTMLDivElement,
61+
React.HTMLAttributes<HTMLDivElement>
62+
>(({ className, ...props }, ref) => (
63+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
64+
))
65+
CardContent.displayName = "CardContent"
66+
67+
const CardFooter = React.forwardRef<
68+
HTMLDivElement,
69+
React.HTMLAttributes<HTMLDivElement>
70+
>(({ className, ...props }, ref) => (
71+
<div
72+
ref={ref}
73+
className={cn("flex items-center p-6 pt-0", className)}
74+
{...props}
75+
/>
76+
))
77+
CardFooter.displayName = "CardFooter"
78+
79+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }

src/components/ui/password-table/data-table-columns.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)