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

feat(native-app): Problem and No data UX related component #14828

Merged
merged 6 commits into from
May 21, 2024

Conversation

snaerseljan
Copy link
Contributor

@snaerseljan snaerseljan commented May 16, 2024

Problem and No data UX component

What

This PR adds new Problem component that can be used to display service error, no data or offline connection.

The usage is simple to get a general message

<Problem type="error|info" />

The component will self detect if offline and the default to offline UI.

  • I also added the new Problem to the first page which is the document details screen
  • Then I added a simple but nice translation hook for much nicer translations execution

Why

Generalize errors in app

Screenshots / Gifs

Simulator Screenshot - iPhone 15 Pro Max - 2024-05-16 at 11 28 01
Simulator Screenshot - iPhone 15 Pro Max - 2024-05-16 at 11 38 18
Simulator Screenshot - iPhone 15 Pro Max - 2024-05-16 at 11 39 08
Simulator Screenshot - iPhone 15 Pro Max - 2024-05-16 at 11 39 30

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a Problem component for handling and displaying various problem scenarios such as errors and no data situations.
    • Added a useTranslate hook to simplify translations within the app.
    • Implemented a ProblemTemplate component for customizable problem displays.
  • Enhancements

    • Added new error handling and offline messages to improve user communication during service disruptions.
    • Updated styling in the Document Detail screen to enhance user experience.
  • Bug Fixes

    • Improved consistency in message key casing for better maintainability.

@snaerseljan snaerseljan requested a review from a team as a code owner May 16, 2024 11:46
Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

The recent changes encompass the addition of a new useTranslate hook for streamlining translations, inclusion of various problem-related messages in English and Icelandic, and improvement in error handling within the DocumentDetailScreen by substituting the Typography component with the new Problem component. Furthermore, two new components, ProblemTemplate and Problem, have been developed to standardize the presentation of diverse problem scenarios like errors and no data situations.

Changes

Files Change Summary
.../hooks/use-translate.ts Introduced useTranslate hook to simplify translations using useIntl.
.../messages/en.ts Added new messages for error handling and offline situations.
.../messages/is.ts Added error handling messages and adjusted casing for consistency.
.../screens/document-detail/... Replaced Typography with Problem component and adjusted styling in DocumentDetailScreen.
.../ui/lib/problem/problem-template.tsx Introduced ProblemTemplate component for displaying styled templates for different problem variants.
.../ui/lib/problem/problem.tsx Added Problem component to handle various problem scenarios and display appropriate messages.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]
coderabbitai bot previously requested changes May 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7047e01 and 012cea1.
Files selected for processing (6)
  • apps/native/app/src/hooks/use-translate.ts (1 hunks)
  • apps/native/app/src/messages/en.ts (1 hunks)
  • apps/native/app/src/messages/is.ts (1 hunks)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (2 hunks)
  • apps/native/app/src/ui/lib/problem/problem-template.tsx (1 hunks)
  • apps/native/app/src/ui/lib/problem/problem.tsx (1 hunks)
Files not reviewed due to errors (1)
  • apps/native/app/src/messages/is.ts (no review received)
Files skipped from review due to trivial changes (2)
  • apps/native/app/src/hooks/use-translate.ts
  • apps/native/app/src/messages/en.ts
Additional Context Used
Path-based Instructions (4)
apps/native/app/src/ui/lib/problem/problem.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/native/app/src/ui/lib/problem/problem-template.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/native/app/src/screens/document-detail/document-detail.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/native/app/src/messages/is.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (9)
apps/native/app/src/ui/lib/problem/problem.tsx (2)

1-9: Imports and enum declaration look good.


84-117: Offline handling and switch case logic look good.

apps/native/app/src/ui/lib/problem/problem-template.tsx (4)

1-25: Imports and type declarations look good.


37-66: getColorsByVariant function looks good.


68-105: Styled components look good.


107-137: ProblemTemplate component looks good.

apps/native/app/src/screens/document-detail/document-detail.tsx (3)

Line range hint 1-41: Imports and styled components look good.


Line range hint 43-61: getRightButtons function looks good.


Line range hint 63-101: PdfViewer component looks good.

@datadog-island-is
Copy link

datadog-island-is bot commented May 16, 2024

Datadog Report

All test runs 2be3931 🔗

