Skip to content

Commit 7551100

Browse files
committed
cleaning up the types and adding new user type
1 parent 6898550 commit 7551100

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

resources/js/components/nav-user.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client"
22

3+
import { type UserType } from '@/types'
34
import { ChevronsUpDown, LogOut, Settings } from "lucide-react"
45
import { Link, usePage } from '@inertiajs/react'
56
import {
@@ -30,7 +31,7 @@ interface User {
3031

3132
interface PageProps {
3233
auth: {
33-
user: User
34+
user: UserType
3435
}
3536
}
3637

@@ -41,7 +42,7 @@ function getInitials(fullName: string): string {
4142
return `${names[0].charAt(0)}${names[names.length - 1].charAt(0)}`.toUpperCase()
4243
}
4344

44-
function UserInfo({ user }: { user: User }) {
45+
function UserInfo({ user }: { user: UserType }) {
4546
return (
4647
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
4748
<Avatar className="h-8 w-8 rounded-md">
@@ -57,7 +58,7 @@ function UserInfo({ user }: { user: User }) {
5758
}
5859

5960
export function NavUser() {
60-
const { auth: { user } } = usePage().props
61+
const { auth: { UserType } } = usePage().props
6162

6263
return (
6364
<SidebarMenu>
@@ -69,14 +70,14 @@ export function NavUser() {
6970
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
7071
>
7172
<Avatar className="h-8 w-8 rounded-md">
72-
<AvatarImage src={user.avatar} alt={user.name} />
73+
<AvatarImage src={UserType.avatar} alt={auth.user.name} />
7374
<AvatarFallback className="rounded-md">
74-
{getInitials(user.name)}
75+
{getInitials(auth.user.name)}
7576
</AvatarFallback>
7677
</Avatar>
7778
<div className="grid flex-1 text-left text-sm leading-tight">
78-
<span className="truncate font-semibold">{user.name}</span>
79-
<span className="truncate text-xs">{user.email}</span>
79+
<span className="truncate font-semibold">{auth.user.name}</span>
80+
<span className="truncate text-xs">{auth.user.email}</span>
8081
</div>
8182
<ChevronsUpDown className="ml-auto size-4" />
8283
</SidebarMenuButton>
@@ -88,7 +89,7 @@ export function NavUser() {
8889
sideOffset={4}
8990
>
9091
<DropdownMenuLabel className="p-0 font-normal">
91-
<UserInfo user={user} />
92+
<UserInfo user={auth.user} />
9293
</DropdownMenuLabel>
9394
<DropdownMenuSeparator />
9495
<DropdownMenuGroup>

resources/js/pages/welcome.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Head, Link } from '@inertiajs/react';
2+
import { type UserType } from '@/types'
23

34
export default function Welcome({
45
auth,
56
laravelVersion,
67
phpVersion,
7-
}: { auth: any; laravelVersion: string; phpVersion: string }) {
8+
}: { auth: { user: UserType }; laravelVersion: string; phpVersion: string }) {
9+
console.log('Auth object:', auth)
810
const handleImageError = () => {
911
document
1012
.getElementById('screenshot-container')

resources/js/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './breadcrumb.types'
2-
export * from './nav.types'
2+
export * from './nav.types'
3+
export * from './user.types'

resources/js/types/user.types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface UserType {
2+
id: number
3+
name: string
4+
email: string
5+
email_verified_at: string | null
6+
created_at: string
7+
updated_at: string
8+
[key: string]: any // This allows for additional properties
9+
}

0 commit comments

Comments
 (0)