-
Notifications
You must be signed in to change notification settings - Fork 0
[ADE-67] Refactor action button handlers to manage processing state during report deletion and new uploads #131
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
Changes from all commits
052bcfe
da8d316
bbe9406
d2eab3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,9 +86,11 @@ const ReportDetailPage: React.FC = () => { | |
| }; | ||
|
|
||
| // Handle action buttons | ||
| const handleDiscard = async () => { | ||
| const handleDiscard = async (setIsProcessing: (isProcessing: boolean) => void) => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Change applied: Added a |
||
| try { | ||
| setIsProcessing(true); | ||
| await axios.delete(`${API_URL}/api/reports/${reportId}`, await getAuthConfig()); | ||
| setIsProcessing(false); | ||
|
|
||
| // Show toast notification | ||
| createToast({ | ||
|
|
@@ -102,6 +104,8 @@ const ReportDetailPage: React.FC = () => { | |
| // Navigate back | ||
| history.push('/tabs/home'); | ||
| } catch (error) { | ||
| setIsProcessing(false); | ||
|
|
||
| console.error('Error discarding report:', error); | ||
| createToast({ | ||
| message: t('report.discard.error', { | ||
|
|
@@ -114,8 +118,17 @@ const ReportDetailPage: React.FC = () => { | |
| } | ||
| }; | ||
|
|
||
| const handleNewUpload = () => { | ||
| history.push('/tabs/upload'); | ||
| const handleNewUpload = async (setIsProcessing: (isProcessing: boolean) => void) => { | ||
adamrefaey marked this conversation as resolved.
Show resolved
Hide resolved
adamrefaey marked this conversation as resolved.
Show resolved
Hide resolved
adamrefaey marked this conversation as resolved.
Show resolved
Hide resolved
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this method do?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Change applied: Added a check for
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Change applied: Now,
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ Change applied:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method ( |
||
| try { | ||
| setIsProcessing(true); | ||
| await axios.delete(`${API_URL}/api/reports/${reportId}`, await getAuthConfig()); | ||
| setIsProcessing(false); | ||
|
|
||
| history.push('/tabs/upload'); | ||
| } catch (error) { | ||
| setIsProcessing(false); | ||
| console.error('Error deleting report before new upload:', error); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
|
|
@@ -142,8 +155,7 @@ const ReportDetailPage: React.FC = () => { | |
| <ActionButtons | ||
| onDiscard={handleDiscard} | ||
| onNewUpload={handleNewUpload} | ||
| reportTitle={reportData.title || reportData.category} | ||
| reportId={reportId} | ||
| reportTitle={reportData.title} | ||
| /> | ||
| </IonContent> | ||
| </IonPage> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.