diff --git a/src/pages/master/postoadms/blocks/AddDialog.tsx b/src/pages/master/postoadms/blocks/AddDialog.tsx index 6dc83d9..75f140e 100644 --- a/src/pages/master/postoadms/blocks/AddDialog.tsx +++ b/src/pages/master/postoadms/blocks/AddDialog.tsx @@ -104,8 +104,8 @@ const AddDialog = () => { }, [formattedTime]); useEffect(() => { - try { - const fetchMunicipios = async (sorting: any) => { + const fetchMunicipios = async (sorting: any) => { + try { sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting; const response = await GetData(`${API_URL}/municipios/list`, { limit: 100, @@ -117,12 +117,12 @@ const AddDialog = () => { console.log(response?.data); setMunicipios(response?.data.list); - }; + } catch (error) { + console.error('Error fetching municipios', error); + } + }; - fetchMunicipios([{ id: 'name', desc: false }]); - } catch (error) { - console.error('Error fetching municipios', error); - } + fetchMunicipios([{ id: 'name', desc: false }]); }, []); return (