Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin portal delete book #153

Merged
merged 9 commits into from
Mar 25, 2024
Merged

Conversation

NenadJeckovic
Copy link
Contributor

Added delete book functionality to admin books table and tests.

Comment on lines 26 to 28
const deleteBook = async (bookId: number) => {
await bookService.deleteBook(bookId);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method shouldn't belong inside this hook

Comment on lines 79 to 87
{loading ? (
<BooksTableSkeleton />
) : (
<BooksTableBody
books={books}
onDelete={handleDelete}
onEdit={handleEdit}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate PR, if we merge it like this, problems with skeleton would require revert of delete book feature

@@ -0,0 +1,34 @@
import { Skeleton, TableBody, TableCell, TableRow } from "@mui/material";

const BooksTableSkeleton = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a separate PR, if we merge it like this, problems with skeleton would require revert of delete book feature

Comment on lines 42 to 48
<Button
className="edit-button"
data-testid="edit-btn"
onClick={() => onEdit(book.id)}
>
<EditOutlined className="edit-icon" />
</Button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still don't have this feature working, so we shouldn't have edit button

@@ -0,0 +1,4 @@
export const ConfirmationMessages = {
DELETE_BOOK_TITLE: "Delete book",
DELETE_BOOK: "Are you sure you want to delete book?"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea to separate this constants, just give them a more descriptive name

Comment on lines 3 to 4
DELETE_BOOK_TITLE: "Cannot delete book",
DELETE_BOOK: "Book is currently in use"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this "Book is currently in use" if we are showing error message received from back-end?


const modal = await screen.findByTestId("confirmation-modal");

const confirmDeleteButton = await screen.findByText("Delete");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to wait here, modal is already present, we can use getBy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we have test when everything goes OK?

@NenadJeckovic NenadJeckovic merged commit aaeebea into main Mar 25, 2024
@NenadJeckovic NenadJeckovic deleted the feat/146-admin-portal-delete-book branch March 25, 2024 10:28
@NenadJeckovic NenadJeckovic linked an issue Mar 26, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin portal Delete book
2 participants