Skip to content

Replace ziggy with wayfinder #148

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
- name: Install Node Dependencies
run: npm ci

- name: Build Assets
run: npm run build

- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Build Assets
run: npm run build

- name: Copy Environment File
run: cp .env.example .env

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/public/build
/public/hot
/public/storage
/resources/js/actions
/resources/js/routes
/resources/js/wayfinder
/storage/*.key
/storage/pail
/vendor
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
resources/js/components/ui/*
resources/js/ziggy.js
resources/views/mail/*
5 changes: 0 additions & 5 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Tighten\Ziggy\Ziggy;

class HandleInertiaRequests extends Middleware
{
Expand Down Expand Up @@ -46,10 +45,6 @@ public function share(Request $request): array
'auth' => [
'user' => $request->user(),
],
'ziggy' => fn (): array => [
...(new Ziggy)->toArray(),
'location' => $request->url(),
],
'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"inertiajs/inertia-laravel": "^2.0",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1",
"tightenco/ziggy": "^2.4"
"laravel/wayfinder": "^0.1.6"
},
"require-dev": {
"fakerphp/faker": "^1.23",
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@laravel/vite-plugin-wayfinder": "^0.1.3",
"@types/node": "^22.13.5",
"eslint": "^9.17.0",
"eslint-config-prettier": "^10.0.1",
Expand Down
5 changes: 3 additions & 2 deletions resources/js/components/delete-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import { Label } from '@/components/ui/label';
import HeadingSmall from '@/components/heading-small';

import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger } from '@/components/ui/dialog';
import { destroy } from '@/actions/App/Http/Controllers/Settings/ProfileController';

export default function DeleteUser() {
const passwordInput = useRef<HTMLInputElement>(null);
const { data, setData, delete: destroy, processing, reset, errors, clearErrors } = useForm<Required<{ password: string }>>({ password: '' });
const { data, setData, submit, processing, reset, errors, clearErrors } = useForm<Required<{ password: string }>>({ password: '' });

const deleteUser: FormEventHandler = (e) => {
e.preventDefault();

destroy(route('profile.destroy'), {
submit(destroy(), {
preserveScroll: true,
onSuccess: () => closeModal(),
onError: () => passwordInput.current?.focus(),
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/user-menu-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { useMobileNavigation } from '@/hooks/use-mobile-navigation';
import { type User } from '@/types';
import { Link, router } from '@inertiajs/react';
import { LogOut, Settings } from 'lucide-react';
import { edit } from '@/routes/profile';
import { logout } from '@/routes';

interface UserMenuContentProps {
user: User;
Expand All @@ -27,15 +29,15 @@ export function UserMenuContent({ user }: UserMenuContentProps) {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild>
<Link className="block w-full" href={route('profile.edit')} as="button" prefetch onClick={cleanup}>
<Link className="block w-full" href={edit()} as="button" prefetch onClick={cleanup}>
<Settings className="mr-2" />
Settings
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem asChild>
<Link className="block w-full" method="post" href={route('logout')} as="button" onClick={handleLogout}>
<Link className="block w-full" method="post" href={logout()} as="button" onClick={handleLogout}>
<LogOut className="mr-2" />
Log out
</Link>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/layouts/auth/auth-card-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AppLogoIcon from '@/components/app-logo-icon';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';
import { home } from '@/routes';

export default function AuthCardLayout({
children,
Expand All @@ -15,7 +16,7 @@ export default function AuthCardLayout({
return (
<div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">
<div className="flex w-full max-w-md flex-col gap-6">
<Link href={route('home')} className="flex items-center gap-2 self-center font-medium">
<Link href={home()} className="flex items-center gap-2 self-center font-medium">
<div className="flex h-9 w-9 items-center justify-center">
<AppLogoIcon className="size-9 fill-current text-black dark:text-white" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/layouts/auth/auth-simple-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AppLogoIcon from '@/components/app-logo-icon';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';
import { home } from '@/routes';

interface AuthLayoutProps {
name?: string;
Expand All @@ -14,7 +15,7 @@ export default function AuthSimpleLayout({ children, title, description }: Props
<div className="w-full max-w-sm">
<div className="flex flex-col gap-8">
<div className="flex flex-col items-center gap-4">
<Link href={route('home')} className="flex flex-col items-center gap-2 font-medium">
<Link href={home()} className="flex flex-col items-center gap-2 font-medium">
<div className="mb-1 flex h-9 w-9 items-center justify-center rounded-md">
<AppLogoIcon className="size-9 fill-current text-[var(--foreground)] dark:text-white" />
</div>
Expand Down
5 changes: 3 additions & 2 deletions resources/js/layouts/auth/auth-split-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AppLogoIcon from '@/components/app-logo-icon';
import { type SharedData } from '@/types';
import { Link, usePage } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';
import { home } from '@/routes';

interface AuthLayoutProps {
title?: string;
Expand All @@ -15,7 +16,7 @@ export default function AuthSplitLayout({ children, title, description }: PropsW
<div className="relative grid h-dvh flex-col items-center justify-center px-8 sm:px-0 lg:max-w-none lg:grid-cols-2 lg:px-0">
<div className="relative hidden h-full flex-col bg-muted p-10 text-white lg:flex dark:border-r">
<div className="absolute inset-0 bg-zinc-900" />
<Link href={route('home')} className="relative z-20 flex items-center text-lg font-medium">
<Link href={home()} className="relative z-20 flex items-center text-lg font-medium">
<AppLogoIcon className="mr-2 size-8 fill-current text-white" />
{name}
</Link>
Expand All @@ -30,7 +31,7 @@ export default function AuthSplitLayout({ children, title, description }: PropsW
</div>
<div className="w-full lg:p-8">
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
<Link href={route('home')} className="relative z-20 flex items-center justify-center lg:hidden">
<Link href={home()} className="relative z-20 flex items-center justify-center lg:hidden">
<AppLogoIcon className="h-10 fill-current text-black sm:h-12" />
</Link>
<div className="flex flex-col items-start gap-2 text-left sm:items-center sm:text-center">
Expand Down
9 changes: 5 additions & 4 deletions resources/js/pages/auth/confirm-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AuthLayout from '@/layouts/auth-layout';
import { store } from '@/actions/App/Http/Controllers/Auth/ConfirmablePasswordController';

export default function ConfirmPassword() {
const { data, setData, post, processing, errors, reset } = useForm<Required<{ password: string }>>({
const { data, setData, submit, processing, errors, reset } = useForm<Required<{ password: string }>>({
password: '',
});

const submit: FormEventHandler = (e) => {
const submitForm: FormEventHandler = (e) => {
e.preventDefault();

post(route('password.confirm'), {
submit(store(), {
onFinish: () => reset('password'),
});
};
Expand All @@ -29,7 +30,7 @@ export default function ConfirmPassword() {
>
<Head title="Confirm password" />

<form onSubmit={submit}>
<form onSubmit={submitForm}>
<div className="space-y-6">
<div className="grid gap-2">
<Label htmlFor="password">Password</Label>
Expand Down
12 changes: 7 additions & 5 deletions resources/js/pages/auth/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AuthLayout from '@/layouts/auth-layout';
import { store } from '@/actions/App/Http/Controllers/Auth/PasswordResetLinkController';
import { login } from '@/routes';

export default function ForgotPassword({ status }: { status?: string }) {
const { data, setData, post, processing, errors } = useForm<Required<{ email: string }>>({
const { data, setData, submit, processing, errors } = useForm<Required<{ email: string }>>({
email: '',
});

const submit: FormEventHandler = (e) => {
const submitForm: FormEventHandler = (e) => {
e.preventDefault();

post(route('password.email'));
submit(store());
};

return (
Expand All @@ -28,7 +30,7 @@ export default function ForgotPassword({ status }: { status?: string }) {
{status && <div className="mb-4 text-center text-sm font-medium text-green-600">{status}</div>}

<div className="space-y-6">
<form onSubmit={submit}>
<form onSubmit={submitForm}>
<div className="grid gap-2">
<Label htmlFor="email">Email address</Label>
<Input
Expand All @@ -55,7 +57,7 @@ export default function ForgotPassword({ status }: { status?: string }) {

<div className="space-x-1 text-center text-sm text-muted-foreground">
<span>Or, return to</span>
<TextLink href={route('login')}>log in</TextLink>
<TextLink href={login()}>log in</TextLink>
</div>
</div>
</AuthLayout>
Expand Down
15 changes: 9 additions & 6 deletions resources/js/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AuthLayout from '@/layouts/auth-layout';
import { store } from '@/actions/App/Http/Controllers/Auth/AuthenticatedSessionController';
import { register } from '@/routes';
import { request } from '@/routes/password';

type LoginForm = {
email: string;
Expand All @@ -22,15 +25,15 @@ interface LoginProps {
}

export default function Login({ status, canResetPassword }: LoginProps) {
const { data, setData, post, processing, errors, reset } = useForm<Required<LoginForm>>({
const { data, setData, submit, processing, errors, reset } = useForm<Required<LoginForm>>({
email: '',
password: '',
remember: false,
});

const submit: FormEventHandler = (e) => {
const submitForm: FormEventHandler = (e) => {
e.preventDefault();
post(route('login'), {
submit(store(), {
onFinish: () => reset('password'),
});
};
Expand All @@ -39,7 +42,7 @@ export default function Login({ status, canResetPassword }: LoginProps) {
<AuthLayout title="Log in to your account" description="Enter your email and password below to log in">
<Head title="Log in" />

<form className="flex flex-col gap-6" onSubmit={submit}>
<form className="flex flex-col gap-6" onSubmit={submitForm}>
<div className="grid gap-6">
<div className="grid gap-2">
<Label htmlFor="email">Email address</Label>
Expand All @@ -61,7 +64,7 @@ export default function Login({ status, canResetPassword }: LoginProps) {
<div className="flex items-center">
<Label htmlFor="password">Password</Label>
{canResetPassword && (
<TextLink href={route('password.request')} className="ml-auto text-sm" tabIndex={5}>
<TextLink href={request()} className="ml-auto text-sm" tabIndex={5}>
Forgot password?
</TextLink>
)}
Expand Down Expand Up @@ -98,7 +101,7 @@ export default function Login({ status, canResetPassword }: LoginProps) {

<div className="text-center text-sm text-muted-foreground">
Don't have an account?{' '}
<TextLink href={route('register')} tabIndex={5}>
<TextLink href={register()} tabIndex={5}>
Sign up
</TextLink>
</div>
Expand Down
12 changes: 7 additions & 5 deletions resources/js/pages/auth/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AuthLayout from '@/layouts/auth-layout';
import { store } from '@/actions/App/Http/Controllers/Auth/RegisteredUserController';
import { login } from '@/routes';

type RegisterForm = {
name: string;
Expand All @@ -17,24 +19,24 @@ type RegisterForm = {
};

export default function Register() {
const { data, setData, post, processing, errors, reset } = useForm<Required<RegisterForm>>({
const { data, setData, submit, processing, errors, reset } = useForm<Required<RegisterForm>>({
name: '',
email: '',
password: '',
password_confirmation: '',
});

const submit: FormEventHandler = (e) => {
const submitForm: FormEventHandler = (e) => {
e.preventDefault();
post(route('register'), {
submit(store(), {
onFinish: () => reset('password', 'password_confirmation'),
});
};

return (
<AuthLayout title="Create an account" description="Enter your details below to create your account">
<Head title="Register" />
<form className="flex flex-col gap-6" onSubmit={submit}>
<form className="flex flex-col gap-6" onSubmit={submitForm}>
<div className="grid gap-6">
<div className="grid gap-2">
<Label htmlFor="name">Name</Label>
Expand Down Expand Up @@ -109,7 +111,7 @@ export default function Register() {

<div className="text-center text-sm text-muted-foreground">
Already have an account?{' '}
<TextLink href={route('login')} tabIndex={6}>
<TextLink href={login()} tabIndex={6}>
Log in
</TextLink>
</div>
Expand Down
Loading