-
{#if isMenuOpen}
(isMenuOpen = false)} />
{/if}
diff --git a/frontend-client/src/lib/routes-registry.ts b/frontend-client/src/lib/routes-registry.ts
new file mode 100644
index 0000000..6e3ffc1
--- /dev/null
+++ b/frontend-client/src/lib/routes-registry.ts
@@ -0,0 +1,11 @@
+export interface RouteDefinition {
+ key: string;
+ label: string;
+ path: string;
+}
+
+export const CLIENT_ROUTES: RouteDefinition[] = [
+ { key: 'nav:tickets', label: 'Mis Tickets', path: '/tickets' },
+ { key: 'nav:organization', label: 'Organización', path: '/organization' },
+ { key: 'nav:usuarios', label: 'Usuarios', path: '/usuarios' },
+]
\ No newline at end of file
diff --git a/frontend-client/src/lib/stores/app.ts b/frontend-client/src/lib/stores/app.ts
index 7e70a94..de10a88 100644
--- a/frontend-client/src/lib/stores/app.ts
+++ b/frontend-client/src/lib/stores/app.ts
@@ -1,7 +1,6 @@
-import { writable } from 'svelte/store';
-import { auth } from './auth.js';
-import { get } from 'svelte/store';
import type { Writable } from 'svelte/store';
+import { get, writable } from 'svelte/store';
+import { auth } from './auth.js';
// Types
export interface Category {
@@ -60,15 +59,15 @@ function createAppStore() {
// Load categories
loadCategories: async () => {
update(state => ({ ...state, isLoading: true, error: null }));
-
+
try {
const categories = await apiCall('/categories/');
update(state => ({ ...state, categories, isLoading: false }));
} catch (error) {
- update(state => ({
- ...state,
- isLoading: false,
- error: error instanceof Error ? error.message : 'Failed to load categories'
+ update(state => ({
+ ...state,
+ isLoading: false,
+ error: error instanceof Error ? error.message : 'Failed to load categories'
}));
}
},
diff --git a/frontend-client/src/lib/stores/navPermissions.ts b/frontend-client/src/lib/stores/navPermissions.ts
new file mode 100644
index 0000000..114376e
--- /dev/null
+++ b/frontend-client/src/lib/stores/navPermissions.ts
@@ -0,0 +1,36 @@
+import { auth } from '$lib/stores/auth';
+import { get, writable } from 'svelte/store';
+
+function createNavPermissionsStore() {
+ const { subscribe, set } = writable>({});
+
+ return {
+ subscribe,
+ load: async () => {
+ try {
+ const authState = get(auth);
+ const slug = authState.user?.tenant_slug || authState.user?.tenant_id || '';
+ const headers: Record = {
+ 'X-App': 'client',
+ 'X-Tenant-Slug': slug,
+ };
+ if (authState.token) {
+ headers['Authorization'] = `Bearer ${authState.token}`;
+ }
+ const res = await fetch('/api/v1/permissions/my', {
+ credentials: 'include',
+ headers
+ });
+ if (res.ok) {
+ const perms = await res.json();
+ set(perms);
+ }
+ } catch (e) {
+ set({});
+ }
+ },
+ clear: () => set({})
+ };
+}
+
+export const navPerms = createNavPermissionsStore();
\ No newline at end of file
diff --git a/frontend-client/src/routes/organization/+page.svelte b/frontend-client/src/routes/organization/+page.svelte
index a49c749..32fe90c 100644
--- a/frontend-client/src/routes/organization/+page.svelte
+++ b/frontend-client/src/routes/organization/+page.svelte
@@ -1,8 +1,8 @@