From ef5da56a6067147628ff7c25a5065cf21dbf3a42 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 11:30:38 -0600 Subject: [PATCH 1/8] wording updates --- app/Http/Controllers/Settings/PasswordController.php | 2 +- app/Http/Controllers/Settings/ProfileController.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Settings/PasswordController.php b/app/Http/Controllers/Settings/PasswordController.php index 70fc344f7..69cef63ef 100644 --- a/app/Http/Controllers/Settings/PasswordController.php +++ b/app/Http/Controllers/Settings/PasswordController.php @@ -14,7 +14,7 @@ class PasswordController extends Controller { /** - * Display the user's password form. + * Display the user's password settings form. */ public function edit(Request $request): Response { diff --git a/app/Http/Controllers/Settings/ProfileController.php b/app/Http/Controllers/Settings/ProfileController.php index c0ce49564..6744eb438 100644 --- a/app/Http/Controllers/Settings/ProfileController.php +++ b/app/Http/Controllers/Settings/ProfileController.php @@ -15,7 +15,7 @@ class ProfileController extends Controller { /** - * Display the user's profile form. + * Display the user's profile settings form. */ public function edit(Request $request): Response { @@ -26,7 +26,7 @@ public function edit(Request $request): Response } /** - * Update the user's profile information. + * Update the user's profile settings. */ public function update(ProfileUpdateRequest $request): RedirectResponse { From 72b1fed1cfd05ab711863ac25eef2ad9edccb6e3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:16:38 -0600 Subject: [PATCH 2/8] formatting --- .../Controllers/Auth/AuthenticatedSessionController.php | 3 +-- .../Controllers/Auth/ConfirmablePasswordController.php | 2 +- .../Auth/EmailVerificationPromptController.php | 2 +- app/Http/Controllers/Auth/NewPasswordController.php | 6 +++--- .../Controllers/Auth/PasswordResetLinkController.php | 9 +++------ app/Http/Controllers/Auth/RegisteredUserController.php | 4 ++-- app/Http/Controllers/Settings/PasswordController.php | 2 +- app/Http/Controllers/Settings/ProfileController.php | 8 ++++---- app/Http/Middleware/HandleInertiaRequests.php | 4 ++-- app/Http/Requests/Auth/LoginRequest.php | 4 ++-- app/Http/Requests/Settings/ProfileUpdateRequest.php | 4 +++- bootstrap/app.php | 6 ++++-- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index 480c7f4af..fe6b8512e 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -14,7 +14,7 @@ class AuthenticatedSessionController extends Controller { /** - * Display the login view. + * Display the login page. */ public function create(): Response { @@ -44,7 +44,6 @@ public function destroy(Request $request): RedirectResponse Auth::guard('web')->logout(); $request->session()->invalidate(); - $request->session()->regenerateToken(); return redirect('/'); diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index b16dcebfe..c729706d6 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -13,7 +13,7 @@ class ConfirmablePasswordController extends Controller { /** - * Show the confirm password view. + * Show the confirm password page. */ public function show(): Response { diff --git a/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/app/Http/Controllers/Auth/EmailVerificationPromptController.php index 8451d8128..ca4c758df 100644 --- a/app/Http/Controllers/Auth/EmailVerificationPromptController.php +++ b/app/Http/Controllers/Auth/EmailVerificationPromptController.php @@ -13,7 +13,7 @@ class EmailVerificationPromptController extends Controller /** * Display the email verification prompt. */ - public function __invoke(Request $request): RedirectResponse|Response + public function __invoke(Request $request): Response|RedirectResponse { return $request->user()->hasVerifiedEmail() ? redirect()->intended(route('dashboard', absolute: false)) diff --git a/app/Http/Controllers/Auth/NewPasswordController.php b/app/Http/Controllers/Auth/NewPasswordController.php index fd5768039..f4dd8df8a 100644 --- a/app/Http/Controllers/Auth/NewPasswordController.php +++ b/app/Http/Controllers/Auth/NewPasswordController.php @@ -17,7 +17,7 @@ class NewPasswordController extends Controller { /** - * Display the password reset view. + * Display the password reset page. */ public function create(Request $request): Response { @@ -59,11 +59,11 @@ function ($user) use ($request) { // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. if ($status == Password::PasswordReset) { - return redirect()->route('login')->with('status', __($status)); + return to_route('login')->with('status', __($status)); } throw ValidationException::withMessages([ - 'email' => [trans($status)], + 'email' => [__($status)], ]); } } diff --git a/app/Http/Controllers/Auth/PasswordResetLinkController.php b/app/Http/Controllers/Auth/PasswordResetLinkController.php index 14a1b248e..341c21eef 100644 --- a/app/Http/Controllers/Auth/PasswordResetLinkController.php +++ b/app/Http/Controllers/Auth/PasswordResetLinkController.php @@ -14,10 +14,10 @@ class PasswordResetLinkController extends Controller /** * Display the password reset link request view. */ - public function create(): Response + public function create(Request $request): Response { return Inertia::render('auth/forgot-password', [ - 'status' => session('status'), + 'status' => $request->session()->get('status'), ]); } @@ -32,13 +32,10 @@ public function store(Request $request): RedirectResponse 'email' => 'required|email', ]); - // We will send the password reset link to this user if the email exists Password::sendResetLink( $request->only('email') ); - // We want to always return a 200 response, even if the user is not found. This is a - // security measure to prevent email accounts from being discovered - return back()->with('status', __('If that email exists in our system, a reset link was sent.')); + return back()->with('status', __('If an account exists with that email, you’ll receive a reset link shortly.')); } } diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index 57dda7d46..bbf6d2b22 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -16,7 +16,7 @@ class RegisteredUserController extends Controller { /** - * Display the registration view. + * Display the registration page. */ public function create(): Response { @@ -46,6 +46,6 @@ public function store(Request $request): RedirectResponse Auth::login($user); - return redirect(route('dashboard', absolute: false)); + return to_route('dashboard'); } } diff --git a/app/Http/Controllers/Settings/PasswordController.php b/app/Http/Controllers/Settings/PasswordController.php index 69cef63ef..bd18196f7 100644 --- a/app/Http/Controllers/Settings/PasswordController.php +++ b/app/Http/Controllers/Settings/PasswordController.php @@ -20,7 +20,7 @@ public function edit(Request $request): Response { return Inertia::render('settings/password', [ 'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail, - 'status' => session('status'), + 'status' => $request->session()->get('status'), ]); } diff --git a/app/Http/Controllers/Settings/ProfileController.php b/app/Http/Controllers/Settings/ProfileController.php index 6744eb438..7706083be 100644 --- a/app/Http/Controllers/Settings/ProfileController.php +++ b/app/Http/Controllers/Settings/ProfileController.php @@ -21,7 +21,7 @@ public function edit(Request $request): Response { return Inertia::render('settings/profile', [ 'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail, - 'status' => session('status'), + 'status' => $request->session()->get('status'), ]); } @@ -38,11 +38,11 @@ public function update(ProfileUpdateRequest $request): RedirectResponse $request->user()->save(); - return Redirect::route('profile.edit'); + return to_route('profile.edit'); } /** - * Delete the user's profile. + * Delete the user's account. */ public function destroy(Request $request): RedirectResponse { @@ -59,6 +59,6 @@ public function destroy(Request $request): RedirectResponse $request->session()->invalidate(); $request->session()->regenerateToken(); - return Redirect::to('/'); + return redirect('/'); } } diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 04a98f5ed..5119b57a3 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -40,11 +40,11 @@ public function share(Request $request): array return array_merge(parent::share($request), [ ...parent::share($request), + 'name' => config('app.name'), + 'quote' => ['message' => trim($message), 'author' => trim($author)], 'auth' => [ 'user' => $request->user(), ], - 'name' => config('app.name'), - 'quote' => ['message' => trim($message), 'author' => trim($author)], ]); } } diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index 257464245..d236bf93c 100644 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -45,7 +45,7 @@ public function authenticate(): void RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ - 'email' => trans('auth.failed'), + 'email' => __('auth.failed'), ]); } @@ -68,7 +68,7 @@ public function ensureIsNotRateLimited(): void $seconds = RateLimiter::availableIn($this->throttleKey()); throw ValidationException::withMessages([ - 'email' => trans('auth.throttle', [ + 'email' => __('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ]), diff --git a/app/Http/Requests/Settings/ProfileUpdateRequest.php b/app/Http/Requests/Settings/ProfileUpdateRequest.php index c294aab26..64cf26b09 100644 --- a/app/Http/Requests/Settings/ProfileUpdateRequest.php +++ b/app/Http/Requests/Settings/ProfileUpdateRequest.php @@ -3,6 +3,7 @@ namespace App\Http\Requests\Settings; use App\Models\User; +use Illuminate\Contracts\Validation\ValidationRule; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rule; @@ -11,12 +12,13 @@ class ProfileUpdateRequest extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array|string> */ public function rules(): array { return [ 'name' => ['required', 'string', 'max:255'], + 'email' => [ 'required', 'string', diff --git a/bootstrap/app.php b/bootstrap/app.php index 7c3387621..a827a7f57 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,8 +1,10 @@ withRouting( @@ -12,8 +14,8 @@ ) ->withMiddleware(function (Middleware $middleware) { $middleware->web(append: [ - \App\Http\Middleware\HandleInertiaRequests::class, - \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class, + HandleInertiaRequests::class, + AddLinkHeadersForPreloadedAssets::class, ]); }) ->withExceptions(function (Exceptions $exceptions) { From 3c8a01b2f7d6cbc134591e9ec49e9b55f8abf1a3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:30:06 -0600 Subject: [PATCH 3/8] formatting --- resources/js/components/app-shell.tsx | 1 + resources/js/hooks/use-appearance.tsx | 3 ++- resources/js/hooks/use-mobile-navigation.ts | 4 ++-- resources/js/lib/utils.ts | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/js/components/app-shell.tsx b/resources/js/components/app-shell.tsx index 156906542..1e576119d 100644 --- a/resources/js/components/app-shell.tsx +++ b/resources/js/components/app-shell.tsx @@ -11,6 +11,7 @@ export function AppShell({ children, variant = 'header' }: AppShellProps) { const handleSidebarChange = (open: boolean) => { setIsOpen(open); + if (typeof window !== 'undefined') { localStorage.setItem('sidebar', String(open)); } diff --git a/resources/js/hooks/use-appearance.tsx b/resources/js/hooks/use-appearance.tsx index 5c9493675..db261ba22 100644 --- a/resources/js/hooks/use-appearance.tsx +++ b/resources/js/hooks/use-appearance.tsx @@ -18,9 +18,10 @@ const handleSystemThemeChange = () => { export function initializeTheme() { const savedAppearance = (localStorage.getItem('appearance') as Appearance) || 'system'; + applyTheme(savedAppearance); - // Add the event listener for system theme changes + // Add the event listener for system theme changes... mediaQuery.addEventListener('change', handleSystemThemeChange); } diff --git a/resources/js/hooks/use-mobile-navigation.ts b/resources/js/hooks/use-mobile-navigation.ts index 2f83685cd..ffb41aad0 100644 --- a/resources/js/hooks/use-mobile-navigation.ts +++ b/resources/js/hooks/use-mobile-navigation.ts @@ -2,9 +2,9 @@ import { useCallback } from 'react'; export function useMobileNavigation() { const cleanup = useCallback(() => { - // Remove pointer-events style from body + // Remove pointer-events style from body... document.body.style.removeProperty('pointer-events'); - // Find and click the close button of any open sheet + // Find and click the close button of any open sheet... const closeButton = document.querySelector('[data-radix-collection-item]'); if (closeButton instanceof HTMLElement) { closeButton.click(); diff --git a/resources/js/lib/utils.ts b/resources/js/lib/utils.ts index a7de77ccd..becb32f0c 100644 --- a/resources/js/lib/utils.ts +++ b/resources/js/lib/utils.ts @@ -6,9 +6,9 @@ export function cn(...inputs: ClassValue[]) { } export function cleanupMobileNavigation() { - // Remove pointer-events style from body + // Remove pointer-events style from body... document.body.style.removeProperty('pointer-events'); - // Dispatch a custom event that the sidebar can listen to + // Dispatch a custom event that the sidebar can listen to... window.dispatchEvent(new CustomEvent('mobile-navigation')); } From 22e2f185e1bd8c5eb8c55d2f3b9f867345d79ff3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:31:45 -0600 Subject: [PATCH 4/8] formatting --- resources/js/app.tsx | 2 +- resources/js/hooks/use-mobile-navigation.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/js/app.tsx b/resources/js/app.tsx index 42dd864eb..3f7401a4a 100644 --- a/resources/js/app.tsx +++ b/resources/js/app.tsx @@ -25,5 +25,5 @@ createInertiaApp({ }, }); -// This will set dark/light mode on load +// This will set light / dark mode on load... initializeTheme(); diff --git a/resources/js/hooks/use-mobile-navigation.ts b/resources/js/hooks/use-mobile-navigation.ts index ffb41aad0..174b776ce 100644 --- a/resources/js/hooks/use-mobile-navigation.ts +++ b/resources/js/hooks/use-mobile-navigation.ts @@ -4,8 +4,10 @@ export function useMobileNavigation() { const cleanup = useCallback(() => { // Remove pointer-events style from body... document.body.style.removeProperty('pointer-events'); + // Find and click the close button of any open sheet... const closeButton = document.querySelector('[data-radix-collection-item]'); + if (closeButton instanceof HTMLElement) { closeButton.click(); } From b1f738fb30005a5a0795909b5e26bf1514603ce0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:32:59 -0600 Subject: [PATCH 5/8] formatting --- resources/js/components/delete-user.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/components/delete-user.tsx b/resources/js/components/delete-user.tsx index b86e3f369..e6b0aecb1 100644 --- a/resources/js/components/delete-user.tsx +++ b/resources/js/components/delete-user.tsx @@ -1,7 +1,7 @@ import { useForm } from '@inertiajs/react'; import { FormEventHandler, useRef } from 'react'; -// Components +// Components... import InputError from '@/components/input-error'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; From 38130cf5b5f69bee871e00f74e6674959590c213 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:34:25 -0600 Subject: [PATCH 6/8] consistency --- app/Http/Controllers/Auth/AuthenticatedSessionController.php | 2 +- app/Http/Controllers/Auth/EmailVerificationPromptController.php | 2 +- app/Http/Controllers/Auth/NewPasswordController.php | 2 +- app/Http/Controllers/Auth/PasswordResetLinkController.php | 2 +- app/Http/Controllers/Auth/RegisteredUserController.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index fe6b8512e..627ade535 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -14,7 +14,7 @@ class AuthenticatedSessionController extends Controller { /** - * Display the login page. + * Show the login page. */ public function create(): Response { diff --git a/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/app/Http/Controllers/Auth/EmailVerificationPromptController.php index ca4c758df..7a81ebe66 100644 --- a/app/Http/Controllers/Auth/EmailVerificationPromptController.php +++ b/app/Http/Controllers/Auth/EmailVerificationPromptController.php @@ -11,7 +11,7 @@ class EmailVerificationPromptController extends Controller { /** - * Display the email verification prompt. + * Show the email verification prompt. */ public function __invoke(Request $request): Response|RedirectResponse { diff --git a/app/Http/Controllers/Auth/NewPasswordController.php b/app/Http/Controllers/Auth/NewPasswordController.php index f4dd8df8a..0b4c6cbd3 100644 --- a/app/Http/Controllers/Auth/NewPasswordController.php +++ b/app/Http/Controllers/Auth/NewPasswordController.php @@ -17,7 +17,7 @@ class NewPasswordController extends Controller { /** - * Display the password reset page. + * Show the password reset page. */ public function create(Request $request): Response { diff --git a/app/Http/Controllers/Auth/PasswordResetLinkController.php b/app/Http/Controllers/Auth/PasswordResetLinkController.php index 341c21eef..41ca281a8 100644 --- a/app/Http/Controllers/Auth/PasswordResetLinkController.php +++ b/app/Http/Controllers/Auth/PasswordResetLinkController.php @@ -12,7 +12,7 @@ class PasswordResetLinkController extends Controller { /** - * Display the password reset link request view. + * Show the password reset link request page. */ public function create(Request $request): Response { diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index bbf6d2b22..db903e8ee 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -16,7 +16,7 @@ class RegisteredUserController extends Controller { /** - * Display the registration page. + * Show the registration page. */ public function create(): Response { From 6fdc1899737cb83239b84f60e184cae43e9b552f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:35:56 -0600 Subject: [PATCH 7/8] remove util --- resources/js/lib/utils.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/resources/js/lib/utils.ts b/resources/js/lib/utils.ts index becb32f0c..dd53ea892 100644 --- a/resources/js/lib/utils.ts +++ b/resources/js/lib/utils.ts @@ -4,11 +4,3 @@ import { twMerge } from 'tailwind-merge'; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } - -export function cleanupMobileNavigation() { - // Remove pointer-events style from body... - document.body.style.removeProperty('pointer-events'); - - // Dispatch a custom event that the sidebar can listen to... - window.dispatchEvent(new CustomEvent('mobile-navigation')); -} From cd3bc53ae427d05bdcf53b6d812dbdb0bceea160 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 10 Feb 2025 12:39:51 -0600 Subject: [PATCH 8/8] formatting --- resources/js/hooks/use-appearance.tsx | 1 + resources/js/hooks/use-initials.tsx | 2 ++ resources/js/hooks/use-mobile.tsx | 3 +++ 3 files changed, 6 insertions(+) diff --git a/resources/js/hooks/use-appearance.tsx b/resources/js/hooks/use-appearance.tsx index db261ba22..f8972a11e 100644 --- a/resources/js/hooks/use-appearance.tsx +++ b/resources/js/hooks/use-appearance.tsx @@ -11,6 +11,7 @@ const applyTheme = (appearance: Appearance) => { }; const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); + const handleSystemThemeChange = () => { const currentAppearance = localStorage.getItem('appearance') as Appearance; applyTheme(currentAppearance || 'system'); diff --git a/resources/js/hooks/use-initials.tsx b/resources/js/hooks/use-initials.tsx index 2e3946a47..c4478c37d 100644 --- a/resources/js/hooks/use-initials.tsx +++ b/resources/js/hooks/use-initials.tsx @@ -1,8 +1,10 @@ export function useInitials() { const getInitials = (fullName: string): string => { const names = fullName.trim().split(' '); + if (names.length === 0) return ''; if (names.length === 1) return names[0].charAt(0).toUpperCase(); + return `${names[0].charAt(0)}${names[names.length - 1].charAt(0)}`.toUpperCase(); }; diff --git a/resources/js/hooks/use-mobile.tsx b/resources/js/hooks/use-mobile.tsx index c9250167d..14a981077 100644 --- a/resources/js/hooks/use-mobile.tsx +++ b/resources/js/hooks/use-mobile.tsx @@ -7,11 +7,14 @@ export function useIsMobile() { React.useEffect(() => { const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`); + const onChange = () => { setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); }; + mql.addEventListener('change', onChange); setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); + return () => mql.removeEventListener('change', onChange); }, []);