@@ -88,6 +89,8 @@
handleArrowScroll(event, globalList)}
@@ -124,6 +127,8 @@
{:else}
handleArrowScroll(event, localList)}
diff --git a/frontend/src/lib/components/sidebar/nav-main.svelte b/frontend/src/lib/components/sidebar/nav-main.svelte
index e21cdf95..ff5a24f7 100644
--- a/frontend/src/lib/components/sidebar/nav-main.svelte
+++ b/frontend/src/lib/components/sidebar/nav-main.svelte
@@ -101,7 +101,7 @@
{#if item.icon}
{:else}
-
+
{/if}
{item.title}
@@ -127,7 +127,7 @@
{#if item.icon}
{:else}
-
+
{/if}
diff --git a/frontend/src/lib/components/ui/select/select-content.svelte b/frontend/src/lib/components/ui/select/select-content.svelte
index 8293adf1..9bed7978 100644
--- a/frontend/src/lib/components/ui/select/select-content.svelte
+++ b/frontend/src/lib/components/ui/select/select-content.svelte
@@ -85,7 +85,6 @@
bind:this={searchInputRef}
value={searchQuery}
placeholder={searchPlaceholder}
- autofocus={autoFocusSearch}
class="placeholder:text-muted-foreground flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm outline-none focus:border-ring focus:ring-1 focus:ring-ring"
oninput={(event) => updateQuery((event.currentTarget as HTMLInputElement).value)}
onclick={(e) => e.stopPropagation()}
diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.server.ts b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.server.ts
new file mode 100644
index 00000000..0e4e1801
--- /dev/null
+++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.server.ts
@@ -0,0 +1,55 @@
+import type { PageServerLoad } from './$types';
+import { error, redirect } from '@sveltejs/kit';
+import { getAuthTokens, getActiveCompanyId, authenticatedFetch } from '$lib/server/api';
+
+export const load: PageServerLoad = async ({ params, cookies, fetch }) => {
+ const { accessToken } = getAuthTokens(cookies);
+
+ if (!accessToken) {
+ throw redirect(302, '/login');
+ }
+
+ const companyId = await getActiveCompanyId(cookies, fetch);
+ if (!companyId) {
+ throw error(400, 'No se encontró una compañía seleccionada');
+ }
+
+ let agentsCount = 0;
+ let clientsCount = 0;
+
+ try {
+ const [brokersRes, clientsRes] = await Promise.all([
+ authenticatedFetch(
+ `v1/a76/customs-brokers?company_id=${companyId}&page=1&page_size=1`,
+ {},
+ cookies,
+ fetch
+ ),
+ authenticatedFetch(
+ `v1/a76/clients-providers?company_id=${companyId}&page=1&page_size=1`,
+ {},
+ cookies,
+ fetch
+ )
+ ]);
+
+ if (brokersRes.ok) {
+ const brokersData = await brokersRes.json();
+ agentsCount = brokersData.total ?? 0;
+ }
+ if (clientsRes.ok) {
+ const clientsData = await clientsRes.json();
+ clientsCount = clientsData.total ?? 0;
+ }
+ } catch (e) {
+ console.error('Error fetching prerequisites count for parts:', e);
+ }
+
+ const isCreate = params.id === 'new' || params.id === undefined;
+
+ return {
+ agentsCount,
+ clientsCount,
+ isCreate
+ };
+};
diff --git a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
index 72633d4c..d87c3f3d 100644
--- a/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
+++ b/frontend/src/routes/dashboard/goods/parts/edit/[[id]]/+page.svelte
@@ -1,9 +1,36 @@
+{#if data?.isCreate}
+
(showPrerequisitesModal = false)}
+ onCancel={() => goto('/dashboard/goods/parts')}
+ />
+{/if}
+
\ No newline at end of file
diff --git a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte
index df9e4fec..2eb4bbd9 100644
--- a/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte
+++ b/frontend/src/routes/dashboard/invoices/edit/[id]/+page.svelte
@@ -39,6 +39,7 @@
import { useShortcuts } from '$lib/hooks/use-shortcuts';
import { obtenerAtajosEdicionFactura } from '$lib/config/shortcuts/dashboard/invoices/edit';
import { api } from '$lib/api';
+ import PrerequisitesModal from '$lib/components/dashboard/PrerequisitesModal.svelte';
// Cargar companyStore solo en el cliente - no usamos sidebar en esta página
let companyStore: any = $state(undefined);
@@ -793,6 +794,19 @@
manejarRegresar: handleBack
})
);
+
+ // Prerrequisitos: modal cuando no hay agentes o clientes
+ const agentsCount = $derived(data.customsBrokers?.length ?? 0);
+ const clientsCount = $derived(data.clients?.length ?? 0);
+ let showPrerequisitesModal = $state(false);
+ let hasTriedToShowPrerequisitesModal = $state(false);
+ $effect(() => {
+ if (hasTriedToShowPrerequisitesModal) return;
+ if (agentsCount === 0 || clientsCount === 0) {
+ hasTriedToShowPrerequisitesModal = true;
+ showPrerequisitesModal = true;
+ }
+ });
@@ -1042,3 +1056,11 @@
+
+