update refresh, add data, navigasi all master
This commit is contained in:
@ -86,7 +86,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => row.sucos_id,
|
||||
accessorKey: 'sucos_id',
|
||||
id: 'id',
|
||||
header: ({ column }) => <DataGridColumnHeader title="ID" column={column} />,
|
||||
enableSorting: true,
|
||||
@ -168,52 +168,6 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
||||
}
|
||||
};
|
||||
|
||||
const getAldeiasBySucos = async (name: string) => {
|
||||
try {
|
||||
const response = await axios.get(`${API_URL}/sucos/aldeias/${name}`);
|
||||
const data = response.data;
|
||||
console.log(data);
|
||||
} catch (error) {
|
||||
console.log(`Error fetching sucos by ${name}`, error);
|
||||
}
|
||||
};
|
||||
|
||||
const createSucos = async (data: Partial<SucosProps>) => {
|
||||
try {
|
||||
await axios.post(`${API_URL}/sucos/create`, data);
|
||||
// getMunicipiosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error creating municipios', error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateSucos = async (id: number, data: Partial<SucosProps>) => {
|
||||
try {
|
||||
await axios.put(`${API_URL}/sucos/update/${id}`, data);
|
||||
// getSucosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error updating sucos', error);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteSucos = async (id: number, hardDelete?: boolean) => {
|
||||
try {
|
||||
await axios.delete(`${API_URL}/sucos/delete/${id}/${hardDelete}`);
|
||||
// getSucosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error deleting sucos', error);
|
||||
}
|
||||
};
|
||||
|
||||
const restoreSucos = async (id: number) => {
|
||||
try {
|
||||
await axios.put(`${API_URL}/sucos/restore/${id}`);
|
||||
// getSucosLists(10, 1, false, 'name', 'ASC');
|
||||
} catch (error) {
|
||||
console.error('Error restoring sucos', error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ManageSucosContext.Provider
|
||||
value={{
|
||||
@ -234,7 +188,7 @@ const ManageSucosContextProvider = ({ children }: { children: React.ReactNode })
|
||||
|
||||
<DataGridProvider
|
||||
columns={columns}
|
||||
pagination={{ size: 25 }}
|
||||
pagination={{ size: 10 }}
|
||||
toolbar={<ListToolbar />}
|
||||
layout={{ card: true }}
|
||||
sorting={[{ id: 'id', desc: false }]}
|
||||
|
||||
Reference in New Issue
Block a user