Skip to content

Commit 7991423

Browse files
author
Tony Lea
committed
Adding new sections for settings
1 parent bc03365 commit 7991423

File tree

14 files changed

+388
-610
lines changed

14 files changed

+388
-610
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Settings;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\RedirectResponse;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Hash;
9+
use Illuminate\Validation\Rules\Password;
10+
use Inertia\Inertia;
11+
use Inertia\Response;
12+
13+
class PasswordController extends Controller
14+
{
15+
/**
16+
* Display the user's password form.
17+
*/
18+
public function edit(Request $request): Response
19+
{
20+
return Inertia::render('Settings/Password', [
21+
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
22+
'status' => session('status'),
23+
]);
24+
}
25+
26+
/**
27+
* Update the user's password.
28+
*/
29+
public function update(Request $request): RedirectResponse
30+
{
31+
$validated = $request->validate([
32+
'current_password' => ['required', 'current_password'],
33+
'password' => ['required', Password::defaults(), 'confirmed'],
34+
]);
35+
36+
$request->user()->update([
37+
'password' => Hash::make($validated['password']),
38+
]);
39+
40+
return back();
41+
}
42+
}

resources/js/Components/NavSecondary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function NavSecondary({
2727
{items.map((item) => (
2828
<SidebarMenuItem key={item.title}>
2929
<SidebarMenuButton asChild>
30-
<a href={item.url} target="_blank" class="w-full block justify-between">
30+
<a href={item.url} target="_blank">
3131
<item.icon />
3232
<span>{item.title}</span>
3333
</a>

resources/js/Layouts/AppLayout.tsx

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,66 @@ import {
44
BreadcrumbItem,
55
BreadcrumbList,
66
BreadcrumbPage,
7+
BreadcrumbLink,
8+
BreadcrumbSeparator
79
} from "@/components/ui/breadcrumb"
810
import { Separator } from "@/components/ui/separator"
911
import {
1012
SidebarInset,
1113
SidebarProvider,
1214
SidebarTrigger,
1315
} from "@/components/ui/sidebar"
14-
import { PropsWithChildren } from 'react';
16+
import { PropsWithChildren, Fragment } from 'react';
1517

16-
export default function App({ children }: PropsWithChildren) {
18+
interface BreadcrumbItem {
19+
title: string;
20+
href: string;
21+
}
22+
23+
interface AppLayoutProps {
24+
children: React.ReactNode;
25+
breadcrumbItems?: BreadcrumbItem[];
26+
}
27+
28+
export default function App({
29+
children,
30+
breadcrumbItems = [],
31+
}: AppLayoutProps) {
1732
return (
1833
<SidebarProvider>
1934
<AppSidebar />
2035
<SidebarInset>
2136
<header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
2237
<SidebarTrigger className="-ml-1" />
23-
<Separator orientation="vertical" className="mr-2 h-4" />
24-
<Breadcrumb>
25-
<BreadcrumbList>
26-
<BreadcrumbItem>
27-
<BreadcrumbPage>Dashboard</BreadcrumbPage>
28-
</BreadcrumbItem>
29-
</BreadcrumbList>
30-
</Breadcrumb>
38+
{breadcrumbItems.length > 0 && (
39+
<>
40+
<Separator orientation="vertical" className="mr-2 h-4" />
41+
<Breadcrumb>
42+
<BreadcrumbList>
43+
{breadcrumbItems.map((item, index) => {
44+
const isLast = index === breadcrumbItems.length - 1;
45+
46+
return (
47+
<Fragment key={index}>
48+
<BreadcrumbItem>
49+
{isLast ? (
50+
<BreadcrumbPage>{item.title}</BreadcrumbPage>
51+
) : (
52+
<BreadcrumbLink href={item.href}>
53+
{item.title}
54+
</BreadcrumbLink>
55+
)}
56+
</BreadcrumbItem>
57+
{!isLast && (
58+
<BreadcrumbSeparator className="hidden md:block" />
59+
)}
60+
</Fragment>
61+
);
62+
})}
63+
</BreadcrumbList>
64+
</Breadcrumb>
65+
</>
66+
)}
3167
</header>
3268
{children}
3369
</SidebarInset>

resources/js/Pages/Dashboard.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import AppLayout from "@/Layouts/AppLayout"
22
import { Head } from '@inertiajs/react';
33

4+
const breadcrumbItems = [
5+
{
6+
title: 'Dashboard',
7+
href: '/dashboard'
8+
}
9+
]
10+
411
export default function Page() {
512
return (
6-
<AppLayout>
13+
<AppLayout
14+
breadcrumbItems={breadcrumbItems}
15+
>
716
<Head title="Dashboard" />
817
<div className="flex flex-1 flex-col gap-4 p-4">
918
<div className="grid auto-rows-min gap-4 md:grid-cols-3">

resources/js/Pages/Profile/Edit.tsx

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

resources/js/Pages/Profile/Layout.tsx

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

resources/js/Pages/Profile/Partials/DeleteUserForm.tsx

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

0 commit comments

Comments
 (0)