39 Total Test Services: 0 Failed, 38 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.02%), 2 increased, 143 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 9.88s 1 no change Link
api 0 0 0 4 0 5.44s 1 no change Link
application-api-files 0 0 0 12 0 11.3s 1 no change Link
application-core 0 0 0 90 0 27.35s 1 increased (+0.21%) Link
application-system-api 0 0 0 111 2 3m 35.29s 1 no change Link
application-template-api-modules 0 0 0 109 0 2m 30.05s 1 no change Link
application-templates-accident-notification 0 0 0 95 0 45.7s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 15.45s 1 no change Link
application-templates-driving-license 0 0 0 13 0 31.21s 1 no change Link
application-templates-example-payment 0 0 0 2 0 18.11s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • license-api - jest 34.78% (-0.02%) - Details

Copy link

codecov bot commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.93%. Comparing base (da3b47f) to head (91898c0).
Report is 1 commits behind head on main.

Current head 91898c0 differs from pull request most recent head 0406fe0

Please upload reports for the commit 0406fe0 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #14828      +/-   ##
==========================================
- Coverage   36.97%   36.93%   -0.05%     
==========================================
  Files        6327     6322       -5     
  Lines      128999   128778     -221     
  Branches    36815    36757      -58     
==========================================
- Hits        47700    47558     -142     
+ Misses      81299    81220      -79     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.48% <ø> (ø)
application-api-files 56.55% <ø> (ø)
application-core 71.81% <ø> (+0.34%) ⬆️
application-system-api 41.99% <ø> (+0.02%) ⬆️
application-template-api-modules 24.43% <ø> (+0.06%) ⬆️
application-templates-accident-notification 19.64% <ø> (-0.29%) ⬇️
application-templates-car-recycling 4.23% <ø> (ø)
application-templates-criminal-record 21.67% <ø> (ø)
application-templates-driving-license 16.52% <ø> (ø)
application-templates-estate 11.74% <ø> (ø)
application-templates-example-payment 20.49% <ø> (ø)
application-templates-financial-aid 12.27% <ø> (+0.17%) ⬆️
application-templates-general-petition 19.14% <ø> (ø)
application-templates-health-insurance 23.10% <ø> (ø)
application-templates-inheritance-report 3.96% <ø> (+<0.01%) ⬆️
application-templates-parental-leave 25.18% <ø> (-0.24%) ⬇️
application-types 7.39% <ø> (ø)
application-ui-components 1.44% <ø> (ø)
application-ui-shell 21.72% <ø> (ø)
auth-react 22.95% <ø> (ø)
clients-charge-fjs-v2 22.58% <ø> (ø)
contentful-apps 6.24% <ø> (ø)
financial-aid-backend 56.34% <ø> (ø)
financial-aid-shared 17.51% <ø> (ø)
island-ui-core 29.01% <ø> (ø)
judicial-system-web 28.07% <ø> (-0.01%) ⬇️
license-api 43.20% <ø> (-0.09%) ⬇️
portals-admin-regulations-admin 2.12% <ø> (ø)
portals-core 16.14% <ø> (ø)
services-auth-ids-api 54.78% <ø> (+0.32%) ⬆️
services-auth-personal-representative 49.95% <ø> (+0.22%) ⬆️
services-sessions 65.67% <ø> (ø)
services-user-notification 47.83% <ø> (ø)
services-user-profile 62.85% <ø> (+0.09%) ⬆️
shared-components 27.79% <ø> (ø)
shared-form-fields 31.87% <ø> (ø)
web 1.91% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 86 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dffa964...0406fe0. Read the comment docs.

snaerseljan and others added 2 commits May 16, 2024 14:22
rename to error

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@snaerseljan snaerseljan added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label May 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 012cea1 and 88172b5.
Files selected for processing (1)
  • apps/native/app/src/ui/lib/problem/problem.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/native/app/src/ui/lib/problem/problem.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 88172b5 and 91898c0.
Files selected for processing (3)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (2 hunks)
  • apps/native/app/src/ui/lib/problem/problem-template.tsx (1 hunks)
  • apps/native/app/src/ui/lib/problem/problem.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • apps/native/app/src/screens/document-detail/document-detail.tsx
  • apps/native/app/src/ui/lib/problem/problem-template.tsx
  • apps/native/app/src/ui/lib/problem/problem.tsx

Copy link
Contributor

@thoreyjona thoreyjona left a comment

Choose a reason for hiding this comment

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

Nice 👏

@kodiakhq kodiakhq bot merged commit 9a95a96 into main May 21, 2024
41 checks passed
@kodiakhq kodiakhq bot deleted the feat/native-app-problem branch May 21, 2024 10:17
eirikurn added a commit that referenced this pull request May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants