-
Notifications
You must be signed in to change notification settings - Fork 531
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
Fix Camera Capture and Upload Workflow #10326
base: develop
Are you sure you want to change the base?
Fix Camera Capture and Upload Workflow #10326
Conversation
WalkthroughThe pull request introduces changes to the camera capture and file upload workflow across multiple components. The modifications enhance the interaction between the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Files/CameraCaptureDialog.tsx (1)
178-178
: Consider using optional chaining.The
onSubmit
callback invocation can be simplified using optional chaining.- onSubmit && onSubmit(); + onSubmit?.();Also applies to: 244-244
🧰 Tools
🪛 Biome (1.9.4)
[error] 178-178: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
src/hooks/useFileUpload.tsx (1)
Line range hint
282-291
: Consider adding error details to the toast message.The error handling could be improved by including more specific error details in the toast message.
- } catch { + } catch (error) { errors.push(file); + const errorMessage = error instanceof Error ? error.message : String(error); + setError(t("file_error__network") + `: ${errorMessage}`); } } setUploading(false); setFiles(errors); setUploadFileNames(errors?.map((f) => f.name) ?? []); - setError(t("file_error__network")); setSubmitClicked(false); setCameraModalOpen(false);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/Files/CameraCaptureDialog.tsx
(3 hunks)src/components/Files/FilesTab.tsx
(2 hunks)src/hooks/useFileUpload.tsx
(7 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Files/CameraCaptureDialog.tsx
[error] 178-178: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 244-244: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (8)
src/components/Files/CameraCaptureDialog.tsx (2)
19-19
: LGTM! Well-typed optional callback.The
onSubmit
callback is properly typed as an optional function.
23-23
: LGTM! Proper destructuring of props.The
onSubmit
callback is properly destructured from props.src/hooks/useFileUpload.tsx (4)
65-65
: LGTM! Well-typed return type.The
submitClicked
state is properly typed as an optional boolean in the return type.
97-97
: LGTM! Proper state initialization.The
submitClicked
state is properly initialized withuseState(false)
.
311-313
: LGTM! Proper state management in onSubmit handler.The
submitClicked
state is properly set totrue
in theonSubmit
handler.
368-368
: LGTM! State properly exposed in return value.The
submitClicked
state is properly exposed in the hook's return value.src/components/Files/FilesTab.tsx (2)
160-169
: LGTM! Proper dialog open condition.The upload dialog open condition properly checks for:
- Files presence
- First file existence
- Submit button click state
592-592
: LGTM! Improved dialog layout.The dialog content layout is improved with:
- Increased vertical spacing
- Maximum height constraint
- Proper overflow handling
@rajku-dev is it ready to be reviewed |
@rajku-dev the normal file upload is not working now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/components/Files/CameraCaptureDialog.tsx (3)
152-154
: Consider using optional chaining for better readability.Replace the logical AND operator with optional chaining:
- togglePreview && togglePreview(); + togglePreview?.();🧰 Tools
🪛 Biome (1.9.4)
[error] 153-153: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
219-221
: Consider using optional chaining for better readability.Replace the logical AND operator with optional chaining:
- togglePreview && togglePreview(); + togglePreview?.();🧰 Tools
🪛 Biome (1.9.4)
[error] 220-220: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
244-246
: Consider using optional chaining for better readability.Replace the logical AND operator with optional chaining:
- togglePreview && togglePreview(); + togglePreview?.();🧰 Tools
🪛 Biome (1.9.4)
[error] 245-245: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/components/Files/CameraCaptureDialog.tsx
(4 hunks)src/components/Files/FilesTab.tsx
(1 hunks)src/hooks/useFileUpload.tsx
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/Files/FilesTab.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Files/CameraCaptureDialog.tsx
[error] 153-153: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 220-220: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 245-245: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (4)
src/components/Files/CameraCaptureDialog.tsx (1)
19-19
: LGTM! Clean interface extension.The addition of the optional
togglePreview
callback maintains backward compatibility while enabling preview state management.Also applies to: 23-23
src/hooks/useFileUpload.tsx (3)
64-64
: LGTM! Clean type extension.The addition of the optional
previewing
property maintains backward compatibility while supporting the preview state management feature.
96-96
: LGTM! Clean state management implementation.The preview state is properly initialized and follows React best practices.
308-308
: LGTM! Clean integration of preview state management.The preview state is properly toggled and exposed through the hook's return value.
Also applies to: 363-363
…thub.com/rajku-dev/care_fe into issue/10312/file-capture-upload-workflow
missed self-testing this one, but handled in the latest changes. |
Yes, I've handled pretty much every edge cases. Could you please test it from your end and let me know if any further changes are required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/Files/CameraCaptureDialog.tsx (2)
153-153
: Use optional chaining for better code style.Replace
setPreview && setPreview(...)
with optional chaining for cleaner code.- setPreview && setPreview(true); + setPreview?.(true); - setPreview && setPreview(false); + setPreview?.(false); - setPreview && setPreview(true); + setPreview?.(true);Also applies to: 169-169, 180-180
🧰 Tools
🪛 Biome (1.9.4)
[error] 153-153: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
222-222
: Use optional chaining for laptop screen button handlers.Similar to mobile screen buttons, use optional chaining for cleaner code.
- setPreview && setPreview(true); + setPreview?.(true); - setPreview && setPreview(false); + setPreview?.(false); - setPreview && setPreview(false); + setPreview?.(false); - setPreview && setPreview(false); + setPreview?.(false);Also applies to: 238-238, 248-248, 264-264
🧰 Tools
🪛 Biome (1.9.4)
[error] 222-222: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Files/CameraCaptureDialog.tsx
(8 hunks)src/hooks/useFileUpload.tsx
(5 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Files/CameraCaptureDialog.tsx
[error] 153-153: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 169-169: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 180-180: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 222-222: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 238-238: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 248-248: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 264-264: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (4)
src/components/Files/CameraCaptureDialog.tsx (1)
19-19
: LGTM! Good addition of the optional preview callback.The optional
setPreview
callback in the props interface maintains backward compatibility while enabling preview state management.src/hooks/useFileUpload.tsx (3)
64-64
: LGTM! Good addition of the preview state to the return type.The optional
previewing
property in FileUploadReturn allows consumers to react to the preview state while maintaining backward compatibility.
96-96
: LGTM! Clean implementation of preview state.The preview state management follows React best practices with appropriate initial state.
290-290
: LGTM! Well-integrated preview state management.The preview state is properly integrated with:
- Camera modal cleanup after upload
- Preview state passed to CameraCaptureDialog
- Preview state exposed to consumers
Also applies to: 308-308, 363-363
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
setPreview
callback in the camera capture dialog for managing preview state.Bug Fixes
Improvements