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): Subpoena functionality in inbox in app #16213

Merged
merged 26 commits into from
Oct 11, 2024

Conversation

thoreyjona
Copy link
Contributor

@thoreyjona thoreyjona commented Sep 30, 2024

What

Add tag to inbox documents that have the flag isUrgent set to true. Also if they have a prop called confirmation. Then we send includeDocument: false to the server when opening the document-detail screen that does not include the content of the document.
We then show a modal with information from the confirmation prop that the user needs to agree to to be able to open the document.
If the user chooses to open the document we fetch the content, show an alert (if present from server) that appropriate organization has been notified of that the user has seen the document and show action buttons if present in the payload.
Currently only supporting two kinds of buttons from actions, with type: 'file' and type: 'url'.

Why

Mirroring functionality to be added to mínar síður regarding law and order.

TODO

Screenshots / Gifs

RPReplay_Final1727705682.MP4

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 urgency indicators for documents in the inbox and document detail screens.
    • Added new queries for fetching document categories and senders, along with a mutation to mark all documents as read.
    • Enhanced document sharing functionality with improved alerts and confirmation handling.
    • New localization keys for urgent documents and direct document access.
    • Updated InboxCard and PressableListItem to handle urgency status.
    • Introduced a new Label component for urgent list items with internationalization support.
    • Enhanced Header component to display optional labels.
  • Bug Fixes

    • Improved handling of document urgency and confirmation status in the inbox and document detail screens.
  • Documentation

    • Updated localization files to include new keys for enhanced user experience.

@thoreyjona thoreyjona requested a review from a team as a code owner September 30, 2024 14:30
Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes introduce enhancements to the GraphQL schema, specifically the ListDocument fragment, by adding new fields related to document urgency and actions. Several new queries and mutations are introduced, including the ability to mark all documents as read and retrieve document categories and senders. The localization files are updated to support these new features, and various components in the application are modified to accommodate the new urgency and confirmation properties, improving the overall document handling and user interface.

Changes

File Path Change Summary
apps/native/app/src/graphql/fragments/document.fragment.graphql Added new fields (isUrgent, actions, alert, confirmation) to the ListDocument fragment in the GraphQL schema.
apps/native/app/src/graphql/queries/inbox.graphql Introduced new mutation (MarkAllDocumentsAsRead) and query (GetDocumentsCategoriesAndSenders), modified GetDocument to include a $locale parameter.
apps/native/app/src/messages/en.ts Added new localization keys for urgent documents and opening documents.
apps/native/app/src/messages/is.ts Added new localization keys for urgent documents and opening documents in the is language file.
apps/native/app/src/screens/document-detail/document-detail.tsx Enhanced DocumentDetailScreen to include isUrgent and confirmation, added confirmation handling and improved sharing functionality.
apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx Introduced a utility function to generate action buttons based on document actions.
apps/native/app/src/screens/finance/finance.tsx Renamed icon import from externalOpen to externalLink.
apps/native/app/src/screens/home/inbox-module.tsx Updated InboxCard to include isUrgent property for document urgency display.
apps/native/app/src/screens/inbox/inbox.tsx Modified InboxScreen to include urgency and confirmation properties in document handling.
apps/native/app/src/ui/lib/alert/alert.tsx Updated Alert component styling and structure for better consistency.
apps/native/app/src/ui/lib/card/inbox-card.tsx Updated InboxCardProps interface to include isUrgent, defaulting to false.
apps/native/app/src/ui/lib/detail/header.tsx Added optional label prop to Header component and adjusted layout.
apps/native/app/src/ui/lib/label/label.tsx Updated Label component to include blackTextColor prop and refactored related functions.
apps/native/app/src/ui/lib/list/list-item.tsx Added urgent property to ListItemProps interface and updated rendering logic for urgency.

Possibly related PRs

Suggested reviewers

  • unakb
  • eirikurn
  • thorkellmani

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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: 11

🧹 Outside diff range and nitpick comments (15)
apps/native/app/src/ui/lib/link/link.tsx (1)

26-26: LGTM: Typography component integrated correctly

The replacement of the styled Text component with the Typography component is well-implemented. This change enhances consistency in text styling across the application.

Consider passing any necessary styling props to the Typography component to maintain the link's visual distinctiveness. For example:

<Typography variant="link">{children}</Typography>

This assumes that the Typography component accepts a variant prop for different text styles.

apps/native/app/src/graphql/queries/inbox.graphql (1)

36-37: LGTM: Added localization support to GetDocument query

The addition of the $locale parameter to the GetDocument query is a good improvement, allowing for localized document retrieval. This change aligns with the goal of supporting internationalization in the application.

Consider adding a default value for the $locale parameter to ensure consistent behavior when it's not provided. For example:

