feat: add validation, delete confirmation, and loading states to Library#12
Open
codeCraft-Ritik wants to merge 1 commit into
Open
feat: add validation, delete confirmation, and loading states to Library#12codeCraft-Ritik wants to merge 1 commit into
codeCraft-Ritik wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To provide a professional contribution to the repository, you should include a clear and structured description of your changes. This is typically used in the Pull Request (PR) description or the Git commit message.
Pull Request Title
feat: improve library management with validation, safety, and loading states
Pull Request Description
Overview This PR enhances the Library management module by improving the user experience, fixing state management bugs, and adding safety checks to prevent accidental data loss.
Changes Implemented
Client-Side Search Validation: Added logic to the handleSubmit function to trim whitespace and prevent empty search queries from being sent to the API.
Delete Confirmation Dialog: Implemented a standard window.confirm browser dialog in the handleDelete function to ensure users verify a deletion before the record is removed from the database.
Loading State Indicators: Integrated a React-Bootstrap Spinner component that displays while book data is being fetched, providing visual feedback to the user during asynchronous operations.
State Management Bug Fix: Replaced the direct state mutation of the books array (previously using _.remove) with a functional .filter() approach to ensure React correctly detects state changes and re-renders the UI.
UI/UX Enhancements: Added cursor: pointer styles to interactive elements like column headers and the trash icon to improve discoverability and accessibility.
Error Handling: Added try...catch blocks around asynchronous fetch requests to handle API failures gracefully and log them to the console.