diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 9c9d05ce..4ede1db0 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -77,6 +77,7 @@ public function share(Request $request): array ...$data, 'name' => config('app.name'), 'version' => config('app.version'), + 'demo' => config('app.demo'), 'quote' => ['message' => trim($message), 'author' => trim($author)], 'auth' => [ 'user' => $user, diff --git a/resources/js/pages/auth/login.tsx b/resources/js/pages/auth/login.tsx index 0a3b9cb0..d629d7c8 100644 --- a/resources/js/pages/auth/login.tsx +++ b/resources/js/pages/auth/login.tsx @@ -1,4 +1,4 @@ -import { Head, useForm } from '@inertiajs/react'; +import { Head, useForm, usePage } from '@inertiajs/react'; import { LoaderCircle } from 'lucide-react'; import { FormEventHandler } from 'react'; @@ -9,6 +9,7 @@ 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 { SharedData } from '@/types'; type LoginForm = { email: string; @@ -22,9 +23,11 @@ interface LoginProps { } export default function Login({ status, canResetPassword }: LoginProps) { + const page = usePage(); + const { data, setData, post, processing, errors, reset } = useForm>({ - email: '', - password: '', + email: page.props.demo ? 'demo@vitodeploy.com' : '', + password: page.props.demo ? 'password' : '', remember: false, }); diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 672fd851..b8bc6948 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -105,6 +105,7 @@ export interface Configs { export interface SharedData { name: string; version: string; + demo: boolean; quote: { message: string; author: string }; auth: Auth; ziggy: Config & { location: string };