Skip to content

Commit

Permalink
fix error datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
karenyov committed Apr 12, 2023
1 parent b318ecf commit 529d67b
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/pages/category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
AlertDialogBody,
AlertDialogFooter,
useColorMode,
Tag,
IconButton as IconButtonBase,
} from "@chakra-ui/react";

Expand Down Expand Up @@ -116,13 +117,14 @@ export default function Category() {
}

const columns = [
{
name: "Id",
selector: (row: any) => row.categoryId,
},
{
name: "Descrição",
selector: (row: any) => row.description,
width: "80%",
selector: (row: any) => (
<Tag size="md" variant="solid" borderRadius="full" bg="primary.700">
{row.description}
</Tag>
),
},
{
name: "Ações",
Expand Down Expand Up @@ -190,7 +192,7 @@ export default function Category() {
});

onCloseConfirm();
loadCategories();
loadCategories(registerBase.registerId);
}
} catch (error: any) {
toast({
Expand All @@ -201,10 +203,10 @@ export default function Category() {
}
}

async function loadCategories() {
async function loadCategories(registerId: number) {
setIsLoading(true);
try {
const res = await listAllCategory(registerBase.registerId);
const res = await listAllCategory(registerId);
if (res.data) {
setCategories(res.data as CategoryDTO[]);
}
Expand Down Expand Up @@ -246,7 +248,7 @@ export default function Category() {

reset();
onCloseFormModal();
loadCategories();
loadCategories(registerBase.registerId);
} else {
toast({
title: res.data.message,
Expand All @@ -264,16 +266,20 @@ export default function Category() {
}

useEffect(() => {
reset(category);
if (registerBase.registerId) {
loadCategories(registerBase.registerId);
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [category]);
}, [registerBase.registerId]);

useEffect(() => {
loadCategories();
reset(category);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}, [category]);



return (
<Layout>
Expand Down

0 comments on commit 529d67b

Please sign in to comment.