-query GetDocument($input: DocumentInput!, $locale: String) {
+query GetDocument($input: DocumentInput!, $locale: String = "en") {
   documentV2(input: $input, locale: $locale) {
     ...ListDocument
     content {
       type
       value
     }
   }
 }

This ensures a fallback locale is always used, maintaining consistent behavior across the application.

apps/native/app/src/screens/document-detail/utils/shareFile.tsx (1)

23-25: Consider adding a comment explaining the Android-specific behavior.

While the code itself is clear, the purpose of setting noLockScreenUntilNextAppStateActive for Android devices is not immediately obvious. Adding a brief comment explaining why this is necessary would improve code maintainability.

Consider adding a comment like this:

// Prevent screen lock on Android while sharing is in progress
if (isAndroid) {
  authStore.setState({ noLockScreenUntilNextAppStateActive: true })
}
apps/native/app/src/ui/lib/card/inbox-card.tsx (2)

16-16: LGTM! Consider adding JSDoc comment for clarity.

The addition of the isUrgent property to the InboxCardProps interface is well-implemented and aligns with the PR objectives. It correctly uses TypeScript to define the property type as boolean | null.

Consider adding a JSDoc comment to explain the purpose of this property:

/** Indicates whether the inbox item is urgent and requires immediate attention */
isUrgent?: boolean | null

50-50: LGTM! Consider simplifying the boolean conversion.

The addition of the urgent prop to the ListItem component is well-implemented, correctly propagating the urgency state. The use of !!isUrgent ensures a boolean value is passed.

For slightly improved readability, you could simplify the boolean conversion:

urgent={Boolean(isUrgent)}

This achieves the same result but may be more immediately clear to other developers.

apps/native/app/src/ui/lib/detail/header.tsx (2)

65-65: LGTM: New optional prop added to HeaderProps.

The addition of the optional label prop to the HeaderProps interface is a good improvement, extending the component's functionality while maintaining backward compatibility.

Consider updating the component's documentation or comments to explain the purpose and usage of this new label prop.


Line range hint 75-121: LGTM: Improved Header component with new label feature.

The changes to the Header component are well-implemented:

  • Default value for label ensures backward compatibility.
  • New Row component improves layout structure.
  • Conditional rendering for message and label is correct.
  • Label component is used appropriately.

These changes align with React and TypeScript best practices.

Consider extracting the message rendering logic into a separate component or function to improve readability and maintainability. For example:

const MessageContent = ({ message, isLoading }: { message?: string; isLoading?: boolean }) => {
  if (!message) return null;
  if (isLoading) return <Skeleton active style={{ borderRadius: 4 }} height={32} />;
  return (
    <Typography style={{ fontWeight: '600' }}>
      {message}
    </Typography>
  );
};

// Then in the render method:
<Row>
  <MessageContent message={message} isLoading={isLoading} />
  {label && (
    <Label color="danger" icon blackTextColor>
      {label}
    </Label>
  )}
</Row>

This refactoring would make the main component more concise and easier to understand.

apps/native/app/src/screens/home/inbox-module.tsx (3)

132-132: LGTM! Consider adding type definition for item.

The addition of the isUrgent property to InboxCard is correct and aligns with the PR objectives. Good job on implementing this feature.

To improve type safety, consider defining an interface for the item object. For example:

interface InboxItem {
  id: string;
  subject: string;
  publicationDate: string;
  opened: boolean;
  bookmarked: boolean;
  sender: {
    name: string;
  };
  isUrgent: boolean;
}

Then, you can use this type in your map function:

documents.map((item: InboxItem, index) => (
  // ... existing code
))

This will provide better type checking and autocompletion for the item properties.


136-136: LGTM! Consider adding type checking for navigation parameters.

The addition of isUrgent to the navigation parameters is correct and aligns with the PR objectives. Good implementation of this feature.

To improve type safety and maintain consistency across the application, consider defining a type for the navigation parameters. For example:

interface InboxItemNavigationParams {
  title: string;
  isUrgent: boolean;
}

Then, update the navigateTo function call:

navigateTo<InboxItemNavigationParams>(`/inbox/${item.id}`, {
  title: item.sender.name,
  isUrgent: item.isUrgent,
})

This will ensure type checking for the navigation parameters and improve the overall type safety of the application.


Line range hint 1-143: Overall implementation looks good. Consider consistent naming for boolean props.

The changes successfully implement the urgency feature as described in the PR objectives. The code maintains good structure and follows React and NextJS best practices. Great job on keeping the changes minimal and focused!

For consistency in naming boolean props, consider renaming unread to isUnread in the InboxCard component:

 <InboxCard
   key={item.id}
   subject={item.subject}
   publicationDate={item.publicationDate}
   id={`${item.id}-${index}`}
-  unread={!item.opened}
+  isUnread={!item.opened}
   bookmarked={item.bookmarked}
   senderName={item.sender.name}
   icon={item.sender.name && getOrganizationLogoUrl(item.sender.name, 75)}
   isUrgent={item.isUrgent}
   onPress={() => /* ... */}
 />

This change would make the prop naming more consistent with isUrgent and follow a common convention for boolean props in React.

apps/native/app/src/ui/lib/list/list-item.tsx (1)

142-146: LGTM: Urgent label rendering logic implemented correctly.

The conditional rendering of the urgent label with appropriate styling and internationalized text is well-implemented. It aligns with the PR objectives and maintains the component's structure.

Consider adding an accessibilityLabel prop to the Label component for better screen reader support. For example:

 <Label color="danger" icon blackTextColor>
   {intl.formatMessage({ id: 'inbox.urgent' })}
 </Label>
+  accessibilityLabel={intl.formatMessage({ id: 'inbox.urgent.accessibility' })}

Don't forget to add the corresponding entry in the localization files.

apps/native/app/src/ui/lib/alert/alert.tsx (2)

Line range hint 46-54: Approve darkBackgroundColor function with a suggestion

The darkBackgroundColor function is a good addition for handling specific color adjustments in dark mode. It enhances theme consistency and improves user experience.

However, consider improving type safety:

Replace any with a more specific type for the colors parameter. For example:

const darkBackgroundColor = (color: string, colors: Record<string, string>) => {
  // ... existing implementation
}

This change will provide better type checking and improve code maintainability.


194-198: Approve Typography usage with a suggestion for Image styles

The use of Typography components with specific variants for the title and message is a good improvement. It enhances consistency in text rendering and leverages the Typography system effectively.

However, consider refactoring the inline styles for the Image component:

Move the inline styles to a styled component for better consistency and maintainability. For example:

const IconImage = styled(Image)`
  width: 32px;
  height: 32px;
  margin-right: 16px;
`

// Then in the render method:
<IconImage source={variant.icon} />

This change will keep the styling consistent with the rest of the component and improve readability.

Also applies to: 205-206

apps/native/app/src/messages/en.ts (1)

216-217: LGTM! Consider adding a period for consistency.

The new translations for 'inbox.urgent' and 'inbox.openDocument' are clear and align well with the PR objectives. They support the new feature for tagging urgent documents and providing a way to open documents.

For consistency with other translations in the file, consider adding a period at the end of each phrase:

-  'inbox.urgent': 'Urgent',
-  'inbox.openDocument': 'Open document',
+  'inbox.urgent': 'Urgent.',
+  'inbox.openDocument': 'Open document.',

This would match the style of similar short phrases in the file, such as 'inbox.loadingText': 'Searching...'.

apps/native/app/src/messages/is.ts (1)

Line range hint 1-217: Overall file structure and content look good.

The file is well-organized and follows consistent naming conventions. The new additions fit seamlessly into the existing structure. For future consideration, it might be beneficial to group related translations (e.g., all inbox-related translations) together to improve maintainability as the file grows.

Consider grouping related translations together in the future. For example:

export const is = {
  // ... other translations

  // Inbox-related translations
  'inbox.screenTitle': 'Pósthólf',
  'inbox.bottomTabText': 'Pósthólf',
  'inbox.searchPlaceholder': 'Leita...',
  'inbox.urgent': 'Áríðandi',
  'inbox.openDocument': 'Opna erindi',
  // ... other inbox-related translations

  // ... other translations
}

This grouping could make it easier to locate and maintain related translations as the file grows.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between efbef76 and c48ef68.

⛔ Files ignored due to path filters (12)
  • apps/native/app/src/assets/icons/download.png is excluded by !**/*.png
  • apps/native/app/src/assets/icons/download@2x.png is excluded by !**/*.png
  • apps/native/app/src/assets/icons/download@3x.png is excluded by !**/*.png
  • apps/native/app/src/assets/icons/external-open.png is excluded by !**/*.png
  • apps/native/app/src/assets/icons/external-open@2x.png is excluded by !**/*.png
  • apps/native/app/src/assets/icons/external-open@3x.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/alert/danger.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/alert/danger@2x.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/alert/danger@3x.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/card/danger.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/card/danger@2x.png is excluded by !**/*.png
  • apps/native/app/src/ui/assets/card/danger@3x.png is excluded by !**/*.png
📒 Files selected for processing (16)
  • apps/native/app/src/graphql/fragments/document.fragment.graphql (1 hunks)
  • apps/native/app/src/graphql/queries/inbox.graphql (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 (9 hunks)
  • apps/native/app/src/screens/document-detail/utils/getButtonsForActions.tsx (1 hunks)
  • apps/native/app/src/screens/document-detail/utils/shareFile.tsx (1 hunks)
  • apps/native/app/src/screens/finance/finance.tsx (2 hunks)
  • apps/native/app/src/screens/home/inbox-module.tsx (1 hunks)
  • apps/native/app/src/screens/inbox/inbox.tsx (1 hunks)
  • apps/native/app/src/ui/lib/alert/alert.tsx (3 hunks)
  • apps/native/app/src/ui/lib/card/inbox-card.tsx (3 hunks)
  • apps/native/app/src/ui/lib/detail/header.tsx (5 hunks)
  • apps/native/app/src/ui/lib/label/label.tsx (6 hunks)
  • apps/native/app/src/ui/lib/link/link.tsx (2 hunks)
  • apps/native/app/src/ui/lib/list/list-item.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (16)
apps/native/app/src/graphql/fragments/document.fragment.graphql (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/graphql/queries/inbox.graphql (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/en.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."
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."
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/screens/document-detail/utils/getButtonsForActions.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/utils/shareFile.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/finance/finance.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/home/inbox-module.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/inbox/inbox.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/alert/alert.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/card/inbox-card.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/detail/header.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/label/label.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/link/link.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/list/list-item.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."
🔇 Additional comments (34)
apps/native/app/src/ui/lib/link/link.tsx (2)

4-4: LGTM: Typography import added correctly

The import of the Typography component is correctly implemented, following TypeScript and React best practices. This change supports the transition to a more consistent text styling approach across the application.


Line range hint 1-29: Overall implementation aligns with NextJS and React best practices

The changes in this file adhere to NextJS best practices and make good use of TypeScript for type safety. The Link component is well-structured, and the integration of the Typography component improves UI consistency.

Some notable points:

  1. The file structure follows NextJS conventions.
  2. TypeScript is used effectively for prop typing.
  3. React hooks (useCallback) are used appropriately for performance optimization.
  4. The component's functionality remains intact while improving text styling consistency.
apps/native/app/src/graphql/queries/inbox.graphql (2)

Line range hint 24-32: LGTM: New query for document categories and senders

The GetDocumentsCategoriesAndSenders query is a well-structured addition that aligns with the PR objectives. It efficiently retrieves the necessary data for document categories and senders, supporting the new tagging system for inbox documents.


Line range hint 1-53: Overall changes align well with PR objectives

The modifications to this GraphQL file are consistent with the PR objectives and the AI-generated summary. The new MarkAllDocumentsAsRead mutation and GetDocumentsCategoriesAndSenders query, along with the localization support added to the GetDocument query, contribute to the enhanced inbox functionality described in the PR summary.

These changes support:

  1. The new tagging system for inbox documents
  2. Improved document handling
  3. Localization capabilities

The file structure and naming conventions adhere to GraphQL and NextJS best practices, ensuring maintainability and readability of the code.

apps/native/app/src/screens/document-detail/utils/shareFile.tsx (5)

1-5: LGTM: Imports are well-organized and relevant.

The imports are correctly structured and include all necessary dependencies for the shareFile function. The use of separate utilities for device detection and the import of GraphQL types demonstrate good code organization and type safety practices.


7-11: LGTM: Well-defined interface using TypeScript.

The ShareFileProps interface is correctly defined, making good use of TypeScript for type safety. The optional pdfUrl property aligns well with the function's ability to handle documents both with and without PDFs.


14-21: LGTM: Robust input validation.

The input validation is thorough and follows best practices by checking for required properties and returning early if the input is invalid. This helps prevent runtime errors and improves the function's reliability.


27-33: LGTM: Sharing logic is well-implemented.

The sharing logic using Share.open is well-structured and correctly handles both PDF and non-PDF cases. The use of optional chaining for document.downloadUrl is a good practice to prevent potential runtime errors.


1-34: Overall, excellent implementation of the shareFile utility.

The shareFile function is well-implemented, aligning with the PR objectives of enhancing document handling in the inbox. It effectively uses TypeScript for type safety, follows React Native best practices, and handles different scenarios (PDF vs. non-PDF) appropriately. The code is clean, well-structured, and includes proper error handling.

Minor suggestions for improvement:

  1. Consider adding a brief comment explaining the Android-specific behavior.
  2. If not present elsewhere, consider adding JSDoc comments to describe the function's purpose and parameters.

Great job on this implementation!

apps/native/app/src/ui/lib/card/inbox-card.tsx (2)

30-30: LGTM! Good use of default value.

The addition of the isUrgent parameter with a default value of false is well-implemented. This ensures that the component always has a defined urgency state, even if the prop is not explicitly provided.


Line range hint 1-54: Overall assessment: Well-implemented feature addition.

The changes to the InboxCard component successfully introduce the urgency feature as outlined in the PR objectives. The implementation maintains good TypeScript practices, ensuring type safety throughout. The component's structure and use of props align well with React and NextJS best practices.

Key points:

  1. Proper TypeScript usage in the InboxCardProps interface.
  2. Consistent implementation of the isUrgent property in the component.
  3. Correct propagation of the urgency state to child components.

The changes do not introduce any apparent issues related to NextJS-specific concerns, maintaining the component's compatibility with server-side rendering and static generation methods.

apps/native/app/src/ui/lib/detail/header.tsx (3)

7-7: LGTM: New import statement is correctly placed.

The import of the Label component from the @ui package is appropriately placed at the top of the file, following best practices for import organization.


10-10: Verify the visual impact of reduced padding.

The change from theme.spacing[2] to theme.spacing[1] for padding-bottom is valid. However, please ensure this reduction in padding doesn't negatively impact the overall layout and appearance of the header.


47-47: LGTM: Improved vertical alignment in Row component.

Adding align-items: center to the Row styled component is a good improvement. It ensures consistent vertical alignment of items within the row, enhancing the overall layout.

apps/native/app/src/ui/lib/list/list-item.tsx (3)

1-1: LGTM: Import statements are correctly updated.

The new imports for Label and useIntl are appropriate for the added urgent label feature and internationalization support.

Also applies to: 3-3


89-89: LGTM: ListItemProps interface updated correctly.

The addition of the optional urgent property to the ListItemProps interface is appropriate for the new urgency tagging feature described in the PR objectives.


100-103: LGTM: ListItem function parameters and hooks updated appropriately.

The addition of the urgent parameter with a default value of false is consistent with the interface update. The use of the useIntl hook is correct for internationalizing the urgent label text.

apps/native/app/src/ui/lib/alert/alert.tsx (3)

18-18: Good addition of Typography component

The import of the Typography component is a positive change. It promotes consistency in text styling across the application and aligns with NextJS best practices for component reusability.


108-110: Approve Title component update

The change from Text to Typography for the Title component is a good improvement. It ensures consistency in text rendering across the application and leverages the newly imported Typography component effectively.


Line range hint 1-231: Overall approval with minor suggestions

The changes to the Alert component are well-implemented and align with NextJS best practices. The introduction of the Typography component and the improvements in theme handling enhance the component's flexibility and consistency.

Key improvements:

  1. Consistent text rendering using Typography
  2. Enhanced dark mode color handling
  3. Improved structure for title and message rendering

The TypeScript usage is generally good, with room for minor improvements in type safety for the darkBackgroundColor function.

These changes will positively impact the maintainability and consistency of the application's UI. The suggestions provided earlier (improving type safety and refactoring inline styles) are minor and do not detract from the overall quality of the implementation.

apps/native/app/src/screens/finance/finance.tsx (3)

165-165: LGTM! Consistent icon usage.

The update of the 'icon' prop in the LightButton component to use 'externalLink' is consistent with the import statement change. This modification maintains the component's functionality while improving code clarity.


Line range hint 1-194: Overall, the changes improve code clarity while maintaining functionality.

The modifications to the icon import and usage enhance code readability without affecting the core functionality of the FinanceScreen component. The code continues to adhere to NextJS best practices, efficiently uses TypeScript for type safety, and maintains proper state management. No issues with server-side rendering techniques are apparent.


6-6: LGTM! Verify icon usage throughout the file.

The import statement change from 'externalOpen' to 'externalLink' is an improvement in naming convention and clarity. This change aligns with the AI-generated summary.

To ensure consistency, please verify that all occurrences of this icon in the file have been updated. You can use the following command to check:

✅ Verification successful

Verified! All instances of externalOpen have been successfully updated to externalLink in the file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

rg "externalOpen" apps/native/app/src/screens/finance/finance.tsx

Length of output: 65

apps/native/app/src/messages/is.ts (1)

216-217: New inbox-related translations added successfully.

The new translations for 'urgent' and 'open document' are consistent with the PR objectives and follow the existing naming conventions. These additions will support the new subpoena functionality in the inbox.

apps/native/app/src/graphql/fragments/document.fragment.graphql (4)

12-17: Ensure the actions field structure matches the GraphQL schema

The actions field introduces an object that contains action-related data for documents. Confirm that the actions field and its subfields (type, title, icon, data) are properly defined and typed in the DocumentV2 type.

To verify the actions field definition, run:

#!/bin/bash
# Description: Verify the 'actions' field and its subfields in 'DocumentV2' type.

# Test: Search for 'actions' field in DocumentV2. Expect: Field with correct subfields should be present.
rg --type graphql 'type DocumentV2.*{[^}]*actions' -A 20

18-21: Addition of alert field to handle document alerts

The alert field adds the capability to display alerts associated with documents. Ensure that the alert field and its subfields (title, data) are correctly defined in the schema and that they match the expected types.

You can confirm the alert field definition by executing:

#!/bin/bash
# Description: Verify that 'alert' field is defined in 'DocumentV2' type.

# Test: Search for 'alert' field in DocumentV2. Expect: Field with 'title' and 'data' subfields.
rg --type graphql 'type DocumentV2.*{[^}]*alert' -A 20

22-26: Ensure the confirmation field is properly defined

The confirmation field is crucial for displaying confirmation prompts before accessing urgent documents. Verify that the confirmation field and its subfields (title, data, icon) are properly defined in the DocumentV2 type and that they adhere to the expected data types.

To verify the confirmation field, run:

#!/bin/bash
# Description: Check 'confirmation' field in 'DocumentV2' type.

# Test: Search for 'confirmation' field in DocumentV2. Expect: Field with 'title', 'data', and 'icon' subfields.
rg --type graphql 'type DocumentV2.*{[^}]*confirmation' -A 20

11-11: Addition of isUrgent field to ListDocument fragment

The inclusion of the isUrgent field aligns with the PR objectives to tag and identify urgent documents within the inbox. Ensure that the isUrgent field is correctly defined in the DocumentV2 type in the GraphQL schema.

You can verify that isUrgent is defined in the DocumentV2 type by running:

apps/native/app/src/ui/lib/label/label.tsx (2)

89-92: LGTM: Updated LabelText styled component with blackTextColor prop

The LabelText styled component now accepts the blackTextColor prop, enhancing its styling flexibility. The implementation is correct and adheres to best practices.


Line range hint 96-122: LGTM: Enhanced Label component with blackTextColor prop

The addition of the blackTextColor prop to the Label component is well-implemented. Setting a default value of false and correctly passing the prop to LabelText ensures backward compatibility and proper functionality.

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

1-1: Verify the use of experimental Apollo Client hook

The import of useFragment_experimental from @apollo/client indicates the use of an experimental API. Using experimental features may introduce instability in the application due to potential changes in future releases. Please ensure that this hook is necessary and acceptable for your production environment.


420-425: Handle potential undefined message in Alert component

When rendering the Alert component, the message prop may receive an undefined value if Document.alert?.title is undefined. Ensure that the Alert component can handle an undefined message prop without causing errors.


Line range hint 1-293: Ensure compliance with coding guidelines for React Native

The provided coding guidelines mention NextJS best practices, which may not be directly applicable to a React Native application. However, it's important to ensure that:

  • State management is efficient and follows React Native best practices.
  • TypeScript is used optimally for component and utility type safety.

Please review the code to confirm adherence to these practices.

apps/native/app/src/screens/inbox/inbox.tsx (1)

128-128: LGTM!

The isUrgent prop is correctly passed to the InboxCard component.

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: 1

🧹 Outside diff range and nitpick comments (1)
apps/native/app/src/screens/document-detail/document-detail.tsx (1)

418-441: Good implementation of alerts and action buttons

The conditional rendering of alerts and action buttons is well-implemented. The use of the ActionsWrapper component and the getButtonsForActions function improves code organization and reusability.

The logic for displaying alerts and actions is clear and follows good practices.

Consider extracting the condition for showing the ActionsWrapper into a variable for improved readability:

const shouldShowActionsWrapper = showConfirmedAlert || (hasActions && !hasConfirmation);

return (
  <>
    <Host>
      {/* ... */}
    </Host>
    {shouldShowActionsWrapper && (
      <ActionsWrapper>
        {/* ... */}
      </ActionsWrapper>
    )}
    <Border />
    <View
      style={{
        flex: 1,
        marginHorizontal: theme.spacing[2],
        marginTop: shouldShowActionsWrapper ? theme.spacing[2] : 0,
      }}
    >
      {/* ... */}
    </View>
  </>
);

