Skip to content

Commit 583bdac

Browse files
committed
Basic login/logout and register functionalities and design
1 parent b316d37 commit 583bdac

File tree

7 files changed

+124
-199
lines changed

7 files changed

+124
-199
lines changed

app/Http/Controllers/Auth/AuthenticatedSessionController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function store(LoginRequest $request): RedirectResponse
3333

3434
$request->session()->regenerate();
3535

36-
return redirect()->intended(route('dashboard', absolute: false));
36+
return redirect()->intended(route('dashboard.show', absolute: false));
3737
}
3838

3939
/**

app/Http/Controllers/Auth/ConfirmablePasswordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function store(Request $request): RedirectResponse
3636

3737
$request->session()->put('auth.password_confirmed_at', time());
3838

39-
return redirect()->intended(route('dashboard', absolute: false));
39+
return redirect()->intended(route('dashboard.show', absolute: false));
4040
}
4141
}

app/Http/Controllers/Auth/EmailVerificationNotificationController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class EmailVerificationNotificationController extends Controller
1414
public function store(Request $request): RedirectResponse
1515
{
1616
if ($request->user()->hasVerifiedEmail()) {
17-
return redirect()->intended(route('dashboard', absolute: false));
17+
return redirect()->intended(route('dashboard.show', absolute: false));
1818
}
1919

2020
$request->user()->sendEmailVerificationNotification();

resources/js/Pages/Auth/Login.vue

+47-64
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<script setup>
2-
import Checkbox from '@/Components/Checkbox.vue';
3-
import GuestLayout from '@/Layouts/GuestLayout.vue';
4-
import InputError from '@/Components/InputError.vue';
5-
import InputLabel from '@/Components/InputLabel.vue';
6-
import PrimaryButton from '@/Components/PrimaryButton.vue';
7-
import TextInput from '@/Components/TextInput.vue';
82
import { Head, Link, useForm } from '@inertiajs/vue3';
93
104
defineProps({
@@ -30,71 +24,60 @@ const submit = () => {
3024
</script>
3125

3226
<template>
33-
<GuestLayout>
34-
<Head title="Log in" />
27+
<Head title="Iniciar Sesión" />
3528

36-
<div v-if="status" class="mb-4 text-sm font-medium text-green-600">
37-
{{ status }}
38-
</div>
39-
40-
<form @submit.prevent="submit">
41-
<div>
42-
<InputLabel for="email" value="Email" />
43-
44-
<TextInput
45-
id="email"
46-
type="email"
47-
class="mt-1 block w-full"
48-
v-model="form.email"
49-
required
50-
autofocus
51-
autocomplete="username"
52-
/>
29+
<div class="min-h-screen flex items-center justify-center bg-gray-100">
30+
<div class="w-96">
31+
<div class="text-center mb-8">
32+
<h1 class="text-2xl font-bold text-gray-800">Neumatrans</h1>
33+
<p class="text-gray-600 mt-2">Inicia sesión en tu cuenta</p>
34+
</div>
5335

54-
<InputError class="mt-2" :message="form.errors.email" />
36+
<div v-if="status" class="mb-4 p-4 bg-green-100 rounded-lg text-green-700 text-sm">
37+
{{ status }}
5538
</div>
5639

57-
<div class="mt-4">
58-
<InputLabel for="password" value="Password" />
40+
<form @submit.prevent="submit" class="space-y-6">
41+
<div>
42+
<input id="email" type="email" class="w-full px-4 py-2 border border-gray-300 rounded-lg"
43+
v-model="form.email" placeholder="Email" required autofocus />
44+
<div v-if="form.errors.email" class="mt-2 text-sm text-red-600">
45+
{{ form.errors.email }}
46+
</div>
47+
</div>
5948

60-
<TextInput
61-
id="password"
62-
type="password"
63-
class="mt-1 block w-full"
64-
v-model="form.password"
65-
required
66-
autocomplete="current-password"
67-
/>
49+
<div>
50+
<input id="password" type="password" class="w-full px-4 py-2 border border-gray-300 rounded-lg"
51+
v-model="form.password" placeholder="Contraseña" required />
52+
<div v-if="form.errors.password" class="mt-2 text-sm text-red-600">
53+
{{ form.errors.password }}
54+
</div>
55+
</div>
6856

69-
<InputError class="mt-2" :message="form.errors.password" />
70-
</div>
57+
<div class="flex items-center justify-between">
58+
<label class="flex items-center">
59+
<input type="checkbox" class="rounded border-gray-300 text-red-600" v-model="form.remember" />
60+
<span class="ml-2 text-sm text-gray-600">Recordarme</span>
61+
</label>
7162

72-
<div class="mt-4 block">
73-
<label class="flex items-center">
74-
<Checkbox name="remember" v-model:checked="form.remember" />
75-
<span class="ms-2 text-sm text-gray-600"
76-
>Remember me</span
77-
>
78-
</label>
79-
</div>
63+
<Link v-if="canResetPassword" :href="route('password.request')"
64+
class="text-sm text-red-600 hover:text-red-800">
65+
¿Olvidaste tu contraseña?
66+
</Link>
67+
</div>
8068

81-
<div class="mt-4 flex items-center justify-end">
82-
<Link
83-
v-if="canResetPassword"
84-
:href="route('password.request')"
85-
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
86-
>
87-
Forgot your password?
88-
</Link>
69+
<button type="submit"
70+
class="w-full bg-red-600 text-white py-2 px-4 rounded-lg hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
71+
:disabled="form.processing">
72+
{{ form.processing ? 'Iniciando sesión...' : 'Iniciar Sesión' }}
73+
</button>
8974

90-
<PrimaryButton
91-
class="ms-4"
92-
:class="{ 'opacity-25': form.processing }"
93-
:disabled="form.processing"
94-
>
95-
Log in
96-
</PrimaryButton>
97-
</div>
98-
</form>
99-
</GuestLayout>
75+
<div class="text-center mt-4">
76+
<Link :href="route('register')" class="text-sm text-gray-600 hover:text-red-600">
77+
¿No tienes cuenta? Regístrate
78+
</Link>
79+
</div>
80+
</form>
81+
</div>
82+
</div>
10083
</template>

resources/js/Pages/Auth/Register.vue

+51-91
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<script setup>
2-
import GuestLayout from '@/Layouts/GuestLayout.vue';
3-
import InputError from '@/Components/InputError.vue';
4-
import InputLabel from '@/Components/InputLabel.vue';
5-
import PrimaryButton from '@/Components/PrimaryButton.vue';
6-
import TextInput from '@/Components/TextInput.vue';
72
import { Head, Link, useForm } from '@inertiajs/vue3';
83
94
const form = useForm({
@@ -21,93 +16,58 @@ const submit = () => {
2116
</script>
2217

2318
<template>
24-
<GuestLayout>
25-
<Head title="Register" />
19+
<Head title="Registro" />
2620

27-
<form @submit.prevent="submit">
28-
<div>
29-
<InputLabel for="name" value="Name" />
30-
31-
<TextInput
32-
id="name"
33-
type="text"
34-
class="mt-1 block w-full"
35-
v-model="form.name"
36-
required
37-
autofocus
38-
autocomplete="name"
39-
/>
40-
41-
<InputError class="mt-2" :message="form.errors.name" />
42-
</div>
43-
44-
<div class="mt-4">
45-
<InputLabel for="email" value="Email" />
46-
47-
<TextInput
48-
id="email"
49-
type="email"
50-
class="mt-1 block w-full"
51-
v-model="form.email"
52-
required
53-
autocomplete="username"
54-
/>
55-
56-
<InputError class="mt-2" :message="form.errors.email" />
57-
</div>
58-
59-
<div class="mt-4">
60-
<InputLabel for="password" value="Password" />
61-
62-
<TextInput
63-
id="password"
64-
type="password"
65-
class="mt-1 block w-full"
66-
v-model="form.password"
67-
required
68-
autocomplete="new-password"
69-
/>
70-
71-
<InputError class="mt-2" :message="form.errors.password" />
72-
</div>
73-
74-
<div class="mt-4">
75-
<InputLabel
76-
for="password_confirmation"
77-
value="Confirm Password"
78-
/>
79-
80-
<TextInput
81-
id="password_confirmation"
82-
type="password"
83-
class="mt-1 block w-full"
84-
v-model="form.password_confirmation"
85-
required
86-
autocomplete="new-password"
87-
/>
88-
89-
<InputError
90-
class="mt-2"
91-
:message="form.errors.password_confirmation"
92-
/>
21+
<div class="min-h-screen flex items-center justify-center bg-gray-100">
22+
<div class="w-96">
23+
<div class="text-center mb-8">
24+
<h1 class="text-2xl font-bold text-gray-800">Neumatrans</h1>
25+
<p class="text-gray-600 mt-2">Crea tu cuenta</p>
9326
</div>
9427

95-
<div class="mt-4 flex items-center justify-end">
96-
<Link
97-
:href="route('login')"
98-
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
99-
>
100-
Already registered?
101-
</Link>
102-
103-
<PrimaryButton
104-
class="ms-4"
105-
:class="{ 'opacity-25': form.processing }"
106-
:disabled="form.processing"
107-
>
108-
Register
109-
</PrimaryButton>
110-
</div>
111-
</form>
112-
</GuestLayout>
28+
<form @submit.prevent="submit" class="space-y-6">
29+
<div>
30+
<input id="name" type="text" class="w-full px-4 py-2 border border-gray-300 rounded-lg"
31+
v-model="form.name" placeholder="Nombre" required autofocus />
32+
<div v-if="form.errors.name" class="mt-2 text-sm text-red-600">
33+
{{ form.errors.name }}
34+
</div>
35+
</div>
36+
37+
<div>
38+
<input id="email" type="email" class="w-full px-4 py-2 border border-gray-300 rounded-lg"
39+
v-model="form.email" placeholder="Email" required />
40+
<div v-if="form.errors.email" class="mt-2 text-sm text-red-600">
41+
{{ form.errors.email }}
42+
</div>
43+
</div>
44+
45+
<div>
46+
<input id="password" type="password" class="w-full px-4 py-2 border border-gray-300 rounded-lg"
47+
v-model="form.password" placeholder="Contraseña" required />
48+
<div v-if="form.errors.password" class="mt-2 text-sm text-red-600">
49+
{{ form.errors.password }}
50+
</div>
51+
</div>
52+
53+
<div>
54+
<input id="password_confirmation" type="password"
55+
class="w-full px-4 py-2 border border-gray-300 rounded-lg" v-model="form.password_confirmation"
56+
placeholder="Confirmar Contraseña" required />
57+
</div>
58+
59+
<button type="submit"
60+
class="w-full bg-red-600 text-white py-2 px-4 rounded-lg hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
61+
:disabled="form.processing">
62+
{{ form.processing ? 'Registrando...' : 'Registrarse' }}
63+
</button>
64+
65+
<div class="text-center mt-4">
66+
<Link :href="route('login')" class="text-sm text-gray-600 hover:text-red-600">
67+
¿Ya tienes cuenta? Inicia sesión
68+
</Link>
69+
</div>
70+
</form>
71+
</div>
72+
</div>
11373
</template>

resources/js/Pages/Dashboard/Show.vue

+22-35
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,35 @@ const navigateToClients = () => router.get('/clients');
1111
const navigateToVehicles = () => router.get('/vehicles');
1212
const navigateToRepairs = () => router.get('/repairs');
1313
const navigateToDeliveryNotes = () => router.get('/delivery-notes');
14+
15+
const logout = () => {
16+
router.post(route('logout'));
17+
};
1418
</script>
1519

1620
<template>
21+
1722
<Head title="Dashboard" />
18-
23+
1924
<div class="min-h-screen flex flex-col px-4 py-12 sm:px-6 lg:px-8">
2025
<div class="max-w-7xl mx-auto w-full">
21-
<h1 class="text-black text-center text-2xl sm:text-3xl font-bold mb-12">
22-
Bienvenido a <span class="text-red-600">Neumatrans</span>, {{ props.user.name }}
23-
</h1>
24-
26+
<div class="flex justify-between items-center mb-12">
27+
<h1 class="text-black text-2xl sm:text-3xl font-bold">
28+
Bienvenido a <span class="text-red-600">Neumatrans</span>, {{ props.user.name }}
29+
</h1>
30+
<button @click="logout"
31+
class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors">
32+
Cerrar Sesión
33+
</button>
34+
</div>
35+
2536
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
26-
<Tile
27-
title="Clientes"
28-
description="Gestión de clientes"
29-
@click="navigateToClients"
30-
/>
31-
<Tile
32-
title="Vehículos"
33-
description="Gestión de vehículos"
34-
@click="navigateToVehicles"
35-
/>
36-
<Tile
37-
title="Reparaciones"
38-
description="Gestión de reparaciones"
39-
@click="navigateToRepairs"
40-
/>
41-
<Tile
42-
title="Compras"
43-
description="Gestión de compras"
44-
@click="navigateToDeliveryNotes"
45-
/>
46-
<Tile
47-
title="Compras"
48-
description="Gestión de reparaciones"
49-
@click="navigateToDeliveryNotes"
50-
/>
51-
<Tile
52-
title="Compras"
53-
description="Gestión de compras"
54-
@click="navigateToDeliveryNotes"
55-
/>
37+
<Tile title="Clientes" description="Gestión de clientes" @click="navigateToClients" />
38+
<Tile title="Vehículos" description="Gestión de vehículos" @click="navigateToVehicles" />
39+
<Tile title="Reparaciones" description="Gestión de reparaciones" @click="navigateToRepairs" />
40+
<Tile title="Compras" description="Gestión de compras" @click="navigateToDeliveryNotes" />
41+
<Tile title="Compras" description="Gestión de reparaciones" @click="navigateToDeliveryNotes" />
42+
<Tile title="Compras" description="Gestión de compras" @click="navigateToDeliveryNotes" />
5643
</div>
5744
</div>
5845
</div>

routes/web.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
use App\Http\Controllers\DeliveryNoteController;
1212

1313
Route::get('/', function () {
14-
return Inertia::render('Welcome', [
15-
'canLogin' => Route::has('login'),
16-
'canRegister' => Route::has('register'),
17-
'laravelVersion' => Application::VERSION,
18-
'phpVersion' => PHP_VERSION,
19-
]);
14+
return redirect('/login');
2015
});
2116

2217
Route::middleware(['auth', 'verified'])->group(function () {

0 commit comments

Comments
 (0)