Skip to content

Formatting #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 10, 2025
Merged
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
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
* Show the login page.
*/
public function create(): Response
{
Expand Down Expand Up @@ -44,7 +44,6 @@ public function destroy(Request $request): RedirectResponse
Auth::guard('web')->logout();

$request->session()->invalidate();

$request->session()->regenerateToken();

return redirect('/');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
* Show the confirm password page.
*/
public function show(): Response
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
* Show 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))
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Auth/NewPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
* Show the password reset page.
*/
public function create(Request $request): Response
{
Expand Down Expand Up @@ -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)],
]);
}
}
11 changes: 4 additions & 7 deletions app/Http/Controllers/Auth/PasswordResetLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
* Show the password reset link request page.
*/
public function create(): Response
public function create(Request $request): Response
{
return Inertia::render('auth/forgot-password', [
'status' => session('status'),
'status' => $request->session()->get('status'),
]);
}

Expand All @@ -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.'));
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
* Show the registration page.
*/
public function create(): Response
{
Expand Down Expand Up @@ -46,6 +46,6 @@ public function store(Request $request): RedirectResponse

Auth::login($user);

return redirect(route('dashboard', absolute: false));
return to_route('dashboard');
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/Settings/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
class PasswordController extends Controller
{
/**
* Display the user's password form.
* Display the user's password settings form.
*/
public function edit(Request $request): Response
{
return Inertia::render('settings/password', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
'status' => $request->session()->get('status'),
]);
}

Expand Down
12 changes: 6 additions & 6 deletions app/Http/Controllers/Settings/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
class ProfileController extends Controller
{
/**
* Display the user's profile form.
* Display the user's profile settings form.
*/
public function edit(Request $request): Response
{
return Inertia::render('settings/profile', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
'status' => $request->session()->get('status'),
]);
}

/**
* Update the user's profile information.
* Update the user's profile settings.
*/
public function update(ProfileUpdateRequest $request): RedirectResponse
{
Expand All @@ -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
{
Expand All @@ -59,6 +59,6 @@ public function destroy(Request $request): RedirectResponse
$request->session()->invalidate();
$request->session()->regenerateToken();

return Redirect::to('/');
return redirect('/');
}
}
4 changes: 2 additions & 2 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
]);
}
}
4 changes: 2 additions & 2 deletions app/Http/Requests/Auth/LoginRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function authenticate(): void
RateLimiter::hit($this->throttleKey());

throw ValidationException::withMessages([
'email' => trans('auth.failed'),
'email' => __('auth.failed'),
]);
}

Expand All @@ -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),
]),
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Requests/Settings/ProfileUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -11,12 +12,13 @@ class ProfileUpdateRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],

'email' => [
'required',
'string',
Expand Down
6 changes: 4 additions & 2 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

use App\Http\Middleware\HandleInertiaRequests;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets;

return Application::configure(basePath: dirname(__DIR__))
->withRouting(
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ createInertiaApp({
},
});

// This will set dark/light mode on load
// This will set light / dark mode on load...
initializeTheme();
1 change: 1 addition & 0 deletions resources/js/components/app-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/delete-user.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 3 additions & 1 deletion resources/js/hooks/use-appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ const applyTheme = (appearance: Appearance) => {
};

const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');

const handleSystemThemeChange = () => {
const currentAppearance = localStorage.getItem('appearance') as Appearance;
applyTheme(currentAppearance || 'system');
};

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);
}

Expand Down
2 changes: 2 additions & 0 deletions resources/js/hooks/use-initials.tsx
Original file line number Diff line number Diff line change
@@ -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();
};

Expand Down
6 changes: 4 additions & 2 deletions resources/js/hooks/use-mobile-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ 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();
}
Expand Down
3 changes: 3 additions & 0 deletions resources/js/hooks/use-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);

Expand Down
8 changes: 0 additions & 8 deletions resources/js/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}