fix filter table
This commit is contained in:
@ -160,73 +160,27 @@ const ManageMunicipiosProvider = ({ children }: { children: React.ReactNode }) =
|
||||
try {
|
||||
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||
filter = filter.length == 0 ? {} : { any: filter[0].value?.toLowerCase() };
|
||||
const response = await axios.get(`${API_URL}/municipios/list`, {
|
||||
params: {
|
||||
limit: limit,
|
||||
page: page + 1,
|
||||
with_deleted: false,
|
||||
order_field: sorting[0].id,
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
|
||||
}
|
||||
const response = await GetData(`${API_URL}/municipios/list`, {
|
||||
limit,
|
||||
page: page + 1,
|
||||
with_deleted: false,
|
||||
order_field: sorting[0].id,
|
||||
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC',
|
||||
filter: JSON.stringify(filter)
|
||||
});
|
||||
// console.log(response.data);
|
||||
// console.log(response?.data);
|
||||
// const sortedList = response.data.data.list.sort((a: MunicipiosProps, b: MunicipiosProps) => {
|
||||
// if (a.name < b.name) return -1;
|
||||
// if (a.name > b.name) return 1;
|
||||
// return 0;
|
||||
// });
|
||||
setMunicipios(response.data.data.list);
|
||||
return { data: response?.data.data.list, totalCount: response?.data.data.total_count };
|
||||
setMunicipios(response?.data.list);
|
||||
return { data: response?.data.list, totalCount: response?.data.total_count };
|
||||
} catch (error) {
|
||||
console.error('Error fetching municipios', error);
|
||||
}
|
||||
};
|
||||
|
||||
const getPostoadmsByMunicipio = async (name: string) => {
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/municipios/postoadms/${name}`);
|
||||
const data = response.data;
|
||||
console.log(data);
|
||||
} catch (error) {
|
||||
console.error(`Error fetching municipios by ${name}`, error);
|
||||
}
|
||||
};
|
||||
|
||||
const createMunicipios = async (data: Partial<MunicipiosProps>) => {
|
||||
try {
|
||||
await axios.post(`${API_URL}/municipios/create`, data);
|
||||
// getMunicipiosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error creating municipios', error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateMunicipios = async (id: number, data: Partial<MunicipiosProps>) => {
|
||||
try {
|
||||
await axios.put(`${API_URL}/update/${id}`, data);
|
||||
// getMunicipiosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error updating municipios', error);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMunicipios = async (id: number, hardDelete?: boolean) => {
|
||||
try {
|
||||
await axios.delete(`${API_URL}/delete/${id}/${hardDelete}`);
|
||||
// getMunicipiosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error deleting municipios', error);
|
||||
}
|
||||
};
|
||||
|
||||
const restoreMunicipios = async (id: number) => {
|
||||
try {
|
||||
await axios.put(`${API_URL}/restore/${id}`);
|
||||
// getMunicipiosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error restoring municipios', error);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<ManageMunicipiosContext.Provider
|
||||
value={{
|
||||
|
||||
Reference in New Issue
Block a user