Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/Settings/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function update(ProfileUpdateRequest $request): RedirectResponse

$request->user()->save();

return to_route('profile.edit');
return to_route('settings.profile');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/user-menu-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSep
import { UserInfo } from '@/components/user-info';
import { useMobileNavigation } from '@/hooks/use-mobile-navigation';
import { logout } from '@/routes';
import { edit } from '@/routes/profile';
import { profile } from '@/routes/settings';
import { type User } from '@/types';
import { Link, router } from '@inertiajs/react';
import { LogOut, Settings } from 'lucide-react';
Expand All @@ -29,7 +29,7 @@ export function UserMenuContent({ user }: UserMenuContentProps) {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild>
<Link className="block w-full" href={edit()} as="button" prefetch onClick={cleanup}>
<Link className="block w-full" href={profile()} as="button" prefetch onClick={cleanup}>
<Settings className="mr-2" />
Settings
</Link>
Expand Down
8 changes: 3 additions & 5 deletions resources/js/layouts/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ import Heading from '@/components/heading';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
import { cn } from '@/lib/utils';
import { appearance } from '@/routes';
import { edit as editPassword } from '@/routes/password';
import { edit } from '@/routes/profile';
import { appearance, password, profile } from '@/routes/settings';
import { type NavItem } from '@/types';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';

const sidebarNavItems: NavItem[] = [
{
title: 'Profile',
href: edit(),
href: profile(),
icon: null,
},
{
title: 'Password',
href: editPassword(),
href: password(),
icon: null,
},
{
Expand Down
2 changes: 1 addition & 1 deletion resources/js/pages/settings/appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type BreadcrumbItem } from '@/types';

import AppLayout from '@/layouts/app-layout';
import SettingsLayout from '@/layouts/settings/layout';
import { appearance } from '@/routes';
import { appearance } from '@/routes/settings';

const breadcrumbs: BreadcrumbItem[] = [
{
Expand Down
13 changes: 6 additions & 7 deletions resources/js/pages/settings/password.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import PasswordController from '@/actions/App/Http/Controllers/Settings/PasswordController';
import HeadingSmall from '@/components/heading-small';
import InputError from '@/components/input-error';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AppLayout from '@/layouts/app-layout';
import SettingsLayout from '@/layouts/settings/layout';
import { password } from '@/routes/settings';
import { type BreadcrumbItem } from '@/types';
import { Transition } from '@headlessui/react';
import { Form, Head } from '@inertiajs/react';
import { useRef } from 'react';

import HeadingSmall from '@/components/heading-small';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { edit } from '@/routes/password';

const breadcrumbs: BreadcrumbItem[] = [
{
title: 'Password settings',
href: edit().url,
href: password().url,
},
];

Expand Down
4 changes: 2 additions & 2 deletions resources/js/pages/settings/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AppLayout from '@/layouts/app-layout';
import SettingsLayout from '@/layouts/settings/layout';
import { edit } from '@/routes/profile';
import { profile } from '@/routes/settings';

const breadcrumbs: BreadcrumbItem[] = [
{
title: 'Profile settings',
href: edit().url,
href: profile().url,
},
];

Expand Down
12 changes: 6 additions & 6 deletions routes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
Route::middleware('auth')->group(function () {
Route::redirect('settings', '/settings/profile');

Route::get('settings/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('settings/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('settings/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
Route::get('settings/profile', [ProfileController::class, 'edit'])->name('settings.profile');
Route::patch('settings/profile', [ProfileController::class, 'update'])->name('settings.profile.update');
Route::delete('settings/profile', [ProfileController::class, 'destroy'])->name('settings.profile.destroy');

Route::get('settings/password', [PasswordController::class, 'edit'])->name('password.edit');
Route::get('settings/password', [PasswordController::class, 'edit'])->name('settings.password');

Route::put('settings/password', [PasswordController::class, 'update'])
->middleware('throttle:6,1')
->name('password.update');
->name('settings.password.update');

Route::get('settings/appearance', function () {
return Inertia::render('settings/appearance');
})->name('appearance');
})->name('settings.appearance');
});
14 changes: 7 additions & 7 deletions tests/Feature/Settings/PasswordUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function test_password_update_page_is_displayed()

$response = $this
->actingAs($user)
->get(route('password.edit'));
->get(route('settings.password'));

$response->assertStatus(200);
}
Expand All @@ -28,16 +28,16 @@ public function test_password_can_be_updated()

$response = $this
->actingAs($user)
->from(route('password.edit'))
->put(route('password.update'), [
->from(route('settings.password'))
->put(route('settings.password.update'), [
'current_password' => 'password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);

$response
->assertSessionHasNoErrors()
->assertRedirect(route('password.edit'));
->assertRedirect(route('settings.password'));

$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
}
Expand All @@ -48,15 +48,15 @@ public function test_correct_password_must_be_provided_to_update_password()

$response = $this
->actingAs($user)
->from(route('password.edit'))
->put(route('password.update'), [
->from(route('settings.password'))
->put(route('settings.password.update'), [
'current_password' => 'wrong-password',
'password' => 'new-password',
'password_confirmation' => 'new-password',
]);

$response
->assertSessionHasErrors('current_password')
->assertRedirect(route('password.edit'));
->assertRedirect(route('settings.password'));
}
}
18 changes: 9 additions & 9 deletions tests/Feature/Settings/ProfileUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function test_profile_page_is_displayed()

$response = $this
->actingAs($user)
->get(route('profile.edit'));
->get(route('settings.profile'));

$response->assertOk();
}
Expand All @@ -27,14 +27,14 @@ public function test_profile_information_can_be_updated()

$response = $this
->actingAs($user)
->patch(route('profile.update'), [
->patch(route('settings.profile.update'), [
'name' => 'Test User',
'email' => '[email protected]',
]);

$response
->assertSessionHasNoErrors()
->assertRedirect(route('profile.edit'));
->assertRedirect(route('settings.profile'));

$user->refresh();

Expand All @@ -49,14 +49,14 @@ public function test_email_verification_status_is_unchanged_when_the_email_addre

$response = $this
->actingAs($user)
->patch(route('profile.update'), [
->patch(route('settings.profile.update'), [
'name' => 'Test User',
'email' => $user->email,
]);

$response
->assertSessionHasNoErrors()
->assertRedirect(route('profile.edit'));
->assertRedirect(route('settings.profile'));

$this->assertNotNull($user->refresh()->email_verified_at);
}
Expand All @@ -67,7 +67,7 @@ public function test_user_can_delete_their_account()

$response = $this
->actingAs($user)
->delete(route('profile.destroy'), [
->delete(route('settings.profile.destroy'), [
'password' => 'password',
]);

Expand All @@ -85,14 +85,14 @@ public function test_correct_password_must_be_provided_to_delete_account()

$response = $this
->actingAs($user)
->from(route('profile.edit'))
->delete(route('profile.destroy'), [
->from(route('settings.profile'))
->delete(route('settings.profile.destroy'), [
'password' => 'wrong-password',
]);

$response
->assertSessionHasErrors('password')
->assertRedirect(route('profile.edit'));
->assertRedirect(route('settings.profile'));

$this->assertNotNull($user->fresh());
}
Expand Down