fix/conceptos-agente-aduanal-bugs-filtros-y-modal
This commit is contained in:
@@ -36,11 +36,22 @@ export async function getCustomsBrokerConcepts(
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {},
|
||||
): Promise<ApiResponse<CustomsBrokerConceptListResponse>> {
|
||||
const cleanFilters = Object.fromEntries(
|
||||
Object.entries(filters).filter(([, value]) => {
|
||||
if (value === undefined || value === null) return false;
|
||||
if (typeof value === 'string') {
|
||||
const trimmed = value.trim();
|
||||
return trimmed !== '' && trimmed.toLowerCase() !== 'undefined';
|
||||
}
|
||||
return true;
|
||||
})
|
||||
);
|
||||
|
||||
const params = new URLSearchParams({
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
company_id: companyId.toString(),
|
||||
...cleanFilters
|
||||
});
|
||||
|
||||
return await api.get(`/v1/a76/customs-broker-concepts/?${params.toString()}`);
|
||||
|
||||
@@ -47,8 +47,20 @@
|
||||
let showBrokerSelector = $state(false);
|
||||
let selectedBrokerLabel = $state('');
|
||||
|
||||
// Cargar datos al editar
|
||||
function resetForm() {
|
||||
formData = {
|
||||
broker_key: '',
|
||||
concept: '',
|
||||
amount: undefined,
|
||||
priority: undefined
|
||||
};
|
||||
selectedBrokerLabel = '';
|
||||
}
|
||||
|
||||
// Cargar o limpiar datos al abrir el modal
|
||||
$effect(() => {
|
||||
if (!open) return;
|
||||
|
||||
if (item) {
|
||||
formData = {
|
||||
broker_key: item.broker_key || '',
|
||||
@@ -58,14 +70,10 @@
|
||||
};
|
||||
selectedBrokerLabel = item.broker_key || '';
|
||||
} else {
|
||||
formData = {
|
||||
broker_key: '',
|
||||
concept: '',
|
||||
amount: undefined,
|
||||
priority: undefined
|
||||
};
|
||||
selectedBrokerLabel = '';
|
||||
resetForm();
|
||||
}
|
||||
|
||||
error = null;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
@@ -135,7 +143,10 @@
|
||||
</script>
|
||||
|
||||
<Dialog.Root bind:open>
|
||||
<Dialog.Content class="max-w-lg max-h-[90vh] overflow-y-auto">
|
||||
<Dialog.Content
|
||||
class="max-w-lg max-h-[90vh] overflow-y-auto"
|
||||
onInteractOutside={(e) => e.preventDefault()}
|
||||
>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{title}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
|
||||
Reference in New Issue
Block a user