Private
Public Access
progreso con la landing page
This commit is contained in:
1 parent
ad0612c4d8
commit
ea29c7d3f0
9 files changed
+648
-77
No files matched your search
@@ -1,80 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { getCurrentUser, ObtenerGruposDeUsuario } from '$lib/api';
|
||||
import CardError from '$lib/components/CardError.svelte';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import {
|
||||
Accordion,
|
||||
AccordionItem,
|
||||
ContainedList,
|
||||
ContainedListItem
|
||||
} from 'carbon-components-svelte';
|
||||
import LandingPage from '$lib/components/LandingPage.svelte';
|
||||
|
||||
let usuario = getCurrentUser();
|
||||
|
||||
let grupos = usuario ? ObtenerGruposDeUsuario(usuario) : undefined;
|
||||
</script>
|
||||
|
||||
<Header {usuario} {grupos} />
|
||||
|
||||
<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 w-full justify-center gap-2">
|
||||
<div class="w-[75%]">
|
||||
{#await grupos}
|
||||
<Accordion skeleton></Accordion>
|
||||
{:then gg}
|
||||
{#if gg == undefined}{:else}
|
||||
<Accordion>
|
||||
{#each gg.groups as g}
|
||||
<AccordionItem title={g.nombre}>
|
||||
{#if g.permisos?.length == 0}
|
||||
<p class="text-neutral-500">No hay permisos en este grupo</p>
|
||||
{:else}
|
||||
<ContainedList>
|
||||
{#each g.permisos as p}
|
||||
<ContainedListItem on:click={() => goto(p.alias)}>
|
||||
<span class="cursor-pointer">
|
||||
{p.nombre}
|
||||
</span>
|
||||
</ContainedListItem>
|
||||
{/each}
|
||||
</ContainedList>
|
||||
{/if}
|
||||
</AccordionItem>
|
||||
{/each}
|
||||
</Accordion>
|
||||
{/if}
|
||||
{:catch err}
|
||||
<CardError>
|
||||
{err}
|
||||
</CardError>
|
||||
{/await}
|
||||
</div>
|
||||
</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>
|
||||
<LandingPage {usuario} />
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { resolve } from '$app/paths';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import type { Grupo } from '../../../types';
|
||||
import {
|
||||
@@ -35,7 +36,7 @@
|
||||
{#if data.grupo.permisos && data.grupo.permisos.length > 0}
|
||||
<ContainedList>
|
||||
{#each data.grupo.permisos as p (p.id)}
|
||||
<ContainedListItem on:click={() => goto(p.alias)}>
|
||||
<ContainedListItem on:click={() => goto('/' + p.alias)}>
|
||||
<div class="permiso-item">
|
||||
<span>{p.nombre}</span>
|
||||
<Tag type="blue">{p.alias}</Tag>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
try {
|
||||
const response = await loginApi({ email, password });
|
||||
goto('/');
|
||||
goto('/menu');
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : 'Error al iniciar sesión';
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { getCurrentUser, ObtenerGruposDeUsuario } from '$lib/api';
|
||||
import CardError from '$lib/components/CardError.svelte';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import {
|
||||
Accordion,
|
||||
AccordionItem,
|
||||
ContainedList,
|
||||
ContainedListItem
|
||||
} from 'carbon-components-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
let usuario = getCurrentUser();
|
||||
|
||||
onMount(() => {
|
||||
if (!usuario) goto('/login');
|
||||
});
|
||||
|
||||
let grupos = usuario ? ObtenerGruposDeUsuario(usuario) : undefined;
|
||||
</script>
|
||||
|
||||
<Header {usuario} {grupos} />
|
||||
|
||||
<main>
|
||||
<section class="dashboard-section">
|
||||
<div class="dashboard-header">
|
||||
<h2 class="section-title">Tu panel de control</h2>
|
||||
<p class="section-subtitle">Accede a los módulos de tu cuenta</p>
|
||||
</div>
|
||||
{#await grupos}
|
||||
<Accordion skeleton />
|
||||
{:then gg}
|
||||
{#if gg == undefined}
|
||||
<p class="text-neutral-500 text-center py-8">No tienes grupos asignados</p>
|
||||
{:else}
|
||||
<Accordion>
|
||||
{#each gg.groups as g}
|
||||
<AccordionItem title={g.nombre}>
|
||||
{#if g.permisos?.length == 0}
|
||||
<p class="text-neutral-500">No hay permisos en este grupo</p>
|
||||
{:else}
|
||||
<ContainedList>
|
||||
{#each g.permisos as p}
|
||||
<ContainedListItem on:click={() => goto(p.alias)}>
|
||||
<span class="cursor-pointer">{p.nombre}</span>
|
||||
</ContainedListItem>
|
||||
{/each}
|
||||
</ContainedList>
|
||||
{/if}
|
||||
</AccordionItem>
|
||||
{/each}
|
||||
</Accordion>
|
||||
{/if}
|
||||
{:catch err}
|
||||
<CardError>{err}</CardError>
|
||||
{/await}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
.section-title {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
font-size: 1.05rem;
|
||||
color: var(--cds-text-secondary, #c6c6c6);
|
||||
text-align: center;
|
||||
max-width: 520px;
|
||||
margin: 0 auto 3rem;
|
||||
}
|
||||
|
||||
.dashboard-section {
|
||||
padding: 5rem 1rem;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.dashboard-header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.dashboard-section :global(.bx--accordion) {
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -40,7 +40,7 @@
|
||||
const response = await registerApi({ name, email, password });
|
||||
// setToken(response.token);
|
||||
// setCurrentUser(response);
|
||||
goto('/');
|
||||
goto('/menu');
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : 'Error al registrar';
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user