feat: increase fetchSucos limit and add doFetchData function

This commit is contained in:
Wikzyy
2025-03-18 10:46:39 +07:00
parent 1cfda6745e
commit e0c064c749
6 changed files with 199 additions and 88 deletions

View File

@ -78,6 +78,24 @@ const AddDialog = () => {
[formField]
);
const doFetchSucos = async (sorting: any) => {
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
const response = await GetData(`${API_URL}/sucos/list`, {
limit: 1000,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('SUCOS', response?.data);
setSucos(response?.data.list);
} catch (error) {
console.error('Error fetching municipios', error);
}
};
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
@ -102,25 +120,7 @@ const AddDialog = () => {
}, [formattedTime]);
useEffect(() => {
const fetchSucos = async (sorting: any) => {
try {
sorting = sorting.length == 0 ? [{ id: 'name', desc: false }] : sorting;
const response = await GetData(`${API_URL}/sucos/list`, {
limit: 100,
page: 1,
with_deleted: false,
order_field: sorting[0].id,
order_direction: sorting[0].desc == false ? 'ASC' : 'DESC'
});
// console.log('SUCOS', response?.data);
setSucos(response?.data.list);
} catch (error) {
console.error('Error fetching municipios', error);
}
};
fetchSucos([{ id: 'name', desc: false }]);
doFetchSucos([{ id: 'name', desc: false }]);
}, []);
useEffect(() => {