Skip to content

Conversation

@adamrefaey
Copy link
Collaborator

Change

Refactor action button handlers to manage processing state during report deletion and new uploads

Does this PR introduce a breaking change?

{...}

What needs to be documented once your changes are merged?

{...}

Additional Comments

{...}

@adamrefaey adamrefaey requested a review from Copilot April 30, 2025 17:49
@adamrefaey adamrefaey self-assigned this Apr 30, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the action button handlers to better manage the processing state during report deletion and new uploads. The changes update the signatures of onDiscard and onNewUpload to accept a state callback, remove the local isDeleting state in favor of a unified isProcessing flag, and delegate axios deletion logic to the ReportDetailPage handlers.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
frontend/src/pages/Reports/components/ActionButtons.tsx Refactored props and internal state to centralize processing state handling.
frontend/src/pages/Reports/ReportDetailPage.tsx Updated action handler functions to incorporate processing state updates with axios deletion logic.

@adamrefaey adamrefaey requested a review from Copilot April 30, 2025 17:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the action button handlers for report deletion and new uploads to manage a unified processing state.

  • Updated the ActionButtons component to use a single processing indicator instead of separate deletion state.
  • Modified the handler functions in ReportDetailPage to propagate and manage processing state through async operations.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/src/pages/Reports/components/ActionButtons.tsx Removed redundant imports and state; updated prop types to use processing state; simplified the async handlers.
frontend/src/pages/Reports/ReportDetailPage.tsx Updated the handler functions to set processing state appropriately; removed the conditional branch for report deletion when uploading a new report.

@adamrefaey adamrefaey requested a review from Copilot April 30, 2025 17:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the action button handlers to better manage the processing state during report deletion and new uploads. Key changes include updating function signatures for onDiscard and onNewUpload to accept a state-setting callback, consolidating the processing state in place of a separate deletion flag, and modifying the handleNewUpload behavior in the report detail page.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/src/pages/Reports/components/ActionButtons.tsx Removed redundant deletion state and updated handler signatures to use a unified processing state
frontend/src/pages/Reports/ReportDetailPage.tsx Updated handleDiscard and handleNewUpload to use the processing state; handleNewUpload now always attempts to delete a report before navigating to upload
Comments suppressed due to low confidence (1)

frontend/src/pages/Reports/ReportDetailPage.tsx:121

  • [nitpick] The function name 'handleNewUpload' might be misleading since it performs a deletion before navigating to the new upload page. Consider renaming it to better reflect its dual responsibility.
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {

@GuidoBR GuidoBR merged commit 154e3ee into main Apr 30, 2025
1 check passed
@adamrefaey adamrefaey deleted the ADE-67 branch April 30, 2025 19:23

const handleNewUpload = () => {
history.push('/tabs/upload');
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what does this method do?


// Handle action buttons
const handleDiscard = async () => {
const handleDiscard = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

✅ Change applied: Added a finally block to handleDiscard to ensure isProcessing is always reset, even if the API call fails. This improves reliability and user experience. Thank you for the suggestion!


const handleNewUpload = () => {
history.push('/tabs/upload');
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

✅ Change applied: Added a check for reportId in handleNewUpload to prevent unintended API calls and provide user feedback if reportId is missing. This makes the code more robust. Thanks for the suggestion!


const handleNewUpload = () => {
history.push('/tabs/upload');
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

✅ Change applied: Now, handleNewUpload checks if reportId is defined before attempting deletion, and provides a toast error if not. This prevents unintended API calls and improves user feedback. Thanks for the suggestion!


const handleNewUpload = () => {
history.push('/tabs/upload');
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

✅ Change applied: handleNewUpload now checks for reportId before deleting and shows an error if it's missing. This avoids unintended behavior. Thanks for the suggestion!


const handleNewUpload = () => {
history.push('/tabs/upload');
const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This method (handleNewUpload) deletes the current report (if a valid reportId exists) and then opens the upload modal so the user can upload a new report. This ensures that only one report is active at a time, and helps keep the user's report archive clean.

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.

3 participants