This small change can make the code slightly more readable and maintainable.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c48ef68 and 9cfe090.

📒 Files selected for processing (1)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (9 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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."
🔇 Additional comments (3)
apps/native/app/src/screens/document-detail/document-detail.tsx (3)

Line range hint 314-338: Good job on refactoring the share functionality

The introduction of the onShare function and its usage in the navigation button press handler is a good improvement. It encapsulates the sharing logic and makes the code more modular and easier to maintain.

This refactoring enhances code organization and reusability. Keep up the good work!


415-417: Good addition of urgent label to Header

The addition of the label prop to the Header component, which displays an "urgent" label when isUrgent is true, is a good feature. It provides important information to the user about the document's priority.

This change enhances the user interface by clearly indicating urgent documents. Well done!


55-59: ⚠️ Potential issue

Fix invalid style properties in ActionsWrapper component

The ActionsWrapper styled component uses incorrect style properties:

  1. margin-horizontal is not a valid React Native style property. Use marginHorizontal instead.
  2. gap is not supported in React Native's View components.

Please update the component as follows:

const ActionsWrapper = styled.View`
  margin-bottom: ${({ theme }) => theme.spacing[2]}px;
- margin-horizontal: ${({ theme }) => theme.spacing[2]}px;
+ marginHorizontal: ${({ theme }) => theme.spacing[2]}px;
- gap: ${({ theme }) => theme.spacing[2]}px;
`

To achieve spacing between child elements, consider using marginBottom on child components or a flexDirection: 'column' layout with justifyContent: 'space-between'.

Likely invalid or redundant comment.

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

🧹 Outside diff range and nitpick comments (2)
apps/native/app/src/screens/document-detail/utils/share-file.tsx (1)

27-34: Good sharing implementation, but consider adding error handling.

The Share.open call is well-constructed, with appropriate use of document properties and conditional logic for PDF handling. The use of optional chaining for document.downloadUrl is also good practice.

Consider wrapping the Share.open call in a try-catch block to handle potential errors:

try {
  await Share.open({
    title: document.subject,
    subject: document.subject,
    message: `${document.sender.name} \n ${document.subject}`,
    type: hasPdf ? 'application/pdf' : undefined,
    url: hasPdf ? `file://${pdfUrl}` : document.downloadUrl!,
  });
} catch (error) {
  console.error('Error sharing file:', error);
  // Handle the error appropriately, e.g., show a user-friendly message
}

This will improve the robustness of the function and provide better error handling.

apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx (1)

81-85: LGTM: Good filtering and responsive layout

The final button filtering and rendering logic is well-implemented. Filtering out non-React elements ensures that only valid components are rendered, and the use of the Host component with conditional max-width provides a responsive layout.

For a minor performance optimization, consider memoizing the filtered buttons if this component is likely to re-render frequently:

import React, { useMemo } from 'react'

// ...

const filteredButtons = useMemo(() => buttons.filter((b) => isValidElement(b)), [buttons])

This change would prevent unnecessary re-filtering of buttons on each render, potentially improving performance in scenarios with frequent updates.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9cfe090 and aae4acc.

📒 Files selected for processing (3)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (9 hunks)
  • apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx (1 hunks)
  • apps/native/app/src/screens/document-detail/utils/share-file.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/native/app/src/screens/document-detail/document-detail.tsx
🧰 Additional context used
📓 Path-based instructions (2)
apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.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/utils/share-file.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."
🔇 Additional comments (4)
apps/native/app/src/screens/document-detail/utils/share-file.tsx (3)

1-11: Imports and type definitions look good.

The imports are appropriate for the functionality, and the ShareFileProps interface provides good type safety for the function parameters. This aligns well with the coding guidelines for optimal use of TypeScript.


13-21: Good use of guard clause for input validation.

The function starts with a comprehensive check for the validity of the input, which is a good practice. It ensures that all required properties are present and handles the conditional case for pdfUrl when hasPdf is true. This robust error handling aligns well with best practices.


1-34: Overall good implementation with room for improvement

The shareFile utility function is well-implemented, adhering to TypeScript best practices and providing good type safety. It effectively handles document sharing for both PDF and non-PDF cases.

Main points for improvement:

  1. Address the security implications of disabling the lock screen on Android.
  2. Implement error handling for the Share.open call.
  3. Consider adding more comprehensive documentation, especially for the Android-specific behavior.

These enhancements will further improve the robustness and maintainability of the code.

apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx (1)

1-20: LGTM: Imports and styled components are well-structured

The imports are appropriate for the functionality, and the styled components follow React Native and styled-components best practices. The conditional max-width setting in the Host component is a good approach for responsive design.

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

🧹 Outside diff range and nitpick comments (1)
apps/native/app/src/screens/inbox/inbox.tsx (1)

128-132: LGTM! Consider adding type safety for the isUrgent prop.

The addition of the isUrgent prop to the InboxCard component and its inclusion in the navigation parameters align well with the PR objectives. This change enables the proper handling of urgent documents in the inbox.

To enhance type safety, consider updating the PressableListItem props type to include the isUrgent property:

type PressableListItemProps = {
  item: DocumentV2 & { isUrgent?: boolean };
  listParams: any;
};

This will ensure that the isUrgent property is properly typed and prevent potential runtime errors.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aae4acc and 2edc3ac.

📒 Files selected for processing (4)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (9 hunks)
  • apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx (1 hunks)
  • apps/native/app/src/screens/inbox/inbox.tsx (1 hunks)
  • apps/native/app/src/ui/lib/label/label.tsx (6 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/screens/document-detail/utils/get-buttons-for-actions.tsx
  • apps/native/app/src/ui/lib/label/label.tsx
🧰 Additional context used
📓 Path-based instructions (1)
apps/native/app/src/screens/inbox/inbox.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."
🔇 Additional comments (1)
apps/native/app/src/screens/inbox/inbox.tsx (1)

Line range hint 1-738: Verify GraphQL query includes the isUrgent field

The changes to handle the isUrgent property in the PressableListItem component look good. However, to ensure full functionality, we need to make sure that the GraphQL query used to fetch the documents includes the isUrgent field.

Please run the following script to check if the isUrgent field is included in the GraphQL query:

If the script doesn't return any results, you may need to update your GraphQL query to include the isUrgent field.

Copy link
Member

@snaerseljan snaerseljan left a comment

Choose a reason for hiding this comment

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

Awesome work Þórey!

Nothing breaking that I could see, but no PR can be without programmers nits 😅.
I really like the extra effort you are setting to clean up a little bit in the codebase

apps/native/app/src/ui/assets/alert/danger.png Outdated Show resolved Hide resolved
apps/native/app/src/ui/lib/detail/header.tsx Outdated Show resolved Hide resolved
apps/native/app/src/ui/lib/label/label.tsx Outdated Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (6)
apps/native/app/src/ui/lib/label/label.tsx (3)

Line range hint 21-59: LGTM: Helper function changes look good.

The addition of 'urgent' cases in all helper functions aligns well with the PR objectives. The conversion to arrow functions is a good stylistic choice for consistency.

Clarify the distinction between 'urgent' and 'danger' colors.

In getTextColor, 'urgent' has a different color than 'danger'. Can you provide some context on why this distinction is necessary? It might be helpful to add a comment explaining the difference for future maintainers.


Line range hint 60-71: LGTM: getIconByColor function updated correctly.

The addition of the 'urgent' case in getIconByColor aligns with the PR objectives.

Consider using a distinct icon for 'urgent' state.

Currently, 'urgent' and 'danger' states use the same icon. To improve user experience and clarity, consider using a distinct icon for the 'urgent' state. This would help users quickly differentiate between urgent and dangerous items.


110-112: LGTM: Label component render updated correctly.

The addition of the variant prop to LabelText with the value 'eyebrow' aligns with the earlier changes and likely corresponds to a specific typography style in your design system.

Consider adding a comment about the 'eyebrow' variant.

For clarity and easier maintenance, consider adding a brief comment explaining what the 'eyebrow' variant represents in your design system. This would help other developers understand the purpose of this specific styling.

apps/native/app/src/ui/lib/list/list-item.tsx (3)

89-89: LGTM: ListItemProps interface updated correctly

The addition of the optional urgent property to the ListItemProps interface is consistent with the new feature requirements and follows TypeScript best practices.

Consider adding a JSDoc comment to explain the purpose of the urgent property, which would improve code documentation:

/** Indicates whether the list item should be displayed as urgent */
urgent?: boolean;

100-103: LGTM: Function parameters and hooks usage updated correctly

The addition of the urgent parameter with a default value, and the use of useIntl hook are consistent with the new functionality and follow React best practices.

Consider destructuring the theme object directly in the function parameters for consistency and to avoid the extra line:

export function ListItem({
  title,
  subtitle,
  date,
  icon,
  onStarPress,
  starred = false,
  unread = false,
  urgent = false,
}: ListItemProps) {
  const intl = useIntl()
  const { theme } = useTheme()
  // ...
}

142-146: LGTM: Urgent label rendering implemented correctly

The conditional rendering of the Label component for urgent items is implemented correctly. The use of intl.formatMessage for internationalization follows best practices.

Consider adding an accessibilityLabel prop to the Label component to improve accessibility for screen readers:

{urgent && (
  <Label
    color="urgent"
    icon
    accessibilityLabel={intl.formatMessage({ id: 'inbox.urgent.accessibility' })}
  >
    {intl.formatMessage({ id: 'inbox.urgent' })}
  </Label>
)}

Don't forget to add the corresponding entry in your localization files for the new accessibility label.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0e6b1e9 and 5eb2885.

📒 Files selected for processing (6)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (10 hunks)
  • apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx (1 hunks)
  • apps/native/app/src/screens/document-detail/utils/share-file.tsx (1 hunks)
  • apps/native/app/src/ui/lib/detail/header.tsx (5 hunks)
  • apps/native/app/src/ui/lib/label/label.tsx (6 hunks)
  • apps/native/app/src/ui/lib/list/list-item.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/native/app/src/screens/document-detail/document-detail.tsx
  • apps/native/app/src/screens/document-detail/utils/get-buttons-for-actions.tsx
  • apps/native/app/src/screens/document-detail/utils/share-file.tsx
  • apps/native/app/src/ui/lib/detail/header.tsx
🧰 Additional context used
📓 Path-based instructions (2)
apps/native/app/src/ui/lib/label/label.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/list/list-item.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."
🔇 Additional comments (6)
apps/native/app/src/ui/lib/label/label.tsx (4)

89-93: LGTM: Styled component changes look good.

The update to LabelText to extend Typography and the addition of the variant prop improve the component's flexibility and consistency with the design system.


9-13: Past review comments addressed successfully.

The implementation of the 'urgent' color as a new LabelColor option addresses the concerns raised in past review comments. This approach is cleaner and more type-safe than using a separate blackTextColor property. The potential TypeScript error mentioned in a past comment has also been resolved by removing the blackTextColor property altogether.

Great job on incorporating feedback and improving the component's design!


Line range hint 1-114: Overall, excellent implementation of the new 'urgent' label functionality.

The changes in this file successfully implement the new 'urgent' label color and improve the overall structure of the Label component. The updates align well with the PR objectives and address concerns raised in past review comments.

Key improvements:

  1. Addition of 'urgent' to LabelColor type.
  2. Implementation of 'urgent' cases in all helper functions.
  3. Transition to using Typography component for better consistency.

Minor suggestions for further improvement:

  1. Consider using a distinct icon for the 'urgent' state.
  2. Add comments to clarify the distinction between 'urgent' and 'danger' colors, and explain the 'eyebrow' variant.

Great job on enhancing the component's flexibility and addressing past feedback!


7-13: LGTM: Import and type changes look good.

The addition of Typography and the new 'urgent' color in LabelColor align well with the PR objectives. These changes enhance the component's flexibility for handling urgent documents.

Consider addressing the blackTextColor property.

A past review comment mentioned issues with the blackTextColor property in HelperProps. Since this property is not present in the current implementation, it seems the issue has been resolved. Can you confirm if this is intentional and if any further adjustments are needed?

✅ Verification successful

blackTextColor Property Removed Successfully

The search confirmed that blackTextColor is not used anywhere in the codebase. The removal has been successfully addressed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if blackTextColor is used elsewhere in the codebase
rg --type typescript --type javascript 'blackTextColor'

Length of output: 90


Script:

#!/bin/bash
# Verify if blackTextColor is used elsewhere in the codebase
rg --type ts --type js 'blackTextColor'

Length of output: 39

apps/native/app/src/ui/lib/list/list-item.tsx (2)

1-1: LGTM: Import statements are correctly updated

The new imports for the Label component and useIntl hook are appropriate for the added functionality. This follows best practices for modular code organization in React and NextJS applications.

Also applies to: 3-3


Line range hint 1-156: Overall: Well-implemented feature with good practices

The changes to add the urgent functionality to the ListItem component are well-implemented and follow React Native and NextJS best practices. The code maintains good TypeScript practices and is properly internationalized.

A few minor suggestions have been made to further improve code documentation and accessibility. Great job on this implementation!

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.79%. Comparing base (b8b850d) to head (d5a3193).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16213      +/-   ##
==========================================
+ Coverage   36.73%   36.79%   +0.05%     
==========================================
  Files        6804     6793      -11     
  Lines      140860   140570     -290     
  Branches    40117    40147      +30     
==========================================
- Hits        51751    51725      -26     
+ Misses      89109    88845     -264     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-mortgage-certificate 34.92% <ø> (ø)
application-api-files 57.97% <ø> (ø)
application-core 71.83% <ø> (+0.32%) ⬆️
application-system-api 41.44% <ø> (ø)
application-template-api-modules 27.96% <ø> (+<0.01%) ⬆️
application-templates-accident-notification 29.29% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.35% <ø> (ø)
application-templates-driving-license 18.29% <ø> (ø)
application-templates-estate 12.31% <ø> (ø)
application-templates-example-payment 25.14% <ø> (ø)
application-templates-financial-aid 14.27% <ø> (ø)
application-templates-general-petition 23.43% <ø> (ø)
application-templates-health-insurance 26.41% <ø> (ø)
application-templates-inheritance-report 6.43% <ø> (ø)
application-templates-marriage-conditions 15.09% <ø> (ø)
application-templates-mortgage-certificate 43.75% <ø> (ø)
application-templates-parental-leave 29.97% <ø> (ø)
application-types 6.71% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.27% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-syslumenn 49.42% <ø> (ø)
services-auth-admin-api 51.84% <ø> (ø)
services-auth-delegation-api 57.32% <ø> (ø)
services-auth-ids-api 51.43% <ø> (+0.01%) ⬆️
services-auth-personal-representative 45.12% <ø> (-0.04%) ⬇️
services-auth-personal-representative-public 41.27% <ø> (+0.04%) ⬆️
services-auth-public-api 48.91% <ø> (ø)
services-user-notification 47.04% <ø> (+0.02%) ⬆️
services-user-profile 62.17% <ø> (ø)
testing-e2e ?
web 1.83% <ø> (ø)

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

see 67 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 b8b850d...d5a3193. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 9, 2024

Datadog Report

All test runs c10d63f 🔗

33 Total Test Services: 0 Failed, 33 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 1 increased (+0.2%), 111 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 8.31s 1 no change Link
api 0 0 0 4 0 2.76s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 12.66s 1 no change Link
api-domains-mortgage-certificate 0 0 0 5 0 18.17s 1 no change Link
application-api-files 0 0 0 12 0 5.74s 1 no change Link
application-core 0 0 0 92 0 18.55s 1 increased (+0.2%) Link
application-system-api 0 0 0 120 2 3m 13.2s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 25.03s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 20.05s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 11.43s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • services-auth-personal-representative - jest 44.01% (-0.01%) - Details

@thoreyjona thoreyjona added the automerge Merge this PR as soon as all checks pass label Oct 10, 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: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5eb2885 and 1326370.

📒 Files selected for processing (1)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (11 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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."
🔇 Additional comments (6)
apps/native/app/src/screens/document-detail/document-detail.tsx (6)

330-330: Good job extracting the share functionality

Extracting the onShare function from the inline logic improves code readability and maintainability. This change follows React best practices by keeping the component's logic organized and easy to understand.


Line range hint 360-392: Well-structured document marking logic

The extraction of the markDocumentAsRead function and the addition of the useEffect hook to handle marking the document as read are good improvements. This structure enhances code readability and ensures that the document is marked as read at the appropriate time.


436-436: Good addition of urgent label to Header

The addition of the label prop to the Header component, which displays an "urgent" label for urgent documents, is a good improvement. This change enhances the user interface by clearly indicating urgent documents.


439-458: Well-implemented ActionsWrapper component

The new ActionsWrapper component effectively handles the display of alerts and action buttons based on the document's state. The implementation is well-structured and follows React best practices, improving the overall user experience.


Line range hint 460-537: Smooth animation added to DocumentWrapper

The addition of the fade-in animation to the DocumentWrapper component is a nice touch. The implementation using React Native's Animated API is correct and follows best practices. This enhancement improves the user experience by providing a smooth transition when the document content is loaded.


Line range hint 1-543: Overall excellent improvements to DocumentDetailScreen

The changes made to the DocumentDetailScreen component significantly enhance its functionality and user experience. Key improvements include:

  1. Handling of urgent documents and confirmations
  2. Improved sharing functionality
  3. Better organization of code with extracted functions
  4. Addition of smooth animations
  5. Clear indication of urgent documents in the UI

The implementation follows React and React Native best practices, resulting in a more maintainable and performant component. Great job on these enhancements!

@oddsson oddsson added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Oct 10, 2024
@thoreyjona thoreyjona removed the automerge Merge this PR as soon as all checks pass label Oct 10, 2024
@thoreyjona thoreyjona added the automerge Merge this PR as soon as all checks pass label Oct 11, 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

🧹 Outside diff range and nitpick comments (5)
apps/native/app/src/screens/document-detail/document-detail.tsx (5)

2-2: LGTM! New imports and styled component added.

The new imports are appropriate for the added functionality. The ActionsWrapper styled component is well-defined for styling the new alert and action buttons section.

Consider using marginHorizontal instead of margin-horizontal in the ActionsWrapper styled component for better React Native compatibility:

const ActionsWrapper = styled.View`
  margin-bottom: ${({ theme }) => theme.spacing[2]}px;
- margin-horizontal: ${({ theme }) => theme.spacing[2]}px;
+ marginHorizontal: ${({ theme }) => theme.spacing[2]}px;
  gap: ${({ theme }) => theme.spacing[2]}px;
`

Also applies to: 7-12, 36-36, 55-59


238-272: LGTM! New state variables and functions added for document handling.

The new state variables and functions effectively manage the document loading process and handle confirmations for urgent documents. This implementation aligns well with the PR objectives.

Consider using a try-catch-finally block in the refetchDocumentContent function to ensure setRefetching(false) is always called, even if an error occurs:

const refetchDocumentContent = async () => {
  setRefetching(true)
  try {
    const result = await docRes.refetch({
      input: { id: docId, includeDocument: true },
    })
    if (result.data?.documentV2?.alert) {
      setShowConfirmedAlert(true)
    }
    markDocumentAsRead()
    setLoaded(true)
  } catch (error) {
    // Handle error if needed
    console.error('Error refetching document:', error)
  } finally {
    setRefetching(false)
  }
}

284-307: LGTM! Updated useGetDocumentQuery hook for handling urgent documents.

The changes to the useGetDocumentQuery hook effectively implement the logic for handling urgent documents and confirmations. The use of shouldIncludeDocument to determine whether to fetch the document content is a good approach.

Consider extracting the onCompleted logic into a separate function for improved readability:

const handleQueryCompletion = (data: GetDocumentQuery) => {
  const confirmation = data.documentV2?.confirmation
  if (confirmation && !refetching) {
    showConfirmationAlert(confirmation)
  } else if (!confirmation && !refetching && !shouldIncludeDocument) {
    refetchDocumentContent()
  }
}

// In the useGetDocumentQuery hook
onCompleted: handleQueryCompletion,

391-396: LGTM! New useEffect hook for marking documents as read.

The addition of this useEffect hook ensures that documents are marked as read when appropriate, improving the user experience. This change aligns well with the component's functionality.

Consider adding markDocumentAsRead to the dependency array of the useEffect hook to ensure it runs if the function changes:

useEffect(() => {
  if (Document.opened || !shouldIncludeDocument) {
    return
  }
  markDocumentAsRead()
}, [Document.id, Document.opened, shouldIncludeDocument, markDocumentAsRead])

Line range hint 442-511: LGTM! Updated document rendering logic for urgent documents and confirmations.

The changes to the document rendering logic effectively implement the new functionality for handling urgent documents and confirmations. The use of the ActionsWrapper component improves the organization of alerts and action buttons.

Consider extracting the PDF rendering logic into a separate component to improve readability and maintainability:

const PdfRenderer = ({ document, shouldIncludeDocument, showAlert, accessToken, onLoaded, onError }) => (
  <PdfViewer
    url={`data:application/pdf;base64,${document.content?.value}`}
    body={`documentId=${document.id}&__accessToken=${accessToken}`}
    onLoaded={onLoaded}
    onError={onError}
  />
)

// In the main component
{hasPdf && (
  <PdfWrapper>
    {visible &&
      accessToken &&
      (shouldIncludeDocument || (!shouldIncludeDocument && showAlert)) && (
        <PdfRenderer
          document={Document}
          shouldIncludeDocument={shouldIncludeDocument}
          showAlert={showAlert}
          accessToken={accessToken}
          onLoaded={(filePath: any) => {
            setPdfUrl(filePath)
            if (shouldIncludeDocument) {
              setLoaded(true)
            }
          }}
          onError={() => {
            setLoaded(true)
            setError(true)
          }}
        />
      )}
  </PdfWrapper>
)}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1326370 and adc7d79.

📒 Files selected for processing (1)
  • apps/native/app/src/screens/document-detail/document-detail.tsx (12 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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."
🔇 Additional comments (5)
apps/native/app/src/screens/document-detail/document-detail.tsx (5)

226-227: LGTM! New isUrgent prop added.

The addition of the isUrgent prop to the DocumentDetailScreen component is appropriate for handling urgent documents. This change aligns well with the new functionality described in the PR objectives.


315-322: LGTM! New variables added for improved readability.

The addition of hasActions, hasConfirmation, hasAlert, and showAlert variables improves code readability by clearly defining the conditions for showing different UI elements. This change enhances the maintainability of the component.


333-334: LGTM! Extracted onShare function.

Extracting the onShare function improves code organization and reusability. This change aligns with good coding practices by separating concerns and making the code more maintainable.


Line range hint 363-390: LGTM! Relocated markDocumentAsRead function.

The relocation of the markDocumentAsRead function improves code organization while maintaining its core functionality. This change enhances the overall structure of the component.


439-439: LGTM! Added label for urgent documents in Header.

The addition of the label prop to the Header component for urgent documents enhances the user interface by clearly indicating urgent items. This change improves the overall user experience and aligns with the PR objectives.

@kodiakhq kodiakhq bot merged commit b23340a into main Oct 11, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the feat/app-receipt-of-urgent-documents branch October 11, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants