Skip to content

Commit 39762e2

Browse files
committed
refactor(types): restructure and move user-related types and Eloquent resource definitions
1 parent 4f92976 commit 39762e2

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

resources/js/components/user-info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
22
import { useInitials } from '@/hooks/use-initials';
3-
import { type User } from '@/types';
3+
import { type User } from '@/types/models';
44

55
export function UserInfo({ user, showEmail = false }: { user: User; showEmail?: boolean }) {
66
const getInitials = useInitials();

resources/js/components/user-menu-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from '@/components/ui/dropdown-menu';
22
import { UserInfo } from '@/components/user-info';
33
import { useMobileNavigation } from '@/hooks/use-mobile-navigation';
4-
import { type User } from '@/types';
4+
import { type User } from '@/types/models';
55
import { Link } from '@inertiajs/react';
66
import { LogOut, Settings } from 'lucide-react';
77

resources/js/types/eloquent.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export type EloquentResource<T> = {
2+
data: T;
3+
};
4+
5+
export type EloquentResourceCollection<T> = {
6+
data: T[];
7+
};
8+
9+
export type EloquentPaginatedResourceCollection<T> = EloquentResourceCollection<T> & {
10+
links: {
11+
first: string;
12+
last: string;
13+
prev: string | null;
14+
next: string | null;
15+
};
16+
meta: {
17+
current_page: number;
18+
from: number;
19+
last_page: number;
20+
links: {
21+
url: string | null;
22+
label: string;
23+
active: boolean;
24+
}[];
25+
path: string;
26+
per_page: number;
27+
to: number;
28+
total: number;
29+
};
30+
};

resources/js/types/index.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,3 @@ export interface SharedData {
3838

3939
[key: string]: unknown;
4040
}
41-
42-
export interface User {
43-
id: number;
44-
name: string;
45-
email: string;
46-
avatar?: string;
47-
email_verified_at: string | null;
48-
created_at: string;
49-
updated_at: string;
50-
51-
[key: string]: unknown; // This allows for additional properties...
52-
}

resources/js/types/models.d.ts

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

0 commit comments

Comments
 (0)