MingruiZhang commited on
Commit
78ebb49
1 Parent(s): 71679ee

feat: Minor updates and introducing shadcn (#54)

Browse files

<img width="1482" alt="image"
src="https://github.com/landing-ai/vision-agent-ui/assets/5669963/a8bbca87-34ba-4c9e-b5ab-149625a349f4">

app/chat/[id]/page.tsx CHANGED
@@ -2,6 +2,7 @@ import { Chat } from '@/components/chat';
2
  import { auth } from '@/auth';
3
  import { dbGetChat } from '@/lib/db/functions';
4
  import { redirect } from 'next/navigation';
 
5
 
6
  interface PageProps {
7
  params: {
@@ -12,7 +13,9 @@ interface PageProps {
12
  export default async function Page({ params }: PageProps) {
13
  const { id: chatId } = params;
14
  const chat = await dbGetChat(chatId);
 
15
  if (!chat) {
 
16
  redirect('/');
17
  }
18
  const session = await auth();
 
2
  import { auth } from '@/auth';
3
  import { dbGetChat } from '@/lib/db/functions';
4
  import { redirect } from 'next/navigation';
5
+ import { revalidatePath } from 'next/cache';
6
 
7
  interface PageProps {
8
  params: {
 
13
  export default async function Page({ params }: PageProps) {
14
  const { id: chatId } = params;
15
  const chat = await dbGetChat(chatId);
16
+
17
  if (!chat) {
18
+ revalidatePath('/');
19
  redirect('/');
20
  }
21
  const session = await auth();
app/globals.css CHANGED
@@ -6,65 +6,46 @@
6
  :root {
7
  --background: 0 0% 100%;
8
  --foreground: 240 10% 3.9%;
9
-
10
- --muted: 240 4.8% 95.9%;
11
- --muted-foreground: 240 3.8% 46.1%;
12
-
13
- --popover: 0 0% 100%;
14
- --popover-foreground: 240 10% 3.9%;
15
-
16
  --card: 0 0% 100%;
17
  --card-foreground: 240 10% 3.9%;
18
-
19
- --border: 240 5.9% 90%;
20
- --input: 240 5.9% 90%;
21
-
22
  --primary: 240 5.9% 10%;
23
  --primary-foreground: 0 0% 98%;
24
-
25
  --secondary: 240 4.8% 95.9%;
26
  --secondary-foreground: 240 5.9% 10%;
27
-
 
28
  --accent: 240 4.8% 95.9%;
29
- --accent-foreground: ;
30
-
31
  --destructive: 0 84.2% 60.2%;
32
  --destructive-foreground: 0 0% 98%;
33
-
34
- --ring: 240 5% 64.9%;
35
-
36
  --radius: 0.5rem;
37
  }
38
 
39
  .dark {
40
  --background: 240 10% 3.9%;
41
  --foreground: 0 0% 98%;
42
-
43
- --muted: 240 3.7% 15.9%;
44
- --muted-foreground: 240 5% 64.9%;
45
-
46
- --popover: 240 10% 3.9%;
47
- --popover-foreground: 0 0% 98%;
48
-
49
  --card: 240 10% 3.9%;
50
  --card-foreground: 0 0% 98%;
51
-
52
- --border: 240 3.7% 15.9%;
53
- --input: 240 3.7% 15.9%;
54
-
55
  --primary: 0 0% 98%;
56
  --primary-foreground: 240 5.9% 10%;
57
-
58
  --secondary: 240 3.7% 15.9%;
59
  --secondary-foreground: 0 0% 98%;
60
-
 
61
  --accent: 240 3.7% 15.9%;
62
- --accent-foreground: ;
63
-
64
  --destructive: 0 62.8% 30.6%;
65
- --destructive-foreground: 0 85.7% 97.3%;
66
-
67
- --ring: 240 3.7% 15.9%;
 
68
  }
69
  }
70
 
 
6
  :root {
7
  --background: 0 0% 100%;
8
  --foreground: 240 10% 3.9%;
 
 
 
 
 
 
 
9
  --card: 0 0% 100%;
10
  --card-foreground: 240 10% 3.9%;
11
+ --popover: 0 0% 100%;
12
+ --popover-foreground: 240 10% 3.9%;
 
 
13
  --primary: 240 5.9% 10%;
14
  --primary-foreground: 0 0% 98%;
 
15
  --secondary: 240 4.8% 95.9%;
16
  --secondary-foreground: 240 5.9% 10%;
17
+ --muted: 240 4.8% 95.9%;
18
+ --muted-foreground: 240 3.8% 46.1%;
19
  --accent: 240 4.8% 95.9%;
20
+ --accent-foreground: 240 5.9% 10%;
 
21
  --destructive: 0 84.2% 60.2%;
22
  --destructive-foreground: 0 0% 98%;
23
+ --border: 240 5.9% 90%;
24
+ --input: 240 5.9% 90%;
25
+ --ring: 240 5.9% 10%;
26
  --radius: 0.5rem;
27
  }
28
 
29
  .dark {
30
  --background: 240 10% 3.9%;
31
  --foreground: 0 0% 98%;
 
 
 
 
 
 
 
32
  --card: 240 10% 3.9%;
33
  --card-foreground: 0 0% 98%;
34
+ --popover: 240 10% 3.9%;
35
+ --popover-foreground: 0 0% 98%;
 
 
36
  --primary: 0 0% 98%;
37
  --primary-foreground: 240 5.9% 10%;
 
38
  --secondary: 240 3.7% 15.9%;
39
  --secondary-foreground: 0 0% 98%;
40
+ --muted: 240 3.7% 15.9%;
41
+ --muted-foreground: 240 5% 64.9%;
42
  --accent: 240 3.7% 15.9%;
43
+ --accent-foreground: 0 0% 98%;
 
44
  --destructive: 0 62.8% 30.6%;
45
+ --destructive-foreground: 0 0% 98%;
46
+ --border: 240 3.7% 15.9%;
47
+ --input: 240 3.7% 15.9%;
48
+ --ring: 240 4.9% 83.9%;
49
  }
50
  }
51
 
components.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "default",
4
+ "rsc": true,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "tailwind.config.ts",
8
+ "css": "app/globals.css",
9
+ "baseColor": "zinc",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils"
16
+ }
17
+ }
components/chat-sidebar/ChatCard.tsx CHANGED
@@ -36,7 +36,6 @@ export const ChatCardLayout: React.FC<
36
 
37
  const ChatCard: React.FC<ChatCardProps> = ({ chat, isAdminView }) => {
38
  const { id: chatIdFromParam } = useParams();
39
- const router = useRouter();
40
  const { id, mediaUrl, messages, userId, updatedAt } = chat;
41
  if (!id) {
42
  return null;
 
36
 
37
  const ChatCard: React.FC<ChatCardProps> = ({ chat, isAdminView }) => {
38
  const { id: chatIdFromParam } = useParams();
 
39
  const { id, mediaUrl, messages, userId, updatedAt } = chat;
40
  if (!id) {
41
  return null;
components/ui/skeleton.tsx ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { cn } from "@/lib/utils"
2
+
3
+ function Skeleton({
4
+ className,
5
+ ...props
6
+ }: React.HTMLAttributes<HTMLDivElement>) {
7
+ return (
8
+ <div
9
+ className={cn("animate-pulse rounded-md bg-muted", className)}
10
+ {...props}
11
+ />
12
+ )
13
+ }
14
+
15
+ export { Skeleton }
lib/db/functions.ts CHANGED
@@ -4,7 +4,6 @@ import { sessionUser } from '@/auth';
4
  import prisma from './prisma';
5
  import { ChatWithMessages, MessageRaw } from './types';
6
  import { revalidatePath } from 'next/cache';
7
- import { redirect } from 'next/navigation';
8
 
9
  /**
10
  * Finds or creates a user in the database based on the provided email and name.
@@ -47,7 +46,6 @@ export async function dbGetAllChat(): Promise<ChatWithMessages[]> {
47
  where: { userId },
48
  include: {
49
  messages: true,
50
- user: true,
51
  },
52
  });
53
  }
 
4
  import prisma from './prisma';
5
  import { ChatWithMessages, MessageRaw } from './types';
6
  import { revalidatePath } from 'next/cache';
 
7
 
8
  /**
9
  * Finds or creates a user in the database based on the provided email and name.
 
46
  where: { userId },
47
  include: {
48
  messages: true,
 
49
  },
50
  });
51
  }
package.json CHANGED
@@ -36,6 +36,7 @@
36
  "geist": "^1.2.1",
37
  "immer": "^10.0.3",
38
  "jotai": "^2.7.0",
 
39
  "nanoid": "^5.0.4",
40
  "next": "14.1.1",
41
  "next-auth": "5.0.0-beta.16",
@@ -75,7 +76,7 @@
75
  "eslint-plugin-tailwindcss": "^3.14.0",
76
  "postcss": "^8.4.33",
77
  "prettier": "^3.2.4",
78
- "tailwind-merge": "^2.2.0",
79
  "tailwindcss": "^3.4.1",
80
  "tailwindcss-animate": "^1.0.7",
81
  "typescript": "^5.3.3"
 
36
  "geist": "^1.2.1",
37
  "immer": "^10.0.3",
38
  "jotai": "^2.7.0",
39
+ "lucide-react": "^0.379.0",
40
  "nanoid": "^5.0.4",
41
  "next": "14.1.1",
42
  "next-auth": "5.0.0-beta.16",
 
76
  "eslint-plugin-tailwindcss": "^3.14.0",
77
  "postcss": "^8.4.33",
78
  "prettier": "^3.2.4",
79
+ "tailwind-merge": "^2.2.2",
80
  "tailwindcss": "^3.4.1",
81
  "tailwindcss-animate": "^1.0.7",
82
  "typescript": "^5.3.3"
pnpm-lock.yaml CHANGED
@@ -74,6 +74,9 @@ importers:
74
  jotai:
75
  specifier: ^2.7.0
76
  version: 2.8.0(@types/react@18.2.79)(react@18.2.0)
 
 
 
77
  nanoid:
78
  specifier: ^5.0.4
79
  version: 5.0.7
@@ -187,7 +190,7 @@ importers:
187
  specifier: ^3.2.4
188
  version: 3.2.5
189
  tailwind-merge:
190
- specifier: ^2.2.0
191
  version: 2.2.2
192
  tailwindcss:
193
  specifier: ^3.4.1
@@ -2562,6 +2565,11 @@ packages:
2562
  resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
2563
  engines: {node: '>=10'}
2564
 
 
 
 
 
 
2565
  magic-string@0.30.10:
2566
  resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==}
2567
 
@@ -6777,6 +6785,10 @@ snapshots:
6777
  dependencies:
6778
  yallist: 4.0.0
6779
 
 
 
 
 
6780
  magic-string@0.30.10:
6781
  dependencies:
6782
  '@jridgewell/sourcemap-codec': 1.4.15
 
74
  jotai:
75
  specifier: ^2.7.0
76
  version: 2.8.0(@types/react@18.2.79)(react@18.2.0)
77
+ lucide-react:
78
+ specifier: ^0.379.0
79
+ version: 0.379.0(react@18.2.0)
80
  nanoid:
81
  specifier: ^5.0.4
82
  version: 5.0.7
 
190
  specifier: ^3.2.4
191
  version: 3.2.5
192
  tailwind-merge:
193
+ specifier: ^2.2.2
194
  version: 2.2.2
195
  tailwindcss:
196
  specifier: ^3.4.1
 
2565
  resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
2566
  engines: {node: '>=10'}
2567
 
2568
+ lucide-react@0.379.0:
2569
+ resolution: {integrity: sha512-KcdeVPqmhRldldAAgptb8FjIunM2x2Zy26ZBh1RsEUcdLIvsEmbcw7KpzFYUy5BbpGeWhPu9Z9J5YXfStiXwhg==}
2570
+ peerDependencies:
2571
+ react: ^16.5.1 || ^17.0.0 || ^18.0.0
2572
+
2573
  magic-string@0.30.10:
2574
  resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==}
2575
 
 
6785
  dependencies:
6786
  yallist: 4.0.0
6787
 
6788
+ lucide-react@0.379.0(react@18.2.0):
6789
+ dependencies:
6790
+ react: 18.2.0
6791
+
6792
  magic-string@0.30.10:
6793
  dependencies:
6794
  '@jridgewell/sourcemap-codec': 1.4.15