Skip to content

Commit 8b761ed

Browse files
committed
feat(core): adds employees page in demo project
1 parent 1476f9f commit 8b761ed

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

apps/react-kit-demo/src/app/all-books/AllBooks.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { Grid, Paper } from '@mui/material';
22
import { DataGrid, GridCellParams, GridColDef } from '@mui/x-data-grid';
3-
import React from 'react';
3+
import { useEffect, useState } from 'react';
44
import { Link } from 'react-router-dom';
55
import { BookService } from '../../services/BookService';
66
import { Book } from '../../types/Book';
77

88
export default function AllBooks() {
9-
const [data, setData] = React.useState<Book[]>([]);
9+
const [data, setData] = useState<Book[]>([]);
10+
const [loading, setLoading] = useState<boolean>(true);
1011

11-
React.useEffect(() => {
12-
BookService.getAllBooks().then((response) => setData(response));
12+
useEffect(() => {
13+
setLoading(true);
14+
BookService.getAllBooks()
15+
.then((response) => {
16+
setData(response);
17+
setLoading(false);
18+
})
19+
.catch((error) => {
20+
console.error(error);
21+
setLoading(false);
22+
});
1323
}, []);
1424

1525
return (
@@ -24,6 +34,7 @@ export default function AllBooks() {
2434
pageSizeOptions={[5, 10, 20, 50, 100]}
2535
disableRowSelectionOnClick={true}
2636
density={'comfortable'}
37+
loading={loading}
2738
rows={data ?? []}
2839
columns={columns}
2940
autoHeight={true}

0 commit comments

Comments
 (0)