primer draft de la pagina

This commit is contained in:
fede committed 2026-05-08 21:20:18 -03:00
1 parent 02a6c846dc
commit fcc3952841
42 files changed
+1248

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
<script lang="ts">
import './layout.css';
import 'carbon-components-svelte/css/all.css';
import favicon from '$lib/assets/favicon.svg';
import { getToken } from '$lib/api';
import { goto } from '$app/navigation';
let { children } = $props();
let theme = 'g100'; // "white" | "g10" | "g80" | "g90" | "g100"
let token = $state(getToken());
$effect(() => {
if (!token) {
goto('/login');
}
});
$effect(() => {
document.documentElement.setAttribute('theme', theme);
});
</script>
<svelte:head><link rel="icon" href={favicon} /></svelte:head>
{@render children()}
+49
View File
@@ -0,0 +1,49 @@
<script lang="ts">
import Header from '$lib/components/Header.svelte';
import { Tile } from 'carbon-components-svelte';
</script>
<Header />
<div class="w-full flex-col justify-center p-2!">
<div class="hero">
<h1 class="hero-title">Bienvenido a Repuestera</h1>
<p class="hero-subtitle">Tu tienda de repuestos de confianza</p>
</div>
<div class="flex gap-2">
<Tile class="feature-tile">
<h3>Catálogo completo</h3>
<p>Explorá nuestro amplio catálogo de repuestos para todas las marcas.</p>
</Tile>
<Tile class="feature-tile">
<h3>Envío rápido</h3>
<p>Recibí tus pedidos en tiempo récord con nuestro servicio de envío.</p>
</Tile>
<Tile class="feature-tile">
<h3>Soporte 24/7</h3>
<p>Nuestro equipo está disponible para ayudarte cuando lo necesites.</p>
</Tile>
</div>
</div>
<style>
.hero {
text-align: center;
padding: 6rem 0 4rem;
}
.hero-title {
font-size: 2.5rem;
font-weight: 700;
margin-bottom: 0.75rem;
}
.hero-subtitle {
font-size: 1.25rem;
}
:global(.feature-tile) {
text-align: center;
}
</style>
+1
View File
@@ -0,0 +1 @@
@import 'tailwindcss';
+83
View File
@@ -0,0 +1,83 @@
<script lang="ts">
import {
TextInput,
PasswordInput,
Button,
InlineNotification,
InlineLoading
} from 'carbon-components-svelte';
import Card from '$lib/components/Card.svelte';
import { login as loginApi } from '$lib/api';
import { goto } from '$app/navigation';
let email: string = $state('');
let password: string = $state('');
let loading: boolean = $state(false);
let error: string = $state('');
async function handleLogin() {
if (!email || !password) {
error = 'Por favor completá todos los campos';
return;
}
loading = true;
error = '';
try {
const response = await loginApi({ email, password });
goto('/');
} catch (e) {
error = e instanceof Error ? e.message : 'Error al iniciar sesión';
} finally {
loading = false;
}
}
</script>
<div class="login-container">
<Card title="Iniciar Sesión">
<p class="subtitle">Ingresá tus credenciales para continuar</p>
{#if error}
<InlineNotification kind="error" title="Error" subtitle={error} hideCloseButton />
{/if}
<form
onsubmit={(e) => {
e.preventDefault();
handleLogin();
}}
>
<TextInput bind:value={email} labelText="Email" placeholder="tu@email.com" type="email" />
<PasswordInput bind:value={password} labelText="Contraseña" placeholder="••••••••" />
<Button type="submit" disabled={loading} class="max-w-full!">
{#if loading}
<InlineLoading description="Ingresando..." />
{:else}
Iniciar Sesión
{/if}
</Button>
</form>
<p>
Si no tenés cuenta <a href="/register">registrate</a>
</p>
</Card>
</div>
<style>
.login-container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: var(--cds-ui-background, #161616);
}
form {
display: flex;
flex-direction: column;
gap: 1rem;
}
</style>
+107
View File
@@ -0,0 +1,107 @@
<script lang="ts">
import {
TextInput,
PasswordInput,
Button,
InlineNotification,
InlineLoading
} from 'carbon-components-svelte';
import Card from '$lib/components/Card.svelte';
import { register as registerApi, setToken, setCurrentUser } from '$lib/api';
import { goto } from '$app/navigation';
let name: string = $state('');
let email: string = $state('');
let password: string = $state('');
let confirmPassword: string = $state('');
let loading: boolean = $state(false);
let error: string = $state('');
async function handleRegister() {
if (!name || !email || !password || !confirmPassword) {
error = 'Por favor completá todos los campos';
return;
}
if (password !== confirmPassword) {
error = 'Las contraseñas no coinciden';
return;
}
if (password.length < 6) {
error = 'La contraseña debe tener al menos 6 caracteres';
return;
}
loading = true;
error = '';
try {
const response = await registerApi({ name, email, password });
// setToken(response.token);
// setCurrentUser(response);
goto('/');
} catch (e) {
error = e instanceof Error ? e.message : 'Error al registrar';
} finally {
loading = false;
}
}
</script>
<div class="register-container">
<Card title="Crear Cuenta">
<p class="subtitle">Ingresá tus datos para registrarte</p>
{#if error}
<InlineNotification kind="error" title="Error" subtitle={error} hideCloseButton />
{/if}
<form
onsubmit={(e) => {
e.preventDefault();
handleRegister();
}}
>
<TextInput bind:value={name} labelText="Nombre" placeholder="Tu nombre" />
<TextInput bind:value={email} labelText="Email" placeholder="tu@email.com" type="email" />
<PasswordInput bind:value={password} labelText="Contraseña" placeholder="••••••••" />
<PasswordInput
bind:value={confirmPassword}
labelText="Confirmar Contraseña"
placeholder="••••••••"
/>
<Button type="submit" disabled={loading} class="max-w-full!">
{#if loading}
<InlineLoading description="Registrando..." />
{:else}
Registrarse
{/if}
</Button>
<p>
Si no tenés cuenta <a href="/login">Inicia Sesión</a>
</p>
</form>
</Card>
</div>
<style>
.register-container {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: var(--cds-ui-background, #161616);
}
.subtitle {
color: var(--cds-text-secondary, #c6c6c6);
margin-bottom: 1.5rem;
}
form {
display: flex;
flex-direction: column;
gap: 1rem;
}
</style>