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(ojoi): Repost failed applications #17411

Merged
merged 9 commits into from
Jan 7, 2025
Merged

Conversation

jonbjarnio
Copy link
Member

@jonbjarnio jonbjarnio commented Jan 6, 2025

What

Allowing users to try to repost their application if it has failed.

Why

To allow users to post application if it has failed

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

Release Notes

  • New Features

    • Added ability to post applications in the Official Journal of Iceland application
    • Introduced new submission functionality with error handling
  • Improvements

    • Enhanced user interface for application submission
    • Added localized error messages for submission failures
    • Implemented loading states for submission process
  • Bug Fixes

    • Improved error handling during application posting

The update provides a more robust and user-friendly application submission experience with comprehensive error reporting and state management.

@jonbjarnio jonbjarnio requested a review from a team as a code owner January 6, 2025 10:39
Copy link
Contributor

coderabbitai bot commented Jan 6, 2025

Walkthrough

This pull request introduces a new functionality for posting applications in the Official Journal of Iceland application system. The changes span multiple files across the application, adding a new mutation method in the resolver, updating the frontend hooks and components, and introducing new GraphQL mutations and error messages. The implementation enables users to submit applications with improved error handling and user experience.

Changes

File Change Summary
libs/api/domains/official-journal-of-iceland-application/src/lib/ojoiApplication.resolver.ts Added postApplication mutation method to resolver
libs/application/templates/official-journal-of-iceland/src/fields/Submitted.tsx Updated useApplication hook, added error handling and submission button
libs/application/templates/official-journal-of-iceland/src/graphql/queries.ts Added new POST_APPLICATION_MUTATION GraphQL mutation
libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts Implemented postApplication mutation hook with loading and error states
libs/application/templates/official-journal-of-iceland/src/lib/messages/submitted.tsx Added new error messages for application submission failures

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • thordurhhh
  • lodmfjord
  • Valur

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (4)
libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts (2)

50-57: Use consistent naming and grouping for newly added hook results.

These lines define the new mutation array destructuring. Ensure the naming conventions match your codebase’s established patterns (e.g., mutationResult, data, error).


107-121: Consider optional chaining for improved readability.

On line 118, you can use optional chaining to avoid explicitly checking if onComplete exists:

-        onComplete && onComplete()
+        onComplete?.()
🧰 Tools
🪛 Biome (1.9.4)

[error] 118-118: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/application/templates/official-journal-of-iceland/src/fields/Submitted.tsx (1)

139-152: Reload logic in callback could restart the submission state.

The callback to window.location.reload() once the posting completes or fails is acceptable but might be disruptive to the user. Consider a more user-friendly approach, such as refetching data or updating state without a full page reload.

libs/application/templates/official-journal-of-iceland/src/graphql/queries.ts (1)

360-364: Consider returning a status or data field to confirm mutation success.

The current mutation does not return any data—only the field call to OJOIAPostApplication(input: $input). For improved resilience, client-side error handling, and clarity, returning an explicit success field or other relevant data would let the UI confirm that the server successfully processed the request.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc3f5f and b3609a0.

📒 Files selected for processing (5)
  • libs/api/domains/official-journal-of-iceland-application/src/lib/ojoiApplication.resolver.ts (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/fields/Submitted.tsx (3 hunks)
  • libs/application/templates/official-journal-of-iceland/src/graphql/queries.ts (1 hunks)
  • libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts (4 hunks)
  • libs/application/templates/official-journal-of-iceland/src/lib/messages/submitted.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
libs/application/templates/official-journal-of-iceland/src/graphql/queries.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/official-journal-of-iceland/src/lib/messages/submitted.tsx (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/api/domains/official-journal-of-iceland-application/src/lib/ojoiApplication.resolver.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/official-journal-of-iceland/src/fields/Submitted.tsx (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts (1)

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

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🪛 Biome (1.9.4)
libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts

[error] 118-118: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: prepare
🔇 Additional comments (6)
libs/application/templates/official-journal-of-iceland/src/lib/messages/submitted.tsx (1)

45-55: Messages look great!

Both the title and message are aligned with existing message definitions. No issues noted.

libs/application/templates/official-journal-of-iceland/src/hooks/useUpdateApplication.ts (2)

15-15: Explicit import of POST_APPLICATION_MUTATION is fine.

This import cleanly indicates where the mutation originates. Looks good.


147-150: Exported mutation references are clearly defined.

The destructured postApplication, postApplicationData, postApplicationError, postApplicationLoading are newly exposed on the returning object. This is helpful for consuming components.

libs/api/domains/official-journal-of-iceland-application/src/lib/ojoiApplication.resolver.ts (1)

147-155: Ensure error handling and test coverage for the new mutation.

The postApplication mutation is straightforward. However, consider how errors or exceptions from the service are handled. Also ensure test coverage for various error cases.

Would you like me to provide a sample unit test to validate the resolver’s behavior when ojoiApplicationService.postApplication throws an error?

libs/application/templates/official-journal-of-iceland/src/fields/Submitted.tsx (2)

43-48: New properties are properly destructured.

Exposing postApplication, postApplicationError, and postApplicationLoading extends your component’s submission logic. Looks good.


119-129: Clear error handling for the postApplication process.

Displaying an alert for postApplicationError helps inform the user about failure states. This approach is consistent with the existing UI patterns.

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 35.68%. Comparing base (550571d) to head (f71b7be).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...nd-application/src/lib/ojoiApplication.resolver.ts 40.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17411      +/-   ##
==========================================
+ Coverage   35.66%   35.68%   +0.01%     
==========================================
  Files        6936     6933       -3     
  Lines      148935   148841      -94     
  Branches    42559    42517      -42     
==========================================
- Hits        53125    53109      -16     
+ Misses      95810    95732      -78     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.72% <40.00%> (-0.01%) ⬇️
application-template-api-modules 27.68% <ø> (+<0.01%) ⬆️
application-ui-shell 22.25% <ø> (ø)

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

Files with missing lines Coverage Δ
...nd-application/src/lib/ojoiApplication.resolver.ts 55.29% <40.00%> (-0.96%) ⬇️

... and 12 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 550571d...f71b7be. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 6, 2025

Datadog Report

All test runs 0693373 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 9 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.36s 1 no change Link
application-system-api 0 0 0 46 0 2m 8.2s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 5.01s 1 no change Link
application-ui-shell 0 0 0 74 0 31.79s 1 no change Link

@jonbjarnio jonbjarnio added the automerge Merge this PR as soon as all checks pass label Jan 7, 2025
@kodiakhq kodiakhq bot merged commit 50422b0 into main Jan 7, 2025
40 checks passed
@kodiakhq kodiakhq bot deleted the feat/ojoi-repost-application branch January 7, 2025 09:15
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.

2 participants