Skip to content

Commit 6898550

Browse files
committed
Adding a types folder where we can store types and doing some cleanup
1 parent fa5f1d3 commit 6898550

File tree

15 files changed

+59
-93
lines changed

15 files changed

+59
-93
lines changed

resources/js/components/app-sidebar.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link } from "@inertiajs/react"
33
import { NavMain } from "@/components/nav-main"
44
import { NavFooter } from "@/components/nav-footer"
55
import { NavUser } from "@/components/nav-user"
6+
import { type NavItemType } from '@/types/navigation'
67
import {
78
Sidebar,
89
SidebarContent,
@@ -14,22 +15,15 @@ import {
1415
} from "@/components/ui/sidebar"
1516
import ApplicationLogo from "./application-logo"
1617

17-
interface NavItem {
18-
title: string
19-
url: string
20-
icon: LucideIcon
21-
isActive?: boolean
22-
}
23-
24-
const mainNavItems: NavItem[] = [
18+
const mainNavItems: NavItemType[] = [
2519
{
2620
title: "Dashboard",
2721
url: "/dashboard",
2822
icon: LayoutDashboard,
2923
},
3024
]
3125

32-
const footerNavItems: NavItem[] = [
26+
const footerNavItems: NavItemType[] = [
3327
{
3428
title: "Repository",
3529
url: "https://github.com/laravel/react-starter-kit",

resources/js/components/heading.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { Separator } from "@/components/ui/separator"
22

3-
interface HeadingProps {
3+
export default function Heading({ title, description }: {
44
title: string;
55
description?: string;
6-
}
7-
8-
export default function Heading({ title, description }: HeadingProps) {
6+
}) {
97
return (
108
<>
119
<div className="space-y-0.5">

resources/js/components/nav-footer.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { type LucideIcon, ExternalLink } from "lucide-react"
1+
import { ExternalLink } from "lucide-react"
2+
import { type NavItemType } from '@/types/navigation'
23
import {
34
SidebarGroup,
45
SidebarGroupContent,
@@ -8,18 +9,12 @@ import {
89
SidebarMenuAction
910
} from "@/components/ui/sidebar"
1011

11-
interface NavItem {
12-
title: string
13-
url: string
14-
icon: LucideIcon
15-
}
16-
1712
export function NavFooter({
1813
items,
1914
className,
2015
...props
2116
}: React.ComponentPropsWithoutRef<typeof SidebarGroup> & {
22-
items: NavItem[]
17+
items: NavItemType[]
2318
}) {
2419
return (
2520
<SidebarGroup

resources/js/components/nav-main.tsx

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

3-
import { type LucideIcon } from "lucide-react"
3+
import { type NavItemType } from '@/types/navigation'
44
import { Link } from "@inertiajs/react"
55
import {
66
SidebarGroup,
@@ -9,18 +9,9 @@ import {
99
SidebarMenuItem,
1010
} from "@/components/ui/sidebar"
1111

12-
interface NavItem {
13-
title: string
14-
url: string
15-
icon: LucideIcon
16-
isActive?: boolean
17-
}
18-
19-
interface NavMainProps {
20-
items?: NavItem[]
21-
}
22-
23-
export function NavMain({ items = [] }: NavMainProps) {
12+
export function NavMain({ items = [] }: {
13+
items: NavItemType[]
14+
}) {
2415
return (
2516
<SidebarGroup>
2617
<SidebarMenu>

resources/js/components/settings/heading.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { Separator } from "@/components/ui/separator"
22

3-
interface HeadingProps {
3+
export default function Heading({ title, description }: {
44
title: string;
55
description?: string;
6-
}
7-
8-
export default function Heading({ title, description }: HeadingProps) {
6+
}) {
97
return (
108
<div>
119
<header>

resources/js/layouts/app-layout.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,21 @@ import {
88
BreadcrumbPage,
99
BreadcrumbSeparator,
1010
} from "@/components/ui/breadcrumb"
11+
import { type BreadcrumbItemType } from '@/types'
1112
import { Separator } from "@/components/ui/separator"
1213
import {
1314
SidebarInset,
1415
SidebarProvider,
1516
SidebarTrigger,
1617
} from "@/components/ui/sidebar"
1718

18-
interface BreadcrumbItemType {
19-
title: string
20-
href: string
21-
}
22-
23-
interface AppLayoutProps {
24-
children: React.ReactNode
25-
breadcrumbs?: BreadcrumbItemType[]
26-
}
27-
2819
export default function App({
2920
children,
3021
breadcrumbs = [],
31-
}: AppLayoutProps) {
22+
}: {
23+
children: React.ReactNode
24+
breadcrumbs?: BreadcrumbItemType[]
25+
}) {
3226

3327
const [isOpen, setIsOpen] = useState(() =>
3428
typeof window !== 'undefined' ?

resources/js/layouts/auth/auth-card-layout.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ import {
88
CardTitle,
99
} from "@/components/ui/card"
1010

11-
interface AuthLayoutProps {
12-
children: React.ReactNode
13-
name?: string
14-
title?: string
15-
description?: string
16-
}
17-
1811
export default function AuthCardLayout({
1912
children,
2013
title,
2114
description
22-
}: AuthLayoutProps) {
15+
}: {
16+
children: React.ReactNode
17+
name?: string
18+
title?: string
19+
description?: string
20+
}) {
2321
const name = usePage().props.name;
2422
const quote = usePage().props.quote;
2523

resources/js/pages/dashboard.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { Head } from '@inertiajs/react'
21
import AppLayout from "@/layouts/app-layout"
2+
import { type BreadcrumbItemType } from '@/types'
3+
import { Head } from '@inertiajs/react'
34

4-
interface BreadcrumbItem {
5-
title: string
6-
href: string
7-
}
8-
9-
const breadcrumbs: BreadcrumbItem[] = [
5+
const breadcrumbs: BreadcrumbItemType[] = [
106
{
117
title: 'Dashboard',
128
href: '/dashboard'

resources/js/pages/settings/appearance.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ import { FormEventHandler } from 'react'
22
import { Head, Link, useForm, usePage } from '@inertiajs/react'
33

44
import AppearanceTabs from '@/components/appearance-tabs';
5+
import { type BreadcrumbItemType } from '@/types'
56
import SettingsHeading from "@/components/settings/heading";
67
import { Label } from "@/components/ui/label";
78

89
import AppLayout from '@/layouts/app-layout'
910
import SettingsLayout from './layout'
1011

11-
interface BreadcrumbItem {
12-
title: string
13-
href: string
14-
}
15-
16-
const breadcrumbs: BreadcrumbItem[] = [
12+
const breadcrumbs: BreadcrumbItemType[] = [
1713
{
1814
title: 'Appearance Settings',
1915
href: '/settings/appearance'

resources/js/pages/settings/layout.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@ import { Link } from "@inertiajs/react"
22
import { Button } from "@/components/ui/button"
33
import Heading from "@/components/heading";
44
import { cn } from "@/lib/utils"
5+
import { type NavItemType } from '@/types/navigation'
56

67
import { Separator } from "@/components/ui/separator"
78

89
interface LayoutProps {
910
children: React.ReactNode
1011
}
1112

12-
interface NavItem {
13-
title: string
14-
href: string
15-
}
16-
17-
const sidebarNavItems: NavItem[] = [
13+
const sidebarNavItems: NavItemType[] = [
1814
{
1915
title: "Profile",
20-
href: "/settings/profile",
16+
url: "/settings/profile",
17+
icon: null
2118
},
2219
{
2320
title: "Password",
24-
href: "/settings/password",
21+
url: "/settings/password",
22+
icon: null
2523
},
2624
{
2725
title: "Appearance",
28-
href: "/settings/appearance"
26+
url: "/settings/appearance",
27+
icon: null
2928
}
3029
]
3130

3231
export default function SettingsLayout({
3332
children
3433
}: LayoutProps) {
3534
const currentPath = window.location.pathname
36-
const currentItem = sidebarNavItems.find(item => currentPath === item.href)
35+
const currentItem = sidebarNavItems.find(item => currentPath === item.url)
3736

3837
return (
3938
<div className="p-5 sm:p-8 md:p-10">
@@ -48,16 +47,16 @@ export default function SettingsLayout({
4847
<nav className="flex-col space-x-0 space-y-1 flex">
4948
{sidebarNavItems.map((item) => (
5049
<Button
51-
key={item.href}
50+
key={item.url}
5251
size="sm"
5352
variant="ghost"
5453
asChild
5554
className={cn(
5655
"w-full justify-center justify-start",
57-
currentPath === item.href ? "bg-muted" : "hover:underline"
56+
currentPath === item.url ? "bg-muted" : "hover:underline"
5857
)}
5958
>
60-
<Link href={item.href} prefetch>
59+
<Link href={item.url} prefetch>
6160
{item.title}
6261
</Link>
6362
</Button>

0 commit comments

Comments
 (0)